Mise en facteur de nombreux code et uniformisation codage sur le LDAP
This commit is contained in:
parent
e69b80ac52
commit
7338936d4d
@ -28,15 +28,6 @@
|
||||
\ingroup ldap
|
||||
\brief Page d'administration/configuration du module Ldap
|
||||
\version $Revision$
|
||||
\remarks Exemple configuration :
|
||||
LDAP_SERVER_HOST Serveur LDAP 192.168.1.50
|
||||
LDAP_SERVER_PORT Port LDAP 389
|
||||
LDAP_ADMIN_DN Administrateur LDAP cn=adminldap,dc=societe,dc=com
|
||||
LDAP_ADMIN_PASS Mot de passe xxxxxxxx
|
||||
LDAP_USER_DN DN des utilisateurs ou=users,dc=societe,dc=com
|
||||
LDAP_GROUP_DN DN des groupes ou=groups,dc=societe,dc=com
|
||||
LDAP_CONTACT_DN DN des contacts ou=contacts,dc=societe,dc=com
|
||||
LDAP_SERVER_TYPE Type Openldap
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
@ -251,8 +242,8 @@ print '</td><td>'.$langs->trans("LDAPServerUseTLSExample").'</td></tr>';
|
||||
|
||||
|
||||
|
||||
|
||||
print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
|
||||
print '</table>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
@ -28,19 +28,11 @@
|
||||
\ingroup ldap
|
||||
\brief Page d'administration/configuration du module Ldap
|
||||
\version $Revision$
|
||||
\remarks Exemple configuration :
|
||||
LDAP_SERVER_HOST Serveur LDAP 192.168.1.50
|
||||
LDAP_SERVER_PORT Port LDAP 389
|
||||
LDAP_ADMIN_DN Administrateur LDAP cn=adminldap,dc=societe,dc=com
|
||||
LDAP_ADMIN_PASS Mot de passe xxxxxxxx
|
||||
LDAP_USER_DN DN des utilisateurs ou=users,dc=societe,dc=com
|
||||
LDAP_GROUP_DN DN des groupes ou=groups,dc=societe,dc=com
|
||||
LDAP_CONTACT_DN DN des contacts ou=contacts,dc=societe,dc=com
|
||||
LDAP_SERVER_TYPE Type Openldap
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/authldap.lib.php");
|
||||
require_once (DOL_DOCUMENT_ROOT."/contact.class.php");
|
||||
|
||||
$langs->load("admin");
|
||||
|
||||
@ -137,13 +129,13 @@ $html=new Form($db);
|
||||
|
||||
// DN Pour les contacts
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPContactDn").'</td><td>';
|
||||
print '<tr '.$bc[$var].'><td><b>'.$langs->trans("LDAPContactDn").picto_required().'</b></td><td>';
|
||||
print '<input size="38" type="text" name="contactdn" value="'.$conf->global->LDAP_CONTACT_DN.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPContactDnExample").'</td></tr>';
|
||||
|
||||
// Name
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldName").'</td><td>';
|
||||
print '<tr '.$bc[$var].'><td><b>'.$langs->trans("LDAPFieldName").picto_required().'</b></td><td>';
|
||||
print '<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_FIELD_NAME.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td></tr>';
|
||||
|
||||
@ -179,7 +171,8 @@ print '<input size="25" type="text" name="fieldmobile" value="'.$conf->global->L
|
||||
print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td></tr>';
|
||||
|
||||
|
||||
print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
|
||||
print '</table>';
|
||||
|
||||
print '</form>';
|
||||
@ -188,6 +181,44 @@ print '</div>';
|
||||
|
||||
print info_admin($langs->trans("LDAPDescValues"));
|
||||
|
||||
/*
|
||||
* Test de la connexion
|
||||
*/
|
||||
if (function_exists("ldap_connect"))
|
||||
{
|
||||
if ($conf->global->LDAP_SERVER_HOST)
|
||||
{
|
||||
print '<br>';
|
||||
print '<a class="tabAction" href="'.$_SERVER["PHP_SELF"].'?action=test">'.$langs->trans("LDAPTestSynchroContact").'</a><br><br>';
|
||||
}
|
||||
|
||||
if ($_GET["action"] == 'test')
|
||||
{
|
||||
// Creation contact
|
||||
$contact=new Contact($db);
|
||||
$contact->initAsSpecimen();
|
||||
|
||||
// Test synchro
|
||||
$result1=$contact->delete_ldap($user);
|
||||
$result2=$contact->update_ldap($user);
|
||||
$result3=$contact->delete_ldap($user);
|
||||
|
||||
if ($result2 > 0)
|
||||
{
|
||||
print img_picto('','info').' ';
|
||||
print '<font class="ok">'.$langs->trans("LDAPSynchroOK").'</font><br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print img_picto('','error').' ';
|
||||
print '<font class="warning">'.$langs->trans("LDAPSynchroKO");
|
||||
print ': '.$contact->error;
|
||||
print '</font><br>';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
|
||||
@ -28,15 +28,6 @@
|
||||
\ingroup ldap
|
||||
\brief Page d'administration/configuration du module Ldap
|
||||
\version $Revision$
|
||||
\remarks Exemple configuration :
|
||||
LDAP_SERVER_HOST Serveur LDAP 192.168.1.50
|
||||
LDAP_SERVER_PORT Port LDAP 389
|
||||
LDAP_ADMIN_DN Administrateur LDAP cn=adminldap,dc=societe,dc=com
|
||||
LDAP_ADMIN_PASS Mot de passe xxxxxxxx
|
||||
LDAP_USER_DN DN des utilisateurs ou=users,dc=societe,dc=com
|
||||
LDAP_GROUP_DN DN des groupes ou=groups,dc=societe,dc=com
|
||||
LDAP_CONTACT_DN DN des contacts ou=contacts,dc=societe,dc=com
|
||||
LDAP_SERVER_TYPE Type Openldap
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
@ -141,19 +132,19 @@ print "</tr>\n";
|
||||
|
||||
// DN Pour les utilisateurs
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPUserDn").'</td><td>';
|
||||
print '<tr '.$bc[$var].'><td><b>'.$langs->trans("LDAPUserDn").picto_required().'</b></td><td>';
|
||||
print '<input size="38" type="text" name="user" value="'.$conf->global->LDAP_USER_DN.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPUserDnExample").'</td></tr>';
|
||||
|
||||
// DN pour les groupes
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPGroupDn").'</td><td>';
|
||||
print '<tr '.$bc[$var].'><td><b>'.$langs->trans("LDAPGroupDn").picto_required().'</b></td><td>';
|
||||
print '<input size="38" type="text" name="group" value="'.$conf->global->LDAP_GROUP_DN.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPGroupDnExample").'</td></tr>';
|
||||
|
||||
// Filtre de connexion
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFilterConnection").'</td><td>';
|
||||
print '<tr '.$bc[$var].'><td><b>'.$langs->trans("LDAPFilterConnection").picto_required().'</b></td><td>';
|
||||
print '<input size="38" type="text" name="filterconnection" value="'.$conf->global->LDAP_FILTER_CONNECTION.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPFilterConnectionExample").'</td></tr>';
|
||||
|
||||
@ -171,7 +162,7 @@ print '</td><td>'.$langs->trans("LDAPFieldLoginSambaExample").'</td></tr>';
|
||||
|
||||
// Name
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldName").'</td><td>';
|
||||
print '<tr '.$bc[$var].'><td><b>'.$langs->trans("LDAPFieldName").picto_required().'</b></td><td>';
|
||||
print '<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_FIELD_NAME.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td></tr>';
|
||||
|
||||
@ -205,8 +196,8 @@ print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldMobile").'</td><td>';
|
||||
print '<input size="25" type="text" name="fieldmobile" value="'.$conf->global->LDAP_FIELD_MOBILE.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td></tr>';
|
||||
|
||||
|
||||
print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
|
||||
print '</table>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
@ -53,6 +53,7 @@ class Contact
|
||||
var $cp;
|
||||
var $ville;
|
||||
var $fk_pays;
|
||||
var $fk_soc;
|
||||
|
||||
var $code;
|
||||
var $email;
|
||||
@ -83,49 +84,60 @@ class Contact
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
// Nettoyage parametres
|
||||
$this->name=trim($this->name);
|
||||
if (! $this->socid)
|
||||
{
|
||||
$this->socid = 0;
|
||||
}
|
||||
if (! $this->socid)$this->socid = 0;
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."socpeople (datec, fk_soc, name, fk_user)";
|
||||
$sql.= " VALUES (now(),";
|
||||
if ($this->socid > 0) $sql.= " $this->socid,";
|
||||
else $sql.= "null,";
|
||||
$sql.= "'$this->name',$user->id)";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
dolibarr_syslog("Contact.class::create sql=".$sql);
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."socpeople");
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."socpeople");
|
||||
|
||||
$ret=$this->update($id, $user);
|
||||
if ($ret < 0)
|
||||
$result=$this->update($this->id, $user, 0);
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
return -2;
|
||||
}
|
||||
return $id;
|
||||
}
|
||||
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||
$interface=new Interfaces($this->db);
|
||||
$result=$interface->run_triggers('CONTACT_CREATE',$this,$user,$langs,$conf);
|
||||
// Fin appel triggers
|
||||
|
||||
// \todo Mettre en trigger
|
||||
$this->create_ldap($user);
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
dolibarr_syslog("Contact.class::create ".$this->error);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Mise à jour des infos
|
||||
* \param id id du contact à mettre à jour
|
||||
* \param user Utilisateur qui effectue la mise à jour
|
||||
* \return int <0 si erreur, >0 si ok
|
||||
* \param id Id du contact à mettre à jour
|
||||
* \param user Objet utilisateur qui effectue la mise à jour
|
||||
* \param call_trigger 0=non, 1=oui
|
||||
* \return int <0 si erreur, >0 si ok
|
||||
*/
|
||||
function update($id, $user=0)
|
||||
function update($id, $user=0, $call_trigger=1)
|
||||
{
|
||||
dolibarr_syslog("Contact::Update id=".$id,LOG_DEBUG);
|
||||
|
||||
$this->id = $id;
|
||||
|
||||
// Nettoyage parametres
|
||||
$this->name=trim($this->name);
|
||||
$this->firstname=trim($this->firstname);
|
||||
$this->email=trim($this->email);
|
||||
@ -158,6 +170,7 @@ class Contact
|
||||
$sql .= ", jabberid = '".addslashes($this->jabberid)."'";
|
||||
if ($user) $sql .= ", fk_user_modif=".$user->id;
|
||||
$sql .= " WHERE idp=".$id;
|
||||
dolibarr_syslog("Contact.class::update sql=".$sql,LOG_DEBUG);
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if (! $result)
|
||||
@ -165,32 +178,99 @@ class Contact
|
||||
$this->error=$this->db->error().' sql='.$sql;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ($conf->ldap->enabled)
|
||||
{
|
||||
if ($conf->global->LDAP_CONTACT_ACTIVE)
|
||||
{
|
||||
$this->update_ldap($user);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($call_trigger)
|
||||
{
|
||||
// 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);
|
||||
// Fin appel triggers
|
||||
|
||||
// \todo Mettre en trigger
|
||||
$this->update_ldap($user);
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Mise à jour de l'arbre LDAP
|
||||
* \brief Mise à jour de l'arbre LDAP
|
||||
* \param user Utilisateur qui efface
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function delete_ldap($user)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
if (! $conf->ldap->enabled || ! $conf->global->LDAP_CONTACT_ACTIVE) return 0;
|
||||
|
||||
dolibarr_syslog("Contact.class::delete_ldap this->id=".$this->id,LOG_DEBUG);
|
||||
|
||||
$ldap=new AuthLdap();
|
||||
$result=$ldap->connect();
|
||||
if ($result)
|
||||
{
|
||||
$bind='';
|
||||
if ($conf->global->LDAP_ADMIN_DN && $conf->global->LDAP_ADMIN_PASS)
|
||||
{
|
||||
dolibarr_syslog("Contact.class::delete_ldap authBind user=".$conf->global->LDAP_ADMIN_DN,LOG_DEBUG);
|
||||
$bind=$ldap->authBind($conf->global->LDAP_ADMIN_DN,$conf->global->LDAP_ADMIN_PASS);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Contact.class::delete_ldap bind",LOG_DEBUG);
|
||||
$bind=$ldap->bind();
|
||||
}
|
||||
|
||||
if ($bind)
|
||||
{
|
||||
$info["cn"] = utf8_encode(trim($this->firstname." ".$this->name));
|
||||
$dn = "cn=".$info["cn"].",".$conf->global->LDAP_CONTACT_DN;
|
||||
|
||||
$result=$ldap->delete($dn);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error="Failed to connect to LDAP server !";
|
||||
dolibarr_syslog("Contact.class::update_ldap Connexion failed",LOG_DEBUG);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Creation d'un contact dans l'arbre LDAP
|
||||
* \param user Utilisateur qui effectue la creation
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function create_ldap($user)
|
||||
{
|
||||
dolibarr_syslog("Contact.class::create_ldap this->id=".$this->id,LOG_DEBUG);
|
||||
return $this->update_ldap($user);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Mise à jour du contact dans l'arbre LDAP
|
||||
* \param user Utilisateur qui effectue la mise à jour
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function update_ldap($user)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
if (! $conf->ldap->enabled || ! $conf->global->LDAP_CONTACT_ACTIVE) return 0;
|
||||
|
||||
$info = array();
|
||||
|
||||
dolibarr_syslog("Contact.class::update_ldap",LOG_DEBUG);
|
||||
dolibarr_syslog("Contact.class::update_ldap this->id=".$this->id,LOG_DEBUG);
|
||||
|
||||
$this->fetch($this->id);
|
||||
|
||||
$ldap=new AuthLdap();
|
||||
$result=$ldap->connect();
|
||||
if ($result)
|
||||
@ -211,19 +291,24 @@ class Contact
|
||||
if ($conf->global->LDAP_SERVER_TYPE == 'activedirectory')
|
||||
{
|
||||
// Pas de conversion utf8 pour etre compatible Windows
|
||||
|
||||
$info["objectclass"][0] = "top";
|
||||
$info["objectclass"][1] = "person";
|
||||
$info["objectclass"][2] = "organizationalPerson";
|
||||
//$info["objectclass"][3] = "inetOrgPerson";
|
||||
$info["objectclass"][3] = "user";
|
||||
$info["objectclass"]=array("top",
|
||||
"person",
|
||||
"organizationalPerson",
|
||||
"user");
|
||||
|
||||
// Champs obligatoires
|
||||
$info["cn"] = trim($this->firstname." ".$this->name);
|
||||
$info["sn"] = $this->name;
|
||||
$info["givenName"] = $this->firstname;
|
||||
|
||||
if ($this->name) $info[$conf->global->LDAP_FIELD_NAME] = $this->name;
|
||||
else
|
||||
{
|
||||
$langs->load("other");
|
||||
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Name"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Champs optionnels
|
||||
if ($this->firstname && $conf->global->LDAP_FIELD_FIRSTNAME) $info[$conf->global->LDAP_FIELD_FIRSTNAME] = utf8_encode($this->firstname);
|
||||
if ($this->poste) $info["title"] = $this->poste;
|
||||
|
||||
if ($this->socid > 0)
|
||||
{
|
||||
$soc = new Societe($this->db);
|
||||
@ -259,45 +344,16 @@ class Contact
|
||||
$info["l"] = $soc->ville;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->phone_pro)
|
||||
$info["telephoneNumber"] = dolibarr_print_phone($this->phone_pro);
|
||||
|
||||
if ($this->phone_perso)
|
||||
$info["homePhone"] = dolibarr_print_phone($this->phone_perso);
|
||||
|
||||
if ($this->phone_mobile)
|
||||
$info["mobile"] = dolibarr_print_phone($this->phone_mobile);
|
||||
|
||||
if ($this->fax)
|
||||
$info["facsimileTelephoneNumber"] = dolibarr_print_phone($this->fax);
|
||||
|
||||
if ($this->note)
|
||||
$info["description"] = $this->note;
|
||||
|
||||
if ($this->email)
|
||||
$info["mail"] = $this->email;
|
||||
|
||||
$dn = "cn=".$info["cn"].",".$conf->global->LDAP_CONTACT_DN;
|
||||
|
||||
// On supprime et on insère
|
||||
dolibarr_syslog("Contact.class::update_ldap dn=".$dn." info=".$info);
|
||||
$r = @ldap_delete($ldap->connection, $dn);
|
||||
if (! @ldap_add($ldap->connection, $dn, $info))
|
||||
{
|
||||
$this->error = ldap_err2str(ldap_errno($ldap->connection));
|
||||
dolibarr_syslog("Contact.class::update_ldap ldap_add ".$this->error);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Contact.class::update_ldap rowid=".$this->rowid." added in LDAP");
|
||||
}
|
||||
if ($this->phone_pro && $conf->global->LDAP_FIELD_PHONE) $info[$conf->global->LDAP_FIELD_PHONE] = $this->phone_pro;
|
||||
if ($this->phone_perso) $info["homePhone"] = $this->phone_perso;
|
||||
if ($this->phone_mobile && $conf->global->LDAP_FIELD_MOBILE) $info[$conf->global->LDAP_FIELD_MOBILE] = $this->phone_mobile;
|
||||
if ($this->fax && $conf->global->LDAP_FIELD_FAX) $info[$conf->global->LDAP_FIELD_FAX] = $this->fax;
|
||||
if ($this->note) $info["description"] = $this->note;
|
||||
if ($this->email && $conf->global->LDAP_FIELD_MAIL) $info[$conf->global->LDAP_FIELD_MAIL] = $this->email;
|
||||
}
|
||||
else
|
||||
{
|
||||
// OpenLDAP. On encode les param en utf8
|
||||
|
||||
$info["objectclass"]=array("top",
|
||||
"person",
|
||||
"organizationalPerson",
|
||||
@ -314,10 +370,8 @@ class Contact
|
||||
}
|
||||
|
||||
// Champs optionnels
|
||||
if ($this->firstname) $info[$conf->global->LDAP_FIELD_FIRSTNAME] = utf8_encode($this->firstname);
|
||||
|
||||
if ($this->firstname && $conf->global->LDAP_FIELD_FIRSTNAME) $info[$conf->global->LDAP_FIELD_FIRSTNAME] = utf8_encode($this->firstname);
|
||||
if ($this->poste) $info["title"] = utf8_encode($this->poste);
|
||||
|
||||
if ($this->socid > 0)
|
||||
{
|
||||
$soc = new Societe($this->db);
|
||||
@ -332,18 +386,12 @@ class Contact
|
||||
if ($soc->cp) $info["postalCode"] = utf8_encode($soc->cp);
|
||||
if ($soc->ville) $info["l"] = utf8_encode($soc->ville);
|
||||
}
|
||||
|
||||
if ($this->phone_pro) $info[$conf->global->LDAP_FIELD_PHONE] = utf8_encode($this->phone_pro);
|
||||
|
||||
if ($this->phone_pro && $conf->global->LDAP_FIELD_PHONE) $info[$conf->global->LDAP_FIELD_PHONE] = utf8_encode($this->phone_pro);
|
||||
if ($this->phone_perso) $info["homePhone"] = utf8_encode($this->phone_perso);
|
||||
|
||||
if ($this->phone_mobile) $info[$conf->global->LDAP_FIELD_MOBILE] = utf8_encode($this->phone_mobile);
|
||||
|
||||
if ($this->fax) $info[$conf->global->LDAP_FIELD_FAX] = utf8_encode($this->fax);
|
||||
|
||||
if ($this->phone_mobile && $conf->global->LDAP_FIELD_MOBILE) $info[$conf->global->LDAP_FIELD_MOBILE] = utf8_encode($this->phone_mobile);
|
||||
if ($this->fax && $conf->global->LDAP_FIELD_FAX) $info[$conf->global->LDAP_FIELD_FAX] = utf8_encode($this->fax);
|
||||
if ($this->note) $info["description"] = utf8_encode($this->note);
|
||||
|
||||
if ($this->email) $info[$conf->global->LDAP_FIELD_MAIL] = utf8_encode($this->email);
|
||||
if ($this->email && $conf->global->LDAP_FIELD_MAIL) $info[$conf->global->LDAP_FIELD_MAIL] = utf8_encode($this->email);
|
||||
|
||||
if ($conf->global->LDAP_SERVER_TYPE == 'egroupware')
|
||||
{
|
||||
@ -374,23 +422,23 @@ class Contact
|
||||
|
||||
$info["uid"] = "Dolibarr ".$this->id. ": ".utf8_encode(trim($this->firstname." ".$this->name));
|
||||
|
||||
$dn = "cn=".$info["cn"].",".$conf->global->LDAP_CONTACT_DN;
|
||||
|
||||
// On supprime et on insère
|
||||
dolibarr_syslog("Contact.class::update_ldap dn=".$dn." info=".$info);
|
||||
$result = $ldap->delete($dn);
|
||||
$result = $ldap->add($dn, $info);
|
||||
if ($result <= 0)
|
||||
{
|
||||
$this->error = $ldap->error." ".ldap_errno($ldap->connection)." ".ldap_error($ldap->connection);
|
||||
dolibarr_syslog("Contact.class::update_ldap ".$this->error);
|
||||
print_r($info);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Contact.class::update_ldap rowid=".$this->rowid." added in LDAP");
|
||||
}
|
||||
}
|
||||
|
||||
// On supprime et on insère
|
||||
$dn = "cn=".$info["cn"].",".$conf->global->LDAP_CONTACT_DN;
|
||||
dolibarr_syslog("Contact.class::update_ldap dn=".$dn." info=".$info);
|
||||
$result = $ldap->delete($dn);
|
||||
$result = $ldap->add($dn, $info);
|
||||
if ($result <= 0)
|
||||
{
|
||||
$this->error = $ldap->error." ".ldap_errno($ldap->connection)." ".ldap_error($ldap->connection);
|
||||
dolibarr_syslog("Contact.class::update_ldap ".$this->error);
|
||||
//print_r($info);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Contact.class::update_ldap rowid=".$this->id." added in LDAP");
|
||||
}
|
||||
|
||||
$ldap->unbind();
|
||||
@ -407,7 +455,7 @@ class Contact
|
||||
else
|
||||
{
|
||||
$this->error="Failed to connect to LDAP server !";
|
||||
dolibarr_syslog("Contact::update_ldap Connexion failed",LOG_DEBUG);
|
||||
dolibarr_syslog("Contact.class::update_ldap Connexion failed",LOG_DEBUG);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -608,7 +656,7 @@ class Contact
|
||||
$sql.=" AND fk_socpeople = ". $this->id;
|
||||
$sql.=" GROUP BY tc.element";
|
||||
|
||||
dolibarr_syslog("Contact::load_ref_elements sql=".$sql);
|
||||
dolibarr_syslog("Contact.class::load_ref_elements sql=".$sql);
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
@ -629,7 +677,7 @@ class Contact
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error()." - ".$sql;
|
||||
dolibarr_syslog("Contact::load_ref_elements Error ".$this->error);
|
||||
dolibarr_syslog("Contact.class::load_ref_elements Error ".$this->error);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -660,50 +708,32 @@ class Contact
|
||||
$sql .= " WHERE idp=$id";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if (!$result)
|
||||
if (! $result)
|
||||
{
|
||||
print $this->db->error() . '<br>' . $sql;
|
||||
$this->error=$this->db->error().' sql='.$sql;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ($conf->ldap->enabled)
|
||||
{
|
||||
if (defined('LDAP_CONTACT_ACTIVE') && LDAP_CONTACT_ACTIVE == 1)
|
||||
{
|
||||
$ldap = New AuthLdap();
|
||||
|
||||
if ($ldap->connect())
|
||||
{
|
||||
if ($ldap->bind())
|
||||
{
|
||||
// delete from ldap directory
|
||||
if (LDAP_SERVER_TYPE == 'activedirectory')
|
||||
{
|
||||
$userdn = $this->old_firstname." ".$this->old_name; //enlever utf8 pour etre compatible Windows
|
||||
}
|
||||
else
|
||||
{
|
||||
$userdn = utf8_encode($this->old_firstname." ".$this->old_name);
|
||||
}
|
||||
|
||||
$dn = "cn=".$userdn.",".$conf->global->LDAP_CONTACT_DN;
|
||||
$r = @ldap_delete($ldap->connection, $dn);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "LDAP bind failed...";
|
||||
}
|
||||
|
||||
$ldap->close();
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Unable to connect to LDAP server";
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
// Fin appel triggers
|
||||
|
||||
|
||||
// \todo Mettre en trigger
|
||||
|
||||
// On modifie contact avec anciens noms
|
||||
$savname=$this->name;
|
||||
$savfirstname=$this->firstname;
|
||||
$this->name=$this->old_name;
|
||||
$this->firstname=$this->old_firstname;
|
||||
|
||||
$this->delete_ldap($user);
|
||||
|
||||
$this->name=$savname;
|
||||
$this->firstname=$savfirstname;
|
||||
}
|
||||
|
||||
|
||||
@ -805,5 +835,47 @@ class Contact
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialise le contact avec valeurs fictives aléatoire
|
||||
*/
|
||||
function initAsSpecimen()
|
||||
{
|
||||
global $user,$langs;
|
||||
|
||||
// Charge tableau des id de société socids
|
||||
$socids = array();
|
||||
$sql = "SELECT idp FROM ".MAIN_DB_PREFIX."societe LIMIT 10";
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num_socs = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num_socs)
|
||||
{
|
||||
$i++;
|
||||
|
||||
$row = $this->db->fetch_row($resql);
|
||||
$socids[$i] = $row[0];
|
||||
}
|
||||
}
|
||||
|
||||
// Initialise paramètres
|
||||
$this->id=0;
|
||||
$this->specimen=1;
|
||||
$this->fullname = 'DOLIBARR SPECIMEN';
|
||||
$this->nom = 'DOLIBARR';
|
||||
$this->name = $this->nom;
|
||||
$this->prenom = 'SPECIMEN';
|
||||
$this->firstname = $this->prenom;
|
||||
$this->address = '61 jump street';
|
||||
$this->cp = '75000';
|
||||
$this->ville = 'Paris';
|
||||
$this->fk_pays = 1;
|
||||
$this->email = 'specimen@specimen.com';
|
||||
$socid = rand(1, $num_socs);
|
||||
$this->fk_soc = $socids[$socid];
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/vcard/vcard.class.php");
|
||||
|
||||
@ -608,7 +609,7 @@ if ($_GET["id"] && $_GET["action"] != 'edit')
|
||||
|
||||
|
||||
// Historique des actions sur ce contact
|
||||
print_titre ($langs->trans("TasksHistoryForThisContact"));
|
||||
print_titre($langs->trans("TasksHistoryForThisContact"));
|
||||
$histo=array();
|
||||
$numaction = 0 ;
|
||||
|
||||
@ -680,11 +681,12 @@ if ($_GET["id"] && $_GET["action"] != 'edit')
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Date").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Status").'</td>';
|
||||
print '<td>'.$langs->trans("Actions").'</td>';
|
||||
print '<td>'.$langs->trans("Comments").'</td>';
|
||||
print '<td>'.$langs->trans("Author").'</td></tr>';
|
||||
|
||||
print '<td>'.$langs->trans("Author").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Status").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
foreach ($histo as $key=>$value)
|
||||
{
|
||||
$var=!$var;
|
||||
@ -693,14 +695,6 @@ if ($_GET["id"] && $_GET["action"] != 'edit')
|
||||
// Date
|
||||
print "<td>". dolibarr_print_date($histo[$key]['date'],"%d %b %Y %H:%M") ."</td>";
|
||||
|
||||
// Status/Percent
|
||||
if ($histo[$key]['percent'] < 100) {
|
||||
print "<td align=\"center\">".$histo[$key]['percent']."%</td>";
|
||||
}
|
||||
else {
|
||||
print "<td align=\"center\">".$langs->trans("Done")."</td>";
|
||||
}
|
||||
|
||||
// Action
|
||||
print '<td>';
|
||||
if ($histo[$key]['type']=='action')
|
||||
@ -732,6 +726,13 @@ if ($_GET["id"] && $_GET["action"] != 'edit')
|
||||
}
|
||||
else print " ";
|
||||
print "</td>";
|
||||
|
||||
// Status/Percent
|
||||
print '<td align="right">';
|
||||
$actionstatic=new ActionComm($db);
|
||||
print $actionstatic->LibStatut($histo[$key]['percent'],5);
|
||||
print '</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
}
|
||||
print "</table>";
|
||||
|
||||
@ -168,7 +168,7 @@ if ($socid > 0)
|
||||
|
||||
// Affiche formulaire upload
|
||||
$html=new Form($db);
|
||||
$html->form_attach_new_file('docsoc.php?socid='.$socid,$langs->trans("AddPhoto"),1);
|
||||
$html->form_attach_new_file('docsoc.php?socid='.$socid,$langs->trans("AddPhoto"),0);
|
||||
|
||||
// Affiche liste des documents existant
|
||||
print_titre($langs->trans("AttachedFiles"));
|
||||
|
||||
@ -527,6 +527,11 @@ LDAPDnContactActiveExample=Activated/Unactivated synchronization
|
||||
LDAPContactDn=Dolibarr contacts' DN
|
||||
LDAPContactDnExample=Complete DN (ex: ou=contacts,dc=society,dc=com)
|
||||
LDAPTestConnect=Test LDAP connection
|
||||
LDAPTestSynchroContact=Test contact's synchronization
|
||||
LDAPTestSynchroUser=Test user's synchronization
|
||||
LDAPTestSynchroMember=Test member's synchronization
|
||||
LDAPSynchroOK=Synchronization test successful
|
||||
LDAPSynchroKO=Failed synchronization test
|
||||
LDAPTCPConnectOK=TCP connect to LDAP server successful (Server=%s, Port=%s)
|
||||
LDAPTCPConnectKO=TCP connect to LDAP server failed (Server=%s, Port=%s)
|
||||
LDAPBindOK=Connect/Authentificate to LDAP server sucessfull (Server=%s, Port=%s, Admin=%s)
|
||||
|
||||
@ -47,7 +47,7 @@ NoRecordedProspects=No prospect recorded
|
||||
StatusActionToDo=To do
|
||||
StatusActionDone=Done
|
||||
StatusActionInProcess=In process
|
||||
TasksHistoryForThisContact=Actions history for this contact
|
||||
TasksHistoryForThisContact=Actions for this contact
|
||||
LastProspectDoNotContact=Do not contact
|
||||
LastProspectNeverContacted=Never contacted
|
||||
LastProspectToContact=To contact
|
||||
|
||||
@ -105,7 +105,7 @@ Note=Note
|
||||
CurrentNote=Current note
|
||||
Title=Title
|
||||
Label=Label
|
||||
Info=Info
|
||||
Info=Log
|
||||
Family=Family
|
||||
Description=Description
|
||||
Designation=Description
|
||||
|
||||
@ -47,7 +47,7 @@ NoRecordedProspects=Pas de prospect enregistr
|
||||
StatusActionToDo=À faire
|
||||
StatusActionDone=Accompli
|
||||
StatusActionInProcess=En cours
|
||||
TasksHistoryForThisContact=Historique des actions pour ce contact
|
||||
TasksHistoryForThisContact=Actions vis à vis de ce contact
|
||||
LastProspectDoNotContact=Ne pas contacter
|
||||
LastProspectNeverContacted=Jamais contacté
|
||||
LastProspectToContact=À contacter
|
||||
|
||||
@ -98,7 +98,7 @@ DefaultContact=Contact par d
|
||||
AddCompany=Créer société
|
||||
AddThirdParty=Ajouter un tiers
|
||||
DeleteACompany=Supprimer une société
|
||||
PersonalInformations=Informations personnelles
|
||||
PersonalInformations=Infos personnelles
|
||||
AccountancyCode=Code compta
|
||||
CustomerCode=Code client
|
||||
SupplierCode=Code fournisseur
|
||||
|
||||
@ -105,7 +105,7 @@ Note=Note
|
||||
CurrentNote=Note actuelle
|
||||
Title=Titre
|
||||
Label=Libellé
|
||||
Info=Info
|
||||
Info=Suivi
|
||||
Family=Famille
|
||||
Description=Description
|
||||
Designation=Désignation
|
||||
|
||||
@ -527,6 +527,11 @@ LDAPDnContactActiveExample=Synchronisation activ
|
||||
LDAPContactDn=DN des contacts Dolibarr
|
||||
LDAPContactDnExample=DN complet (ex: ou=contacts,dc=my-domain,dc=com)
|
||||
LDAPTestConnect=Tester la connexion LDAP
|
||||
LDAPTestSynchroContact=Tester synchronisation contacts
|
||||
LDAPTestSynchroUser=Tester synchronisation utilisateur
|
||||
LDAPTestSynchroMember=Tester synchronisation adhérent
|
||||
LDAPSynchroOK=Test de synchronisation réalisé avec succès
|
||||
LDAPSynchroKO=Echec du test de synchronisation
|
||||
LDAPTCPConnectOK=Connexion TCP au serveur LDAP réussie (Serveur=%s, Port=%s)
|
||||
LDAPTCPConnectKO=Connexion TCP au serveur LDAP échouée (Serveur=%s, Port=%s)
|
||||
LDAPBindOK=Connection/Authentification au serveur LDAP réussie (Serveur=%s, Port=%s, Admin=%s)
|
||||
|
||||
@ -47,7 +47,7 @@ NoRecordedProspects=Aucun prospect enregistr
|
||||
StatusActionToDo=À faire
|
||||
StatusActionDone=Réalisé
|
||||
StatusActionInProcess=En cours
|
||||
TasksHistoryForThisContact=Historique des actions pour ce contact
|
||||
TasksHistoryForThisContact=Actions vis à vis de contact
|
||||
LastProspectDoNotContact=A ne pas contacter
|
||||
LastProspectNeverContacted=Non contactés
|
||||
LastProspectToContact=A contacter
|
||||
|
||||
@ -98,7 +98,7 @@ DefaultContact=Contact par d
|
||||
AddCompany=Créer société
|
||||
AddThirdParty=Créer tiers
|
||||
DeleteACompany=Supprimer une société
|
||||
PersonalInformations=Informations personnelles
|
||||
PersonalInformations=Infos personnelles
|
||||
AccountancyCode=Code compta
|
||||
CustomerCode=Code client
|
||||
SupplierCode=Code fournisseur
|
||||
|
||||
@ -105,7 +105,7 @@ Note=Note
|
||||
CurrentNote=Note actuelle
|
||||
Title=Titre
|
||||
Label=Libellé
|
||||
Info=Info
|
||||
Info=Suivi
|
||||
Family=Famille
|
||||
Description=Description
|
||||
Designation=Désignation
|
||||
|
||||
@ -50,7 +50,7 @@ Type=Het type
|
||||
Language=Taal
|
||||
Note=Aantekening
|
||||
Label=Het etiket
|
||||
Info=de info
|
||||
Info=Log
|
||||
Family=Famille
|
||||
Description=De beschrijving
|
||||
Action=Actie
|
||||
|
||||
@ -69,7 +69,7 @@ Language=Idioma
|
||||
Note=Nota
|
||||
CurrentNote=Nota currente
|
||||
Label=Rótulo
|
||||
Info=Info
|
||||
Info=Log
|
||||
Family=Família
|
||||
Description=Descrição
|
||||
Designation=Designação
|
||||
|
||||
@ -2107,8 +2107,8 @@ function dolibarr_dir_list($path, $types="all", $recursive=0, $filter="", $exclu
|
||||
|
||||
/**
|
||||
* \brief Retourne le numéro de la semaine par rapport a une date
|
||||
* \param time date au format 'timestamp'
|
||||
* \return Numéro de semaine
|
||||
* \param time Date au format 'timestamp'
|
||||
* \return int Numéro de semaine
|
||||
*/
|
||||
function numero_semaine($time)
|
||||
{
|
||||
@ -2185,4 +2185,14 @@ function numero_semaine($time)
|
||||
return sprintf("%02d",$numeroSemaine);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Retourne le picto champ obligatoire
|
||||
* \return string Chaine avec picto obligatoire
|
||||
*/
|
||||
function picto_required()
|
||||
{
|
||||
return '<b>*</b>';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -66,8 +66,9 @@ if ($resql)
|
||||
print $langs->trans("UpdateContact")." rowid=".$obj->rowid;
|
||||
|
||||
$contact = new Contact($db);
|
||||
|
||||
$contact->id = $obj->rowid;
|
||||
$contact->fetch($contact->id);
|
||||
|
||||
$result=$contact->update_ldap($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user