From a28ff7bfe1f5198c2c468d75aa8a384a3007162c Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Wed, 5 May 2004 12:28:33 +0000 Subject: [PATCH] =?UTF-8?q?Modif=20de=20la=20mise=20=E0=20jour=20de=20ldap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/contact.class.php | 169 +++++++++++++++++++++------------------ 1 file changed, 90 insertions(+), 79 deletions(-) diff --git a/htdocs/contact.class.php b/htdocs/contact.class.php index ec19e0868ff..fd4101c4376 100644 --- a/htdocs/contact.class.php +++ b/htdocs/contact.class.php @@ -103,88 +103,99 @@ class Contact if (defined('MAIN_MODULE_LDAP') && MAIN_MODULE_LDAP) { - $ds = dolibarr_ldap_connect(); - - if ($ds) - { - ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); - - $ldapbind = dolibarr_ldap_bind($ds); - - if ($ldapbind) - { - $info["cn"] = utf8_encode($this->firstname." ".$this->name); - $info["sn"] = utf8_encode($this->name); - - if ($this->email) - $info["rfc822Mailbox"] = $this->email; - - if ($this->phone_pro) - $info["telephoneNumber"] = dolibarr_print_phone($this->phone_pro); - - if ($this->phone_mobile) - $info["mobile"] = dolibarr_print_phone($this->phone_mobile); - - if ($this->phone_perso) - $info["homePhone"] = dolibarr_print_phone($this->phone_perso); - - if ($this->poste) - $info["title"] = utf8_encode($this->poste); - - if ($this->socid > 0) - { - $soc = new Societe($this->db); - $soc->fetch($this->socid); - $info["o"] = utf8_encode($soc->nom); - if ($soc->ville) - { - $info["l"] = utf8_encode($soc->ville); - } - } - - $info["objectclass"][0] = "organizationalPerson"; - $info["objectclass"][1] = "inetOrgPerson"; - $info["objectclass"][2] = "phpgwContact"; // compatibilite egroupware - - $info['uidnumber'] = $id; - - $info['phpgwTz'] = 0; - $info['phpgwMailType'] = 'INTERNET'; - $info['phpgwMailHomeType'] = 'INTERNET'; - - $info["uid"] = $id. ":".$info["sn"]; - $info["phpgwContactTypeId"] = 'n'; - $info["phpgwContactCatId"] = 0; - $info["phpgwContactAccess"] = "public"; - $info["phpgwContactOwner"] = $user->egroupware_id; - $info["givenName"] = $info["sn"]; - - if ($this->phone_mobile) - $info["phpgwCellTelephoneNumber"] = dolibarr_print_phone($this->phone_mobile); - - //$dn = "uid=".$info["uid"].","."cn=".$info["cn"].", ".LDAP_SERVER_DN ; - $dn = "cn=".$info["cn"].", ".LDAP_SERVER_DN ; - - $r = @ldap_delete($ds, $dn); - - if (! ldap_add($ds, $dn, $info)) - { - $this->error[0] = ldap_err2str(ldap_errno($ds)); - } - } - else - { - echo "LDAP bind failed..."; - } - ldap_close($ds); - } - else - { - echo "Unable to connect to LDAP server"; - } + update_ldap($user); } return $result; } + /* + * + * + */ + Function update_ldap($user) + { + $this->fetch($this->id); + + $ds = dolibarr_ldap_connect(); + + if ($ds) + { + ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); + + $ldapbind = dolibarr_ldap_bind($ds); + + if ($ldapbind) + { + $info["cn"] = utf8_encode($this->firstname." ".$this->name); + $info["sn"] = utf8_encode($this->name); + + if ($this->email) + $info["rfc822Mailbox"] = $this->email; + + if ($this->phone_pro) + $info["telephoneNumber"] = dolibarr_print_phone($this->phone_pro); + + if ($this->phone_mobile) + $info["mobile"] = dolibarr_print_phone($this->phone_mobile); + + if ($this->phone_perso) + $info["homePhone"] = dolibarr_print_phone($this->phone_perso); + + if ($this->poste) + $info["title"] = utf8_encode($this->poste); + + if ($this->socid > 0) + { + $soc = new Societe($this->db); + $soc->fetch($this->socid); + $info["o"] = utf8_encode($soc->nom); + if ($soc->ville) + { + $info["l"] = utf8_encode($soc->ville); + } + } + + $info["objectclass"][0] = "organizationalPerson"; + $info["objectclass"][1] = "inetOrgPerson"; + $info["objectclass"][2] = "phpgwContact"; // compatibilite egroupware + + $info['uidnumber'] = $id; + + $info['phpgwTz'] = 0; + $info['phpgwMailType'] = 'INTERNET'; + $info['phpgwMailHomeType'] = 'INTERNET'; + + $info["uid"] = $id. ":".$info["sn"]; + $info["phpgwContactTypeId"] = 'n'; + $info["phpgwContactCatId"] = 0; + $info["phpgwContactAccess"] = "public"; + $info["phpgwContactOwner"] = $user->egroupware_id; + $info["givenName"] = utf8_encode($this->firstname); + + if ($this->phone_mobile) + $info["phpgwCellTelephoneNumber"] = dolibarr_print_phone($this->phone_mobile); + + //$dn = "uid=".$info["uid"].","."cn=".$info["cn"].", ".LDAP_SERVER_DN ; + $dn = "cn=".$info["cn"].", ".LDAP_SERVER_DN ; + + $r = @ldap_delete($ds, $dn); + + if (! ldap_add($ds, $dn, $info)) + { + $this->error[0] = ldap_err2str(ldap_errno($ds)); + } + } + else + { + echo "LDAP bind failed..."; + } + ldap_close($ds); + } + else + { + echo "Unable to connect to LDAP server"; + } + } + /* * Mise à jour des infos persos