Fix: Toutes les synchro Dolibarr vers LDAP sont dans le trigger LDAP.

This commit is contained in:
Laurent Destailleur 2006-11-23 23:47:54 +00:00
parent 9618978029
commit c161905bcd
13 changed files with 172 additions and 149 deletions

View File

@ -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();

View File

@ -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;
}

View File

@ -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();

View File

@ -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$

View File

@ -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$

View File

@ -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$

View File

@ -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$

View File

@ -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

View File

@ -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");

View File

@ -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;

View File

@ -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";

View File

@ -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");

View File

@ -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");