LSrelation: fix error codes prefix

This commit is contained in:
Benjamin Renard 2020-09-03 18:38:08 +02:00
parent 9db67eb2ba
commit 88d8d7f026
3 changed files with 45 additions and 45 deletions

View file

@ -1353,7 +1353,7 @@ class LSldapObject extends LSlog_staticLoggerClass {
**/ **/
public static function getObjectKeyValueInRelation($object,$objectType,$attrValues='dn') { public static function getObjectKeyValueInRelation($object,$objectType,$attrValues='dn') {
if (!$objectType) { if (!$objectType) {
LSerror :: addErrorCode('LSrelations_05','getObjectKeyValueInRelation'); LSerror :: addErrorCode('LSrelation_05','getObjectKeyValueInRelation');
return; return;
} }
if (!is_array($attrValues)) $attrValues=array($attrValues); if (!is_array($attrValues)) $attrValues=array($attrValues);
@ -1395,7 +1395,7 @@ class LSldapObject extends LSlog_staticLoggerClass {
**/ **/
public function listObjectsInRelation($object,$attr,$objectType,$attrValues='dn') { public function listObjectsInRelation($object,$attr,$objectType,$attrValues='dn') {
if ((!$attr)||(!$objectType)) { if ((!$attr)||(!$objectType)) {
LSerror :: addErrorCode('LSrelations_05','listObjectsInRelation'); LSerror :: addErrorCode('LSrelation_05','listObjectsInRelation');
return; return;
} }
if (!is_array($attrValues)) $attrValues=array($attrValues); if (!is_array($attrValues)) $attrValues=array($attrValues);
@ -1428,7 +1428,7 @@ class LSldapObject extends LSlog_staticLoggerClass {
**/ **/
public function addOneObjectInRelation($object,$attr,$objectType,$attrValue='dn',$canEditFunction=NULL) { public function addOneObjectInRelation($object,$attr,$objectType,$attrValue='dn',$canEditFunction=NULL) {
if ((!$attr)||(!$objectType)) { if ((!$attr)||(!$objectType)) {
LSerror :: addErrorCode('LSrelations_05','addOneObjectInRelation'); LSerror :: addErrorCode('LSrelation_05','addOneObjectInRelation');
return; return;
} }
if ($object instanceof $objectType) { if ($object instanceof $objectType) {
@ -1493,7 +1493,7 @@ class LSldapObject extends LSlog_staticLoggerClass {
**/ **/
public function deleteOneObjectInRelation($object,$attr,$objectType,$attrValue='dn',$canEditFunction=NULL,$attrValues=null) { public function deleteOneObjectInRelation($object,$attr,$objectType,$attrValue='dn',$canEditFunction=NULL,$attrValues=null) {
if ((!$attr)||(!$objectType)) { if ((!$attr)||(!$objectType)) {
LSerror :: addErrorCode('LSrelations_05','deleteOneObjectInRelation'); LSerror :: addErrorCode('LSrelation_05','deleteOneObjectInRelation');
return; return;
} }
if ($object instanceof $objectType) { if ($object instanceof $objectType) {
@ -1544,7 +1544,7 @@ class LSldapObject extends LSlog_staticLoggerClass {
*/ */
public function renameOneObjectInRelation($object,$oldValues,$attr,$objectType,$attrValue='dn') { public function renameOneObjectInRelation($object,$oldValues,$attr,$objectType,$attrValue='dn') {
if ((!$attr)||(!$objectType)) { if ((!$attr)||(!$objectType)) {
LSerror :: addErrorCode('LSrelations_05','renameOneObjectInRelation'); LSerror :: addErrorCode('LSrelation_05','renameOneObjectInRelation');
return; return;
} }
if (!is_array($oldValues)) $oldValues=array($oldValues); if (!is_array($oldValues)) $oldValues=array($oldValues);
@ -1600,7 +1600,7 @@ class LSldapObject extends LSlog_staticLoggerClass {
**/ **/
public function updateObjectsInRelation($object,$listDns,$attr,$objectType,$attrValue='dn',$canEditFunction=NULL,$attrValues=null) { public function updateObjectsInRelation($object,$listDns,$attr,$objectType,$attrValue='dn',$canEditFunction=NULL,$attrValues=null) {
if ((!$attr)||(!$objectType)) { if ((!$attr)||(!$objectType)) {
LSerror :: addErrorCode('LSrelations_05','updateObjectsInRelation'); LSerror :: addErrorCode('LSrelation_05','updateObjectsInRelation');
return; return;
} }
if (!is_array($attrValues)) $attrValues=array($attrValue); if (!is_array($attrValues)) $attrValues=array($attrValue);
@ -2999,7 +2999,7 @@ ___("LSldapObject : Error during generating container DN : %{error}")
); );
// LSrelation // LSrelation
LSerror :: defineError('LSrelations_05', LSerror :: defineError('LSrelation_05',
___("LSrelation : Some parameters are missing in the call of methods to handle standard relations (Method : %{meth}).") ___("LSrelation : Some parameters are missing in the call of methods to handle standard relations (Method : %{meth}).")
); );

View file

@ -52,7 +52,7 @@ class LSrelation extends LSlog_staticLoggerClass {
if (!is_array($this -> config) || !$this -> checkConfig()) { if (!is_array($this -> config) || !$this -> checkConfig()) {
$this -> config = null; $this -> config = null;
LSerror :: addErrorCode( LSerror :: addErrorCode(
'LSrelations_02', 'LSrelation_02',
array( array(
'relation' => $relationName, 'relation' => $relationName,
'LSobject' => $obj -> getType() 'LSobject' => $obj -> getType()
@ -119,7 +119,7 @@ class LSrelation extends LSlog_staticLoggerClass {
// Check LSobject parameter // Check LSobject parameter
if (!$this -> LSobject) { if (!$this -> LSobject) {
LSerror :: addErrorCode( LSerror :: addErrorCode(
'LSrelations_07', 'LSrelation_07',
array( array(
'parameter' => 'LSobject', 'parameter' => 'LSobject',
'relation' => $this -> name, 'relation' => $this -> name,
@ -132,7 +132,7 @@ class LSrelation extends LSlog_staticLoggerClass {
// Load related object type // Load related object type
if (!LSsession :: loadLSobject($this -> LSobject)) { if (!LSsession :: loadLSobject($this -> LSobject)) {
LSerror :: addErrorCode( LSerror :: addErrorCode(
'LSrelations_04', 'LSrelation_04',
array( array(
'relation' => $this -> name, 'relation' => $this -> name,
'LSobject' => $this -> LSobject 'LSobject' => $this -> LSobject
@ -146,7 +146,7 @@ class LSrelation extends LSlog_staticLoggerClass {
// Check linkAttribute refered to an existing related object type attribute // Check linkAttribute refered to an existing related object type attribute
if (!call_user_func(array($this -> LSobject, 'hasAttr'), $this -> linkAttribute)) { if (!call_user_func(array($this -> LSobject, 'hasAttr'), $this -> linkAttribute)) {
LSerror :: addErrorCode( LSerror :: addErrorCode(
'LSrelations_08', 'LSrelation_08',
array( array(
'parameter' => 'linkAttribute', 'parameter' => 'linkAttribute',
'relation' => $this -> name, 'relation' => $this -> name,
@ -159,7 +159,7 @@ class LSrelation extends LSlog_staticLoggerClass {
// Check linkAttributeValue // Check linkAttributeValue
if ($this -> linkAttributeValue != 'dn' && !$this -> obj -> hasAttr($this -> linkAttributeValue)) { if ($this -> linkAttributeValue != 'dn' && !$this -> obj -> hasAttr($this -> linkAttributeValue)) {
LSerror :: addErrorCode( LSerror :: addErrorCode(
'LSrelations_08', 'LSrelation_08',
array( array(
'parameter' => 'linkAttributeValue', 'parameter' => 'linkAttributeValue',
'relation' => $this -> name, 'relation' => $this -> name,
@ -182,7 +182,7 @@ class LSrelation extends LSlog_staticLoggerClass {
// Check parameter is defined // Check parameter is defined
if (!$this -> $p) { if (!$this -> $p) {
LSerror :: addErrorCode( LSerror :: addErrorCode(
'LSrelations_07', 'LSrelation_07',
array( array(
'parameter' => $p, 'parameter' => $p,
'relation' => $this -> name, 'relation' => $this -> name,
@ -195,7 +195,7 @@ class LSrelation extends LSlog_staticLoggerClass {
// Check parameter refered to an existing related object class method // Check parameter refered to an existing related object class method
if (!method_exists($this -> LSobject, $this -> $p)) { if (!method_exists($this -> LSobject, $this -> $p)) {
LSerror :: addErrorCode( LSerror :: addErrorCode(
'LSrelations_01', 'LSrelation_01',
array( array(
'parameter' => $p, 'parameter' => $p,
'function' => $this -> $p, 'function' => $this -> $p,
@ -260,7 +260,7 @@ class LSrelation extends LSlog_staticLoggerClass {
// Load related object type // Load related object type
if (!LSsession :: loadLSobject($this -> LSobject)) { if (!LSsession :: loadLSobject($this -> LSobject)) {
LSerror :: addErrorCode( LSerror :: addErrorCode(
'LSrelations_04', 'LSrelation_04',
array( array(
'relation' => $this -> name, 'relation' => $this -> name,
'LSobject' => $this -> LSobject 'LSobject' => $this -> LSobject
@ -281,7 +281,7 @@ class LSrelation extends LSlog_staticLoggerClass {
); );
} }
LSerror :: addErrorCode( LSerror :: addErrorCode(
'LSrelations_01', 'LSrelation_01',
array( array(
'parameter' => 'list_function', 'parameter' => 'list_function',
'function' => $this -> list_function, 'function' => $this -> list_function,
@ -304,7 +304,7 @@ class LSrelation extends LSlog_staticLoggerClass {
// Configuration problem // Configuration problem
LSerror :: addErrorCode( LSerror :: addErrorCode(
'LSrelations_05', 'LSrelation_05',
array( array(
'relation' => $this -> name, 'relation' => $this -> name,
'LSobject' => $this -> LSobject, 'LSobject' => $this -> LSobject,
@ -323,7 +323,7 @@ class LSrelation extends LSlog_staticLoggerClass {
// Load related object type // Load related object type
if (!LSsession :: loadLSobject($this -> LSobject)) { if (!LSsession :: loadLSobject($this -> LSobject)) {
LSerror :: addErrorCode( LSerror :: addErrorCode(
'LSrelations_04', 'LSrelation_04',
array( array(
'relation' => $this -> name, 'relation' => $this -> name,
'LSobject' => $this -> LSobject 'LSobject' => $this -> LSobject
@ -344,7 +344,7 @@ class LSrelation extends LSlog_staticLoggerClass {
); );
} }
LSerror :: addErrorCode( LSerror :: addErrorCode(
'LSrelations_01', 'LSrelation_01',
array( array(
'parameter' => 'getkeyvalue_function', 'parameter' => 'getkeyvalue_function',
'function' => $this -> getkeyvalue_function, 'function' => $this -> getkeyvalue_function,
@ -366,7 +366,7 @@ class LSrelation extends LSlog_staticLoggerClass {
// Configuration problem // Configuration problem
LSerror :: addErrorCode( LSerror :: addErrorCode(
'LSrelations_05', 'LSrelation_05',
array( array(
'relation' => $this -> name, 'relation' => $this -> name,
'LSobject' => $this -> LSobject, 'LSobject' => $this -> LSobject,
@ -392,7 +392,7 @@ class LSrelation extends LSlog_staticLoggerClass {
return call_user_func(array($objRel, $this -> canEdit_function)); return call_user_func(array($objRel, $this -> canEdit_function));
} }
LSerror :: addErrorCode( LSerror :: addErrorCode(
'LSrelations_01', 'LSrelation_01',
array( array(
'parameter' => 'canEdit_function', 'parameter' => 'canEdit_function',
'function' => $this -> canEdit_function, 'function' => $this -> canEdit_function,
@ -414,7 +414,7 @@ class LSrelation extends LSlog_staticLoggerClass {
// Configuration problem // Configuration problem
LSerror :: addErrorCode( LSerror :: addErrorCode(
'LSrelations_05', 'LSrelation_05',
array( array(
'relation' => $this -> name, 'relation' => $this -> name,
'LSobject' => $this -> LSobject, 'LSobject' => $this -> LSobject,
@ -441,7 +441,7 @@ class LSrelation extends LSlog_staticLoggerClass {
); );
} }
LSerror :: addErrorCode( LSerror :: addErrorCode(
'LSrelations_01', 'LSrelation_01',
array( array(
'parameter' => 'remove_function', 'parameter' => 'remove_function',
'function' => $this -> remove_function, 'function' => $this -> remove_function,
@ -459,7 +459,7 @@ class LSrelation extends LSlog_staticLoggerClass {
// Configuration problem // Configuration problem
LSerror :: addErrorCode( LSerror :: addErrorCode(
'LSrelations_05', 'LSrelation_05',
array( array(
'relation' => $this -> name, 'relation' => $this -> name,
'LSobject' => $this -> LSobject, 'LSobject' => $this -> LSobject,
@ -484,7 +484,7 @@ class LSrelation extends LSlog_staticLoggerClass {
return call_user_func_array(array($objRel, $this -> rename_function), array(&$this -> obj, $oldKeyValue)); return call_user_func_array(array($objRel, $this -> rename_function), array(&$this -> obj, $oldKeyValue));
} }
LSerror :: addErrorCode( LSerror :: addErrorCode(
'LSrelations_01', 'LSrelation_01',
array( array(
'parameter' => 'rename_function', 'parameter' => 'rename_function',
'function' => $this -> rename_function, 'function' => $this -> rename_function,
@ -508,7 +508,7 @@ class LSrelation extends LSlog_staticLoggerClass {
// Configuration problem // Configuration problem
LSerror :: addErrorCode( LSerror :: addErrorCode(
'LSrelations_05', 'LSrelation_05',
array( array(
'relation' => $this -> name, 'relation' => $this -> name,
'LSobject' => $this -> LSobject, 'LSobject' => $this -> LSobject,
@ -529,7 +529,7 @@ class LSrelation extends LSlog_staticLoggerClass {
// Load related objects type // Load related objects type
if (!LSsession :: loadLSobject($this -> LSobject)) { if (!LSsession :: loadLSobject($this -> LSobject)) {
LSerror :: addErrorCode( LSerror :: addErrorCode(
'LSrelations_04', 'LSrelation_04',
array( array(
'relation' => $this -> name, 'relation' => $this -> name,
'LSobject' => $this -> LSobject 'LSobject' => $this -> LSobject
@ -550,7 +550,7 @@ class LSrelation extends LSlog_staticLoggerClass {
); );
} }
LSerror :: addErrorCode( LSerror :: addErrorCode(
'LSrelations_01', 'LSrelation_01',
array( array(
'parameter' => 'update_function', 'parameter' => 'update_function',
'function' => $this -> update_function, 'function' => $this -> update_function,
@ -576,7 +576,7 @@ class LSrelation extends LSlog_staticLoggerClass {
// Configuration problem // Configuration problem
LSerror :: addErrorCode( LSerror :: addErrorCode(
'LSrelations_05', 'LSrelation_05',
array( array(
'relation' => $this -> name, 'relation' => $this -> name,
'LSobject' => $this -> LSobject, 'LSobject' => $this -> LSobject,
@ -622,7 +622,7 @@ class LSrelation extends LSlog_staticLoggerClass {
return; return;
$LSrelations=array(); $LSrelations=array();
$LSrelations_JSparams=array(); $LSrelation_JSparams=array();
foreach($object -> getConfig('LSrelation') as $relationName => $relationConf) { foreach($object -> getConfig('LSrelation') as $relationName => $relationConf) {
// Check user access // Check user access
if (!LSsession :: relationCanAccess($object -> getValue('dn'), $object->getType(), $relationName)) { if (!LSsession :: relationCanAccess($object -> getValue('dn'), $object->getType(), $relationName)) {
@ -644,7 +644,7 @@ class LSrelation extends LSlog_staticLoggerClass {
$id=rand(); $id=rand();
$return['id']=$id; $return['id']=$id;
$LSrelations_JSparams[$id]=array( $LSrelation_JSparams[$id]=array(
'emptyText' => $return['emptyText'] 'emptyText' => $return['emptyText']
); );
$_SESSION['LSrelation'][$id] = array( $_SESSION['LSrelation'][$id] = array(
@ -692,7 +692,7 @@ class LSrelation extends LSlog_staticLoggerClass {
self :: loadDependenciesDisplay(); self :: loadDependenciesDisplay();
LStemplate :: assign('LSrelations',$LSrelations); LStemplate :: assign('LSrelations',$LSrelations);
LStemplate :: addJSconfigParam('LSrelations',$LSrelations_JSparams); LStemplate :: addJSconfigParam('LSrelations',$LSrelation_JSparams);
} }
/* /*
@ -857,7 +857,7 @@ class LSrelation extends LSlog_staticLoggerClass {
// Update related objects // Update related objects
if (!$relation -> updateRelations(array_keys($selected_objects))) { if (!$relation -> updateRelations(array_keys($selected_objects))) {
LSerror :: addErrorCode('LSrelations_03', $conf['relationName']); LSerror :: addErrorCode('LSrelation_03', $conf['relationName']);
self :: log_warning("Fail to update objects in relation"); self :: log_warning("Fail to update objects in relation");
return; return;
} }
@ -907,7 +907,7 @@ class LSrelation extends LSlog_staticLoggerClass {
$list = $relation -> listRelatedObjects(); $list = $relation -> listRelatedObjects();
if (!is_array($list)) { if (!is_array($list)) {
self :: log_warning('Fail to list related objects'); self :: log_warning('Fail to list related objects');
LSerror :: addErrorCode('LSrelations_03',$conf['relationName']); LSerror :: addErrorCode('LSrelation_03',$conf['relationName']);
return; return;
} }
@ -923,7 +923,7 @@ class LSrelation extends LSlog_staticLoggerClass {
return; return;
} }
if (!$relation -> removeRelationWithObject($o)) { if (!$relation -> removeRelationWithObject($o)) {
LSerror :: addErrorCode('LSrelations_03', $conf['relationName']); LSerror :: addErrorCode('LSrelation_03', $conf['relationName']);
return; return;
} }
else { else {
@ -936,7 +936,7 @@ class LSrelation extends LSlog_staticLoggerClass {
// Check object found // Check object found
if (!$found) { if (!$found) {
self :: log_warning("Object '".$_REQUEST['dn']."' not found in related objects list."); self :: log_warning("Object '".$_REQUEST['dn']."' not found in related objects list.");
LSerror :: addErrorCode('LSrelations_03', $conf['relationName']); LSerror :: addErrorCode('LSrelation_03', $conf['relationName']);
return; return;
} }
@ -950,27 +950,27 @@ class LSrelation extends LSlog_staticLoggerClass {
/** /**
* Error Codes * Error Codes
**/ **/
LSerror :: defineError('LSrelations_01', LSerror :: defineError('LSrelation_01',
___("LSrelation : Invalid parameter '%{parameter}' of the relation %{relation}: objects %{LSobject} have no function '%{function}'.") ___("LSrelation : Invalid parameter '%{parameter}' of the relation %{relation}: objects %{LSobject} have no function '%{function}'.")
); );
LSerror :: defineError('LSrelations_02', LSerror :: defineError('LSrelation_02',
___("LSrelation : Relation %{relation} of object type %{LSobject} unknown.") ___("LSrelation : Relation %{relation} of object type %{LSobject} unknown.")
); );
LSerror :: defineError('LSrelations_03', LSerror :: defineError('LSrelation_03',
___("LSrelation : Error during relation update of the relation %{relation}.") ___("LSrelation : Error during relation update of the relation %{relation}.")
); );
LSerror :: defineError('LSrelations_04', LSerror :: defineError('LSrelation_04',
___("LSrelation : Object type %{LSobject} unknown (Relation : %{relation}).") ___("LSrelation : Object type %{LSobject} unknown (Relation : %{relation}).")
); );
LSerror :: defineError('LSrelations_05', LSerror :: defineError('LSrelation_05',
___("LSrelation : Incomplete configuration for LSrelation %{relation} of object type %{LSobject} for action : %{action}.") ___("LSrelation : Incomplete configuration for LSrelation %{relation} of object type %{LSobject} for action : %{action}.")
); );
LSerror :: defineError('LSrelations_06', LSerror :: defineError('LSrelation_06',
___("LSrelation : Invalid editable attribute for LSrelation %{relation} with LSobject %{LSobject}.") ___("LSrelation : Invalid editable attribute for LSrelation %{relation} with LSobject %{LSobject}.")
); );
LSerror :: defineError('LSrelations_07', LSerror :: defineError('LSrelation_07',
___("LSrelation : The configuration parameter '%{parameter}' of the relation %{relation} of %{LSobject} is missing.") ___("LSrelation : The configuration parameter '%{parameter}' of the relation %{relation} of %{LSobject} is missing.")
); );
LSerror :: defineError('LSrelations_08', LSerror :: defineError('LSrelation_08',
___("LSrelation : The configuration parameter '%{parameter}' of the relation %{relation} of %{LSobject} is invalid.") ___("LSrelation : The configuration parameter '%{parameter}' of the relation %{relation} of %{LSobject} is invalid.")
); );

View file

@ -862,7 +862,7 @@ function handle_LSobject_create($request) {
$object -> attrs[$attr] -> data = array($value); $object -> attrs[$attr] -> data = array($value);
} }
else { else {
LSerror :: addErrorCode('LSrelations_06',array('relation' => $relation -> getName(),'LSobject' => $obj -> getType())); LSerror :: addErrorCode('LSrelation_06',array('relation' => $relation -> getName(),'LSobject' => $obj -> getType()));
} }
} }
else { else {