mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-26 19:54:46 +01:00
LSldapObject : use LSlog_logger
This commit is contained in:
parent
0cac3631c6
commit
2f8d644af0
1 changed files with 26 additions and 25 deletions
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
LSsession :: loadLSclass('LSlog_staticLoggerClass');
|
||||||
LSsession :: loadLSclass('LSattribute');
|
LSsession :: loadLSclass('LSattribute');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,7 +30,7 @@ LSsession :: loadLSclass('LSattribute');
|
||||||
*
|
*
|
||||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||||
*/
|
*/
|
||||||
class LSldapObject {
|
class LSldapObject extends LSlog_staticLoggerClass {
|
||||||
|
|
||||||
var $config = array();
|
var $config = array();
|
||||||
var $type_name;
|
var $type_name;
|
||||||
|
@ -343,9 +344,9 @@ class LSldapObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($this -> validateAttrsData($idForm)) {
|
if($this -> validateAttrsData($idForm)) {
|
||||||
LSdebug("les données sont validées");
|
self :: log("DEBUG", "les données sont validées");
|
||||||
if ($justValidate) {
|
if ($justValidate) {
|
||||||
LSdebug('Just validate mode');
|
self :: log("DEBUG", 'Just validate mode');
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,7 +362,7 @@ class LSldapObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this -> submitChange($idForm)) {
|
if ($this -> submitChange($idForm)) {
|
||||||
LSdebug('Les modifications sont submitées');
|
self :: log("DEBUG", 'Les modifications sont submitées');
|
||||||
// Event After Modify
|
// Event After Modify
|
||||||
$this -> fireEvent('after_modify');
|
$this -> fireEvent('after_modify');
|
||||||
|
|
||||||
|
@ -590,7 +591,7 @@ class LSldapObject {
|
||||||
if(($attr -> isUpdate())&&($attr -> isValidate())) {
|
if(($attr -> isUpdate())&&($attr -> isValidate())) {
|
||||||
if(($attr -> name == $this -> getConfig('rdn')) && (!$new)) {
|
if(($attr -> name == $this -> getConfig('rdn')) && (!$new)) {
|
||||||
$new = true;
|
$new = true;
|
||||||
LSdebug('Rename');
|
self :: log("DEBUG", 'Rename');
|
||||||
if (!$this -> fireEvent('before_rename')) {
|
if (!$this -> fireEvent('before_rename')) {
|
||||||
LSerror :: addErrorCode('LSldapObject_16');
|
LSerror :: addErrorCode('LSldapObject_16');
|
||||||
return;
|
return;
|
||||||
|
@ -626,7 +627,7 @@ class LSldapObject {
|
||||||
$dn=$this -> getDn();
|
$dn=$this -> getDn();
|
||||||
if($dn) {
|
if($dn) {
|
||||||
$this -> dn=$dn;
|
$this -> dn=$dn;
|
||||||
LSdebug($submitData);
|
self :: log("DEBUG", $submitData);
|
||||||
if ($new) {
|
if ($new) {
|
||||||
if (!$this -> fireEvent('before_create')) {
|
if (!$this -> fireEvent('before_create')) {
|
||||||
LSerror :: addErrorCode('LSldapObject_20');
|
LSerror :: addErrorCode('LSldapObject_20');
|
||||||
|
@ -1142,7 +1143,7 @@ class LSldapObject {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LSdebug('Problème durant la mise en cache de la relation '.$relation_name);
|
self :: log("DEBUG", 'Problème durant la mise en cache de la relation '.$relation_name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1266,7 +1267,7 @@ class LSldapObject {
|
||||||
* @retval True en cas de cas ce succès, False sinon.
|
* @retval True en cas de cas ce succès, False sinon.
|
||||||
*/
|
*/
|
||||||
private function afterCreate() {
|
private function afterCreate() {
|
||||||
LSdebug('after');
|
self :: log("DEBUG", 'after');
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
// container_auto_create
|
// container_auto_create
|
||||||
|
@ -1278,7 +1279,7 @@ class LSldapObject {
|
||||||
if (isset($conf_type['container_auto_create'])&&isset($conf_type['container_dn'])) {
|
if (isset($conf_type['container_auto_create'])&&isset($conf_type['container_dn'])) {
|
||||||
$dn = $conf_type['container_dn'].','.$this -> getDn();
|
$dn = $conf_type['container_dn'].','.$this -> getDn();
|
||||||
if(!LSldap :: getNewEntry($dn,$conf_type['container_auto_create']['objectclass'],$conf_type['container_auto_create']['attrs'],true)) {
|
if(!LSldap :: getNewEntry($dn,$conf_type['container_auto_create']['objectclass'],$conf_type['container_auto_create']['attrs'],true)) {
|
||||||
LSdebug("Impossible de créer l'entrée fille : ".print_r(
|
self :: log("DEBUG", "Impossible de créer l'entrée fille : ".print_r(
|
||||||
array(
|
array(
|
||||||
'dn' => $dn,
|
'dn' => $dn,
|
||||||
'objectClass' => $conf_type['container_auto_create']['objectclass'],
|
'objectClass' => $conf_type['container_auto_create']['objectclass'],
|
||||||
|
@ -1910,7 +1911,7 @@ class LSldapObject {
|
||||||
|
|
||||||
$obj = new $objType();
|
$obj = new $objType();
|
||||||
if (!$obj->loadData($dn)) {
|
if (!$obj->loadData($dn)) {
|
||||||
LSlog :: fatal("Fail to load object $dn data from LDAP");
|
self :: log("FATAL", "Fail to load object $dn data from LDAP");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1961,7 +1962,7 @@ class LSldapObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LSlog :: error("Fail to load related objects.");
|
self :: log("ERROR", "Fail to load related objects.");
|
||||||
}
|
}
|
||||||
echo "\n";
|
echo "\n";
|
||||||
}
|
}
|
||||||
|
@ -2035,7 +2036,7 @@ class LSldapObject {
|
||||||
|
|
||||||
$obj = new $objType();
|
$obj = new $objType();
|
||||||
if (!$obj->loadData($dn)) {
|
if (!$obj->loadData($dn)) {
|
||||||
LSlog :: fatal("Fail to load object $dn data from LDAP");
|
self :: log("FATAL", "Fail to load object $dn data from LDAP");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2053,10 +2054,10 @@ class LSldapObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($obj -> remove()) {
|
if ($obj -> remove()) {
|
||||||
LSlog :: info("Object ".$obj->getDn()." removed.");
|
self :: log("INFO", "Object ".$obj->getDn()." removed.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
LSlog :: error("Fail to remove object ".$obj->getDn().".");
|
self :: log("ERROR", "Fail to remove object ".$obj->getDn().".");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2109,17 +2110,17 @@ class LSldapObject {
|
||||||
|
|
||||||
$obj = new $objType();
|
$obj = new $objType();
|
||||||
if (!$obj->loadData($dn)) {
|
if (!$obj->loadData($dn)) {
|
||||||
LSlog :: fatal("Fail to load object $dn data from LDAP");
|
self :: log("FATAL", "Fail to load object $dn data from LDAP");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!LSsession :: loadLSclass('LSrelation')) {
|
if (!LSsession :: loadLSclass('LSrelation')) {
|
||||||
LSlog :: fatal("Fail to load LSrelation class.");
|
self :: log("FATAL", "Fail to load LSrelation class.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_array($obj -> getConfig("LSrelation.$relName"))) {
|
if (!is_array($obj -> getConfig("LSrelation.$relName"))) {
|
||||||
LSlog :: fatal("LSobject $objType have no relation '$relName'.");
|
self :: log("FATAL", "LSobject $objType have no relation '$relName'.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2133,7 +2134,7 @@ class LSldapObject {
|
||||||
$listDns[] = $o -> getDn();
|
$listDns[] = $o -> getDn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LSlog :: debug("Current related object(s) :".varDump($listDns));
|
self :: log("DEBUG", "Current related object(s) :".varDump($listDns));
|
||||||
|
|
||||||
// Keep a copy of initial related objects list
|
// Keep a copy of initial related objects list
|
||||||
$initialListDns = $listDns;
|
$initialListDns = $listDns;
|
||||||
|
@ -2150,7 +2151,7 @@ class LSldapObject {
|
||||||
foreach ($add as $dn) {
|
foreach ($add as $dn) {
|
||||||
// Check if DN is already in relation
|
// Check if DN is already in relation
|
||||||
if (in_array($dn, $listDns)) {
|
if (in_array($dn, $listDns)) {
|
||||||
LSlog :: debug("LSobject $relatedLSobject $dn is already in relation with ".$obj -> getDn().".");
|
self :: log("DEBUG", "LSobject $relatedLSobject $dn is already in relation with ".$obj -> getDn().".");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2159,7 +2160,7 @@ class LSldapObject {
|
||||||
$search -> run(false);
|
$search -> run(false);
|
||||||
$result = $search -> listObjectsDn();
|
$result = $search -> listObjectsDn();
|
||||||
if (!is_array($result) || count($result) != 1) {
|
if (!is_array($result) || count($result) != 1) {
|
||||||
LSlog :: error("No $relatedLSobject found for DN $dn");
|
self :: log("ERROR", "No $relatedLSobject found for DN $dn");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$listDns[] = $dn;
|
$listDns[] = $dn;
|
||||||
|
@ -2175,20 +2176,20 @@ class LSldapObject {
|
||||||
unset($listDns[$key]);
|
unset($listDns[$key]);
|
||||||
}
|
}
|
||||||
if (!$found)
|
if (!$found)
|
||||||
LSlog :: debug("LSobject $relatedLSobject $dn is not in relation with ".$obj -> getDn().".");
|
self :: log("DEBUG", "LSobject $relatedLSobject $dn is not in relation with ".$obj -> getDn().".");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($initialListDns == $listDns) {
|
if ($initialListDns == $listDns) {
|
||||||
LSlog :: info('No changes done.');
|
self :: log("INFO", 'No changes done.');
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
LSlog :: debug("New related object(s) list: ".varDump($listDns));
|
self :: log("DEBUG", "New related object(s) list: ".varDump($listDns));
|
||||||
if ($relation -> updateRelations($listDns)) {
|
if ($relation -> updateRelations($listDns)) {
|
||||||
LSlog :: info('Objects in relation updated.');
|
self :: log("INFO", 'Objects in relation updated.');
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
LSlog :: error("Fail to update objects in relation");
|
self :: log("ERROR", "Fail to update objects in relation");
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue