From 124366f41a45a2d1dceb69bda28d7c65fae595dc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 11 Nov 2012 23:31:45 +0100 Subject: [PATCH] Fix: To be compatible with LDAP synchro, property oldcopy must be set. We add a warning if not. --- ...interface_50_modLdap_Ldapsynchro.class.php | 33 +++++++++++++++++++ htdocs/user/class/usergroup.class.php | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php index 7c151ae09c4..c756f9a89f3 100755 --- a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php @@ -134,6 +134,12 @@ class InterfaceLdapsynchro $ldap=new Ldap(); $ldap->connect_bind(); + if (empty($object->oldcopy) || ! is_object($object->oldcopy)) + { + dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING); + $object->oldcopy=dol_clone($object); + } + $oldinfo=$object->oldcopy->_load_ldap_info(); $olddn=$object->oldcopy->_load_ldap_dn($oldinfo); @@ -165,6 +171,12 @@ class InterfaceLdapsynchro $ldap=new Ldap(); $ldap->connect_bind(); + if (empty($object->oldcopy) || ! is_object($object->oldcopy)) + { + dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING); + $object->oldcopy=dol_clone($object); + } + $oldinfo=$object->oldcopy->_load_ldap_info(); $olddn=$object->oldcopy->_load_ldap_dn($oldinfo); @@ -291,6 +303,7 @@ class InterfaceLdapsynchro // Groupes elseif ($action == 'GROUP_CREATE') { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { $ldap=new Ldap(); @@ -313,11 +326,18 @@ class InterfaceLdapsynchro } elseif ($action == 'GROUP_MODIFY') { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { $ldap=new Ldap(); $ldap->connect_bind(); + if (empty($object->oldcopy) || ! is_object($object->oldcopy)) + { + dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING); + $object->oldcopy=dol_clone($object); + } + $oldinfo=$object->oldcopy->_load_ldap_info(); $olddn=$object->oldcopy->_load_ldap_dn($oldinfo); @@ -343,6 +363,7 @@ class InterfaceLdapsynchro } elseif ($action == 'GROUP_DELETE') { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { $ldap=new Ldap(); @@ -388,6 +409,12 @@ class InterfaceLdapsynchro $ldap=new Ldap(); $ldap->connect_bind(); + if (empty($object->oldcopy) || ! is_object($object->oldcopy)) + { + dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING); + $object->oldcopy=dol_clone($object); + } + $oldinfo=$object->oldcopy->_load_ldap_info(); $olddn=$object->oldcopy->_load_ldap_dn($oldinfo); @@ -511,6 +538,12 @@ class InterfaceLdapsynchro $ldap=new Ldap(); $ldap->connect_bind(); + if (empty($object->oldcopy) || ! is_object($object->oldcopy)) + { + dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING); + $object->oldcopy=dol_clone($object); + } + $oldinfo=$object->oldcopy->_load_ldap_info(); $olddn=$object->oldcopy->_load_ldap_dn($oldinfo); diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 21ea7606e29..d5170955162 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -628,7 +628,7 @@ class UserGroup extends CommonObject $sql.= ", note = '" . $this->db->escape($this->note) . "'"; $sql.= " WHERE rowid = " . $this->id; - dol_syslog("Usergroup::update sql=".$sql); + dol_syslog(get_class($this)."::update sql=".$sql); $resql = $this->db->query($sql); if ($resql) {