diff --git a/htdocs/adherents/adherent.class.php b/htdocs/adherents/adherent.class.php index df183d5d5ba..49dc2d46c99 100644 --- a/htdocs/adherents/adherent.class.php +++ b/htdocs/adherents/adherent.class.php @@ -344,20 +344,10 @@ class Adherent include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); $interface=new Interfaces($this->db); $result=$interface->run_triggers('MEMBER_CREATE',$this,$user,$langs,$conf); + if ($result < 0) $error++; // Fin appel triggers - // \todo Mettre en trigger - if ($conf->ldap->enabled && $conf->global->LDAP_MEMBER_ACTIVE) - { - $ldap=new Ldap(); - $ldap->connect_bind(); - $info=$this->_load_ldap_info(); - $dn=$this->_load_ldap_dn($info); - - $ldap->add($dn,$info,$user); - } - - return 1; + return $this->id; } else { @@ -369,14 +359,14 @@ class Adherent /** \brief fonction qui met à jour l'adhérent - \param disable_triggers 1=désactive le trigger UPDATE (quand appelé par creation) - \return int <0 si ko, >0 si ok + \param notrigger 1=désactive le trigger UPDATE (quand appelé par creation) + \return int <0 si KO, >0 si OK */ - function update($disable_trigger=0) + function update($notrigger=0) { global $conf,$langs,$user; - dolibarr_syslog("Adherent.class::update $disable_trigger"); + dolibarr_syslog("Adherent.class::update $notrigger"); // Verification parametres if ($conf->global->ADHERENT_MAIL_REQUIRED && ! ValidEMail($this->email)) @@ -444,26 +434,14 @@ class Adherent } } - if (! $disable_trigger) + if (! $notrigger) { // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); $interface=new Interfaces($this->db); $result=$interface->run_triggers('MEMBER_MODIFY',$this,$user,$langs,$conf); - // Fin appel triggers - - // \todo Mettre en trigger - if ($conf->ldap->enabled && $conf->global->LDAP_MEMBER_ACTIVE) - { - $ldap=new Ldap(); - $ldap->connect_bind(); - - $info=$this->_load_ldap_info(); - $dn=$this->_load_ldap_dn($info); - - $ldap->update($dn,$info,$user); - } - + if ($result < 0) $error++; + // Fin appel triggers } $this->db->commit(); @@ -475,6 +453,7 @@ class Adherent /** \brief Fonction qui supprime l'adhérent et les données associées \param rowid + \return int <0 si KO, >0 si OK */ function delete($rowid) { @@ -483,41 +462,30 @@ class Adherent $result = 0; $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_options WHERE adhid = ".$rowid; - if ( $this->db->query( $sql) ) + if ( $this->db->query($sql) ) { if ( $this->db->affected_rows() ) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."cotisation WHERE fk_adherent = ".$rowid; - if ( $this->db->query( $sql) ) + if ($this->db->query( $sql)) { - if ( $this->db->affected_rows() ) - { - $result = 1; - } + } $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent WHERE rowid = ".$rowid; dolibarr_syslog("Adherent.class::delete"); - if ( $this->db->query( $sql) ) + if ( $this->db->query($sql) ) { if ( $this->db->affected_rows() ) { - $result = 1; - - // \todo Mettre en trigger - if ($conf->ldap->enabled && $conf->global->LDAP_MEMBER_ACTIVE) - { - $ldap=new Ldap(); - $ldap->connect_bind(); - - $info=$this->_load_ldap_info(); - $dn=$this->_load_ldap_dn($info); - - $ldap->delete($dn,$info,$user); - } - + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('CONTACT_DELETE',$this,$user,$langs,$conf); + if ($result < 0) $error++; + // Fin appel triggers } } } @@ -525,6 +493,7 @@ class Adherent else { dolibarr_print_error($this->db); + return -1; } return $result; @@ -817,6 +786,7 @@ class Adherent include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); $interface=new Interfaces($this->db); $result=$interface->run_triggers('MEMBER_VALIDATE',$this,$user,$langs,$conf); + if ($result < 0) $error++; // Fin appel triggers $this->db->commit(); diff --git a/htdocs/contact.class.php b/htdocs/contact.class.php index b4c20392dd7..7d2b428b8c2 100644 --- a/htdocs/contact.class.php +++ b/htdocs/contact.class.php @@ -102,7 +102,7 @@ class Contact { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."socpeople"); - $result=$this->update($this->id, $user, 0); + $result=$this->update($this->id, $user, 1); if ($result < 0) { $this->error=$this->db->error(); @@ -113,20 +113,9 @@ class Contact include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); $interface=new Interfaces($this->db); $result=$interface->run_triggers('CONTACT_CREATE',$this,$user,$langs,$conf); + if ($result < 0) $error++; // Fin appel triggers - // \todo Mettre en trigger - if ($conf->ldap->enabled && $conf->global->LDAP_CONTACT_ACTIVE) - { - $ldap=new Ldap(); - $ldap->connect_bind(); - - $info=$this->_load_ldap_info(); - $dn=$this->_load_ldap_dn($info); - - $ldap->add($dn,$info,$user); - } - return $this->id; } else @@ -141,10 +130,10 @@ class Contact * \brief Mise à jour des infos * \param id Id du contact à mettre à jour * \param user Objet utilisateur qui effectue la mise à jour - * \param call_trigger 0=non, 1=oui + * \param notrigger 0=non, 1=oui * \return int <0 si erreur, >0 si ok */ - function update($id, $user=0, $call_trigger=1) + function update($id, $user=0, $notrigger=0) { global $conf, $langs; @@ -194,28 +183,15 @@ class Contact return -1; } - if ($call_trigger) + if (! $notrigger) { // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); $interface=new Interfaces($this->db); - $result=$interface->run_triggers('CONTACT_UPDATE',$this,$user,$langs,$conf); + $result=$interface->run_triggers('CONTACT_MODIFY',$this,$user,$langs,$conf); + if ($result < 0) $error++; // Fin appel triggers - - - // \todo Mettre en trigger - if ($conf->ldap->enabled && $conf->global->LDAP_CONTACT_ACTIVE) - { - $ldap=new Ldap(); - $ldap->connect_bind(); - - $info=$this->_load_ldap_info(); - $dn=$this->_load_ldap_dn($info); - - $ldap->update($dn,$info,$user); - } } - return 1; } @@ -571,25 +547,13 @@ class Contact return -1; } - // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); $interface=new Interfaces($this->db); $result=$interface->run_triggers('CONTACT_DELETE',$this,$user,$langs,$conf); + if ($result < 0) $error++; // Fin appel triggers - // \todo Mettre en trigger - if ($conf->ldap->enabled && $conf->global->LDAP_CONTACT_ACTIVE) - { - $ldap=new Ldap(); - $ldap->connect_bind(); - - $info=$this->_load_ldap_info(); - $dn=$this->_load_ldap_dn($info); - - $ldap->delete($dn,$info,$user); - } - return 1; } diff --git a/htdocs/fichinter/index.php b/htdocs/fichinter/index.php index b15ffc167ff..1c92d72895e 100644 --- a/htdocs/fichinter/index.php +++ b/htdocs/fichinter/index.php @@ -54,6 +54,13 @@ $offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; +// Securité accès client +if ($user->societe_id > 0) +{ + $action = ''; + $socid = $user->societe_id; +} + llxHeader(); diff --git a/htdocs/includes/menus/barre_left/eldy_backoffice.php b/htdocs/includes/menus/barre_left/eldy_backoffice.php index 440b64b88b8..43b1664132c 100644 --- a/htdocs/includes/menus/barre_left/eldy_backoffice.php +++ b/htdocs/includes/menus/barre_left/eldy_backoffice.php @@ -20,7 +20,7 @@ */ /** - \file htdocs/includes/menus/barre_left/eldy.php + \file htdocs/includes/menus/barre_left/eldy_backoffice.php \brief Gestionnaire du menu du gauche Eldy \version $Revision$ diff --git a/htdocs/includes/menus/barre_left/eldy_frontoffice.php b/htdocs/includes/menus/barre_left/eldy_frontoffice.php index 6d7456ae5ab..603e721855c 100644 --- a/htdocs/includes/menus/barre_left/eldy_frontoffice.php +++ b/htdocs/includes/menus/barre_left/eldy_frontoffice.php @@ -20,7 +20,7 @@ */ /** - \file htdocs/includes/menus/barre_left/eldy.php + \file htdocs/includes/menus/barre_left/eldy_frontoffice.php \brief Gestionnaire du menu du gauche Eldy \version $Revision$ diff --git a/htdocs/includes/menus/barre_top/eldy_backoffice.php b/htdocs/includes/menus/barre_top/eldy_backoffice.php index b6038e4bac4..a5cf184ab72 100644 --- a/htdocs/includes/menus/barre_top/eldy_backoffice.php +++ b/htdocs/includes/menus/barre_top/eldy_backoffice.php @@ -20,7 +20,7 @@ */ /** - \file htdocs/includes/menus/barre_top/eldy.php + \file htdocs/includes/menus/barre_top/eldy_backoffice.php \brief Gestionnaire nommé eldy du menu du haut \version $Revision$ diff --git a/htdocs/includes/menus/barre_top/eldy_frontoffice.php b/htdocs/includes/menus/barre_top/eldy_frontoffice.php index bdcd4633546..4e59b909f45 100644 --- a/htdocs/includes/menus/barre_top/eldy_frontoffice.php +++ b/htdocs/includes/menus/barre_top/eldy_frontoffice.php @@ -20,7 +20,7 @@ */ /** - \file htdocs/includes/menus/barre_top/eldy.php + \file htdocs/includes/menus/barre_top/eldy_frontoffice.php \brief Gestionnaire nommé eldy du menu du haut \version $Revision$ diff --git a/htdocs/includes/triggers/interface_ldap.class.php b/htdocs/includes/triggers/interface_ldap.class.php index 0624c78ae9c..f6f4779ceef 100644 --- a/htdocs/includes/triggers/interface_ldap.class.php +++ b/htdocs/includes/triggers/interface_ldap.class.php @@ -102,7 +102,7 @@ class InterfaceLdap if (! $conf->ldap->enabled) return 0; // Module non actif // Users - if ($action == 'USER_CREATE') + if ($action == 'USER_CREATE') { dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE) @@ -153,24 +153,104 @@ class InterfaceLdap } } + // Groupes + elseif ($action == 'GROUP_CREATE') + { + if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE) + { + $ldap=new Ldap(); + $ldap->connect_bind(); + + $info=$object->_load_ldap_info(); + $dn=$object->_load_ldap_dn($info); + + $ldap->add($dn,$info,$user); + } + } + elseif ($action == 'GROUP_MODIFY') + { + if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE) + { + $ldap=new Ldap(); + $ldap->connect_bind(); + + $info=$object->_load_ldap_info(); + $dn=$object->_load_ldap_dn($info); + + $ldap->update($dn,$info,$user); + } + } + elseif ($action == 'GROUP_DELETE') + { + if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE) + { + $ldap=new Ldap(); + $ldap->connect_bind(); + + $info=$object->_load_ldap_info(); + $dn=$object->_load_ldap_dn($info); + + $ldap->delete($dn,$info,$user); + } + } + // Contacts elseif ($action == 'CONTACT_CREATE') { dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + if ($conf->ldap->enabled && $conf->global->LDAP_CONTACT_ACTIVE) + { + $ldap=new Ldap(); + $ldap->connect_bind(); + + $info=$object->_load_ldap_info(); + $dn=$object->_load_ldap_dn($info); + + $ldap->add($dn,$info,$user); + } } elseif ($action == 'CONTACT_MODIFY') { dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + if ($conf->ldap->enabled && $conf->global->LDAP_CONTACT_ACTIVE) + { + $ldap=new Ldap(); + $ldap->connect_bind(); + + $info=$object->_load_ldap_info(); + $dn=$object->_load_ldap_dn($info); + + $ldap->update($dn,$info,$user); + } } elseif ($action == 'CONTACT_DELETE') { dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + if ($conf->ldap->enabled && $conf->global->LDAP_CONTACT_ACTIVE) + { + $ldap=new Ldap(); + $ldap->connect_bind(); + + $info=$object->_load_ldap_info(); + $dn=$object->_load_ldap_dn($info); + + $ldap->delete($dn,$info,$user); + } } // Members elseif ($action == 'MEMBER_CREATE') { dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + if ($conf->ldap->enabled && $conf->global->LDAP_MEMBER_ACTIVE) + { + $ldap=new Ldap(); + $ldap->connect_bind(); + $info=$object->_load_ldap_info(); + $dn=$object->_load_ldap_dn($info); + + $ldap->add($dn,$info,$user); + } } elseif ($action == 'MEMBER_VALIDATE') { @@ -183,6 +263,16 @@ class InterfaceLdap elseif ($action == 'MEMBER_MODIFY') { dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + if ($conf->ldap->enabled && $conf->global->LDAP_MEMBER_ACTIVE) + { + $ldap=new Ldap(); + $ldap->connect_bind(); + + $info=$object->_load_ldap_info(); + $dn=$object->_load_ldap_dn($info); + + $ldap->update($dn,$info,$user); + } } elseif ($action == 'MEMBER_RESILIATE') { @@ -191,6 +281,16 @@ class InterfaceLdap elseif ($action == 'MEMBER_DELETE') { dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + if ($conf->ldap->enabled && $conf->global->LDAP_MEMBER_ACTIVE) + { + $ldap=new Ldap(); + $ldap->connect_bind(); + + $info=$object->_load_ldap_info(); + $dn=$object->_load_ldap_dn($info); + + $ldap->delete($dn,$info,$user); + } } // If not found diff --git a/htdocs/user.class.php b/htdocs/user.class.php index 78d8668571d..9c6baea3542 100644 --- a/htdocs/user.class.php +++ b/htdocs/user.class.php @@ -795,10 +795,10 @@ class User /** * \brief Mise à jour en base d'un utilisateur - * \param create 1 si update durant le create, 0 sinon - * \return int <0 si echec, >=0 si ok + * \param notrigger 1 si update durant le create, 0 sinon + * \return int <0 si KO, >=0 si OK */ - function update($create=0) + function update($notrigger=0) { global $conf,$langs; @@ -821,7 +821,7 @@ class User $this->admin=$this->admin?$this->admin:0; if (!strlen($this->code)) $this->code = $this->login; - dolibarr_syslog("User::update nom=".$this->nom.", prenom=".$this->prenom); + dolibarr_syslog("User::update notrigger=".$notrigger." nom=".$this->nom.", prenom=".$this->prenom); $error=0; $sql = "UPDATE ".MAIN_DB_PREFIX."user SET "; @@ -844,7 +844,7 @@ class User { if ($this->db->affected_rows($resql)) { - if (! $create) + if (! $notrigger) { // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); diff --git a/htdocs/usergroup.class.php b/htdocs/usergroup.class.php index fee52c51c7e..94566a18b28 100644 --- a/htdocs/usergroup.class.php +++ b/htdocs/usergroup.class.php @@ -369,18 +369,6 @@ class UserGroup if ($result < 0) $error++; // Fin appel triggers - // \todo Mettre en trigger - if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE) - { - $ldap=new Ldap(); - $ldap->connect_bind(); - - $info=$this->_load_ldap_info(); - $dn=$this->_load_ldap_dn($info); - - $ldap->delete($dn,$info,$user); - } - $this->db->commit(); return 1; } @@ -418,18 +406,6 @@ class UserGroup if ($result < 0) $error++; // Fin appel triggers - // \todo Mettre en trigger - if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE) - { - $ldap=new Ldap(); - $ldap->connect_bind(); - - $info=$this->_load_ldap_info(); - $dn=$this->_load_ldap_dn($info); - - $ldap->add($dn,$info,$user); - } - return $this->id; } else @@ -441,8 +417,9 @@ class UserGroup /** - * \brief Mise à jour en base d'un utilisateur - * \return <0 si echec, >=0 si ok + * \brief Mise à jour en base d'un utilisateur + * \param notrigger 0=non, 1=oui + * \return int <0 si KO, >=0 si OK */ function update($notrigger=0) { @@ -468,19 +445,6 @@ class UserGroup $result=$interface->run_triggers('GROUP_MODIFY',$this,$user,$lang,$conf); if ($result < 0) $error++; // Fin appel triggers - - - // \todo Mettre en trigger - if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE) - { - $ldap=new Ldap(); - $ldap->connect_bind(); - - $info=$this->_load_ldap_info(); - $dn=$this->_load_ldap_dn($info); - - $ldap->update($dn,$info,$user); - } } return 1; diff --git a/scripts/company/sync_contacts_dolibarr2ldap.php b/scripts/company/sync_contacts_dolibarr2ldap.php index 974df06012d..854d1a6caab 100644 --- a/scripts/company/sync_contacts_dolibarr2ldap.php +++ b/scripts/company/sync_contacts_dolibarr2ldap.php @@ -82,7 +82,13 @@ if ($resql) print $langs->trans("UpdateContact")." rowid=".$contact->id." ".$contact->fullname; - $result=$contact->update_ldap($user); + $ldap=new Ldap(); + $ldap->connect_bind(); + + $info=$contact->_load_ldap_info(); + $dn=$contact->_load_ldap_dn($info); + + $result=$ldap->update($dn,$info,$user); if ($result > 0) { print " - ".$langs->trans("OK"); @@ -90,7 +96,7 @@ if ($resql) else { $error++; - print " - ".$langs->trans("KO").' - '.$contact->error; + print " - ".$langs->trans("KO").' - '.$ldap->error; } print "\n"; diff --git a/scripts/user/sync_group_dolibarr2ldap.php b/scripts/user/sync_group_dolibarr2ldap.php index a6f277d388b..9d9af14b52c 100644 --- a/scripts/user/sync_group_dolibarr2ldap.php +++ b/scripts/user/sync_group_dolibarr2ldap.php @@ -82,7 +82,13 @@ if ($resql) print $langs->trans("UpdateGroup")." rowid=".$fgroup->id." ".$fgroup->nom; - $result=$fgroup->update_ldap($user); + $ldap=new Ldap(); + $ldap->connect_bind(); + + $info=$fgroup->_load_ldap_info(); + $dn=$fgroup->_load_ldap_dn($info); + + $result=$ldap->update($dn,$info,$user); if ($result > 0) { print " - ".$langs->trans("OK"); diff --git a/scripts/user/sync_user_dolibarr2ldap.php b/scripts/user/sync_user_dolibarr2ldap.php index b1a855fb208..58d97f8dcc4 100644 --- a/scripts/user/sync_user_dolibarr2ldap.php +++ b/scripts/user/sync_user_dolibarr2ldap.php @@ -82,7 +82,13 @@ if ($resql) print $langs->trans("UpdateUser")." rowid=".$fuser->id." ".$fuser->fullname; - $result=$fuser->update_ldap($user); + $ldap=new Ldap(); + $ldap->connect_bind(); + + $info=$fuser->_load_ldap_info(); + $dn=$fuser->_load_ldap_dn($info); + + $result=$ldap->update($dn,$info,$user); if ($result > 0) { print " - ".$langs->trans("OK");