New: On ajout un onglet LDAP sur fiches contacts pour voir a quoi ressemble le contact dans la base LDAP.
This commit is contained in:
parent
0eedd30c48
commit
2a59cf8433
@ -43,7 +43,7 @@ if (!$user->admin)
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
|
||||
if ($_GET["action"] == 'setvalue' && $user->admin)
|
||||
{
|
||||
$error=0;
|
||||
@ -52,8 +52,11 @@ if ($_GET["action"] == 'setvalue' && $user->admin)
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_FIRSTNAME',$_POST["fieldfirstname"])) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_MAIL',$_POST["fieldmail"])) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_PHONE',$_POST["fieldphone"])) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_FAX',$_POST["fieldfax"])) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_MOBILE',$_POST["fieldmobile"])) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_FAX',$_POST["fieldfax"])) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_ADDRESS',$_POST["fieldaddress"])) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_ZIP',$_POST["fieldzip"])) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_TOWN',$_POST["fieldtown"])) $error++;
|
||||
|
||||
if ($error)
|
||||
{
|
||||
@ -158,17 +161,35 @@ print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldPhone").'</td><td>';
|
||||
print '<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_FIELD_PHONE.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td></tr>';
|
||||
|
||||
// Mobile
|
||||
$var=!$var;
|
||||
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>';
|
||||
|
||||
// Fax
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFax").'</td><td>';
|
||||
print '<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_FIELD_FAX.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td></tr>';
|
||||
|
||||
// Mobile
|
||||
// Address
|
||||
$var=!$var;
|
||||
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 '.$bc[$var].'><td>'.$langs->trans("LDAPFieldAddress").'</td><td>';
|
||||
print '<input size="25" type="text" name="fieldaddress" value="'.$conf->global->LDAP_FIELD_ADDRESS.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPFieldAddressExample").'</td></tr>';
|
||||
|
||||
// CP
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldZip").'</td><td>';
|
||||
print '<input size="25" type="text" name="fieldzip" value="'.$conf->global->LDAP_FIELD_ZIP.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPFieldZipExample").'</td></tr>';
|
||||
|
||||
// Ville
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldTown").'</td><td>';
|
||||
print '<input size="25" type="text" name="fieldtown" value="'.$conf->global->LDAP_FIELD_TOWN.'">';
|
||||
print '</td><td>'.$langs->trans("LDAPFieldTownExample").'</td></tr>';
|
||||
|
||||
|
||||
$var=!$var;
|
||||
|
||||
@ -53,7 +53,7 @@ class Contact
|
||||
var $cp;
|
||||
var $ville;
|
||||
var $fk_pays;
|
||||
var $fk_soc;
|
||||
var $socid; // fk_soc
|
||||
|
||||
var $code;
|
||||
var $email;
|
||||
@ -86,7 +86,7 @@ class Contact
|
||||
{
|
||||
// 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(),";
|
||||
@ -290,148 +290,91 @@ class Contact
|
||||
{
|
||||
if ($conf->global->LDAP_SERVER_TYPE == 'activedirectory')
|
||||
{
|
||||
// Pas de conversion utf8 pour etre compatible Windows
|
||||
$info["objectclass"]=array("top",
|
||||
"person",
|
||||
"organizationalPerson",
|
||||
"user");
|
||||
|
||||
// Champs obligatoires
|
||||
$info["cn"] = trim($this->firstname." ".$this->name);
|
||||
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);
|
||||
$soc->fetch($this->socid);
|
||||
$info["o"] = $soc->nom;
|
||||
$info["company"] = $soc->nom;
|
||||
|
||||
if ($soc->client == 1)
|
||||
{
|
||||
$info["businessCategory"] = "Customers";
|
||||
}
|
||||
elseif ($soc->client == 2)
|
||||
{
|
||||
$info["businessCategory"] = "Prospects";
|
||||
}
|
||||
|
||||
if ($soc->fournisseur == 1)
|
||||
{
|
||||
$info["businessCategory"] = "Suppliers";
|
||||
}
|
||||
|
||||
if ($soc->ville)
|
||||
{
|
||||
if ($soc->adresse)
|
||||
{
|
||||
$info["streetAddress"] = $soc->adresse;
|
||||
}
|
||||
if ($soc->cp)
|
||||
{
|
||||
$info["postalCode"] = $soc->cp;
|
||||
}
|
||||
|
||||
$info["l"] = $soc->ville;
|
||||
}
|
||||
}
|
||||
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",
|
||||
"inetOrgPerson");
|
||||
|
||||
// Champs obligatoires
|
||||
$info["cn"] = utf8_encode(trim($this->firstname." ".$this->name));
|
||||
if ($this->name) $info[$conf->global->LDAP_FIELD_NAME] = utf8_encode($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"] = utf8_encode($this->poste);
|
||||
if ($this->socid > 0)
|
||||
{
|
||||
$soc = new Societe($this->db);
|
||||
$soc->fetch($this->socid);
|
||||
}
|
||||
|
||||
$info["o"] = utf8_encode($soc->nom);
|
||||
// Champs obligatoires
|
||||
$info["cn"] = trim($this->firstname." ".$this->name);
|
||||
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] = $this->firstname;
|
||||
if ($this->poste) $info["title"] = $this->poste;
|
||||
if ($this->socid > 0)
|
||||
{
|
||||
$soc = new Societe($this->db);
|
||||
$soc->fetch($this->socid);
|
||||
|
||||
if ($soc->client == 1) $info["businessCategory"] = utf8_encode("Customers");
|
||||
if ($soc->client == 2) $info["businessCategory"] = utf8_encode("Prospects");
|
||||
if ($soc->fournisseur == 1) $info["businessCategory"] = utf8_encode("Suppliers");
|
||||
if ($soc->adresse) $info["street"] = utf8_encode($soc->adresse);
|
||||
if ($soc->cp) $info["postalCode"] = utf8_encode($soc->cp);
|
||||
if ($soc->ville) $info["l"] = utf8_encode($soc->ville);
|
||||
}
|
||||
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 && $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 && $conf->global->LDAP_FIELD_MAIL) $info[$conf->global->LDAP_FIELD_MAIL] = utf8_encode($this->email);
|
||||
$info["o"] = $soc->nom;
|
||||
if ($soc->client == 1) $info["businessCategory"] = "Customers";
|
||||
if ($soc->client == 2) $info["businessCategory"] = "Prospects";
|
||||
if ($soc->fournisseur == 1) $info["businessCategory"] = "Suppliers";
|
||||
}
|
||||
if ($this->address && $conf->global->LDAP_FIELD_ADDRESS) $info[$conf->global->LDAP_FIELD_ADDRESS] = $this->address;
|
||||
if ($this->cp && $conf->global->LDAP_FIELD_ZIP) $info[$conf->global->LDAP_FIELD_ZIP] = $this->cp;
|
||||
if ($this->ville && $conf->global->LDAP_FIELD_TOWN) $info[$conf->global->LDAP_FIELD_TOWN] = $this->ville;
|
||||
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;
|
||||
|
||||
if ($conf->global->LDAP_SERVER_TYPE == 'egroupware')
|
||||
if ($conf->global->LDAP_SERVER_TYPE == 'egroupware')
|
||||
{
|
||||
$info["objectclass"][4] = "phpgwContact"; // compatibilite egroupware
|
||||
|
||||
$info['uidnumber'] = $this->id;
|
||||
|
||||
$info['phpgwTz'] = 0;
|
||||
$info['phpgwMailType'] = 'INTERNET';
|
||||
$info['phpgwMailHomeType'] = 'INTERNET';
|
||||
|
||||
$info["phpgwContactTypeId"] = 'n';
|
||||
$info["phpgwContactCatId"] = 0;
|
||||
$info["phpgwContactAccess"] = "public";
|
||||
|
||||
if (strlen($user->egroupware_id) == 0)
|
||||
{
|
||||
$info["objectclass"][4] = "phpgwContact"; // compatibilite egroupware
|
||||
|
||||
if ($this->email) $info["rfc822Mailbox"] = $this->email;
|
||||
|
||||
$info['uidnumber'] = $this->id;
|
||||
|
||||
$info['phpgwTz'] = 0;
|
||||
$info['phpgwMailType'] = 'INTERNET';
|
||||
$info['phpgwMailHomeType'] = 'INTERNET';
|
||||
|
||||
$info["phpgwContactTypeId"] = 'n';
|
||||
$info["phpgwContactCatId"] = 0;
|
||||
$info["phpgwContactAccess"] = "public";
|
||||
|
||||
if (strlen($user->egroupware_id) == 0)
|
||||
{
|
||||
$user->egroupware_id = 1;
|
||||
}
|
||||
|
||||
$info["phpgwContactOwner"] = $user->egroupware_id;
|
||||
|
||||
if ($this->phone_mobile)
|
||||
$info["phpgwCellTelephoneNumber"] = dolibarr_print_phone($this->phone_mobile);
|
||||
$user->egroupware_id = 1;
|
||||
}
|
||||
|
||||
$info["uid"] = "Dolibarr ".$this->id. ": ".utf8_encode(trim($this->firstname." ".$this->name));
|
||||
|
||||
$info["phpgwContactOwner"] = $user->egroupware_id;
|
||||
|
||||
if ($this->email) $info["rfc822Mailbox"] = $this->email;
|
||||
if ($this->phone_mobile) $info["phpgwCellTelephoneNumber"] = $this->phone_mobile;
|
||||
}
|
||||
|
||||
$info["uid"] = "Dolibarr ".$this->id. ": ".trim($this->firstname." ".$this->name);
|
||||
|
||||
$newdn = "cn=".$info["cn"].",".$conf->global->LDAP_CONTACT_DN;
|
||||
$olddn = $newdn;
|
||||
if ($this->old_firstname || $this->old_name) $olddn="cn=".trim($this->old_firstname." ".$this->old_name).",".$conf->global->LDAP_CONTACT_DN;
|
||||
|
||||
// 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);
|
||||
dolibarr_syslog("Contact.class::update_ldap olddn=".$olddn." newdn=".$newdn);
|
||||
|
||||
$result = $ldap->delete($olddn);
|
||||
$result = $ldap->add($newdn, $info);
|
||||
if ($result <= 0)
|
||||
{
|
||||
$this->error = $ldap->error." ".ldap_errno($ldap->connection)." ".ldap_error($ldap->connection);
|
||||
$this->error = ldap_errno($ldap->connection)." ".ldap_error($ldap->connection)." ".$ldap->error;
|
||||
dolibarr_syslog("Contact.class::update_ldap ".$this->error);
|
||||
//print_r($info);
|
||||
return -1;
|
||||
@ -874,7 +817,7 @@ class Contact
|
||||
$this->fk_pays = 1;
|
||||
$this->email = 'specimen@specimen.com';
|
||||
$socid = rand(1, $num_socs);
|
||||
$this->fk_soc = $socids[$socid];
|
||||
$this->socid = $socids[$socid];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/contact.lib.php");
|
||||
|
||||
$user->getrights('commercial');
|
||||
|
||||
@ -80,26 +81,12 @@ $contact = new Contact($db);
|
||||
$contact->fetch($_GET["id"], $user);
|
||||
|
||||
|
||||
$h=0;
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
$head = contact_prepare_head($contact);
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contact/fiche.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("General");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contact/perso.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("PersonalInformations");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contact/exportimport.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("ExportImport");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contact/info.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$h++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Contact").": ".$contact->firstname.' '.$contact->name);
|
||||
dolibarr_fiche_head($head, 'exportimport', $langs->trans("Contact").": ".$contact->firstname.' '.$contact->name);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@ -32,7 +32,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");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/contact.lib.php");
|
||||
|
||||
$langs->load("companies");
|
||||
$langs->load("users");
|
||||
@ -63,7 +63,7 @@ if ($contactid && !$user->rights->commercial->client->voir)
|
||||
$sql .= " AND sc.fk_soc = sp.fk_soc AND sc.fk_user = ".$user->id;
|
||||
}
|
||||
if ($user->societe_id > 0) $sql .= " AND sp.fk_soc = ".$socid;
|
||||
|
||||
|
||||
if ( $db->query($sql) )
|
||||
{
|
||||
if ( $db->num_rows() == 0) accessforbidden();
|
||||
@ -77,7 +77,7 @@ if ($user->rights->societe->contact->creer)
|
||||
// Recuperation contact actuel
|
||||
$contact = new Contact($db);
|
||||
$result = $contact->fetch($_GET["id"]);
|
||||
|
||||
|
||||
// Creation user
|
||||
$nuser = new User($db);
|
||||
$nuser->nom = $contact->name;
|
||||
@ -149,40 +149,45 @@ if ($user->rights->societe->contact->supprimer)
|
||||
|
||||
if ($user->rights->societe->contact->creer)
|
||||
{
|
||||
if ($_POST["action"] == 'update')
|
||||
{
|
||||
$contact = new Contact($db);
|
||||
|
||||
$contact->old_name = $_POST["old_name"];
|
||||
$contact->old_firstname = $_POST["old_firstname"];
|
||||
|
||||
$contact->socid = $_POST["socid"];
|
||||
$contact->name = $_POST["name"];
|
||||
$contact->firstname = $_POST["firstname"];
|
||||
$contact->civilite_id = $_POST["civilite_id"];
|
||||
$contact->poste = $_POST["poste"];
|
||||
|
||||
$contact->address = $_POST["address"];
|
||||
$contact->cp = $_POST["cp"];
|
||||
$contact->ville = $_POST["ville"];
|
||||
$contact->fk_pays = $_POST["pays_id"];
|
||||
|
||||
$contact->email = $_POST["email"];
|
||||
$contact->phone_pro = $_POST["phone_pro"];
|
||||
$contact->phone_perso = $_POST["phone_perso"];
|
||||
$contact->phone_mobile = $_POST["phone_mobile"];
|
||||
$contact->fax = $_POST["fax"];
|
||||
$contact->jabberid = $_POST["jabberid"];
|
||||
|
||||
$contact->note = $_POST["note"];
|
||||
|
||||
$result = $contact->update($_POST["contactid"], $user);
|
||||
|
||||
if ($contact->error)
|
||||
{
|
||||
$error = $contact->error;
|
||||
}
|
||||
}
|
||||
if ($_POST["action"] == 'update' && ! $_POST["cancel"])
|
||||
{
|
||||
$contact = new Contact($db);
|
||||
|
||||
$contact->old_name = $_POST["old_name"];
|
||||
$contact->old_firstname = $_POST["old_firstname"];
|
||||
|
||||
$contact->socid = $_POST["socid"];
|
||||
$contact->name = $_POST["name"];
|
||||
$contact->firstname = $_POST["firstname"];
|
||||
$contact->civilite_id = $_POST["civilite_id"];
|
||||
$contact->poste = $_POST["poste"];
|
||||
|
||||
$contact->address = $_POST["address"];
|
||||
$contact->cp = $_POST["cp"];
|
||||
$contact->ville = $_POST["ville"];
|
||||
$contact->fk_pays = $_POST["pays_id"];
|
||||
|
||||
$contact->email = $_POST["email"];
|
||||
$contact->phone_pro = $_POST["phone_pro"];
|
||||
$contact->phone_perso = $_POST["phone_perso"];
|
||||
$contact->phone_mobile = $_POST["phone_mobile"];
|
||||
$contact->fax = $_POST["fax"];
|
||||
$contact->jabberid = $_POST["jabberid"];
|
||||
|
||||
$contact->note = $_POST["note"];
|
||||
|
||||
$result = $contact->update($_POST["contactid"], $user);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$contact->old_name='';
|
||||
$contact->old_firstname='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = $contact->error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -215,25 +220,12 @@ if ($_GET["id"] > 0)
|
||||
dolibarr_print_error('',$contact->error);
|
||||
}
|
||||
|
||||
$h=0;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contact/fiche.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("General");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
$head = contact_prepare_head($contact);
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contact/perso.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("PersonalInformations");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contact/exportimport.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("ExportImport");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contact/info.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$h++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Contact").": ".$contact->firstname.' '.$contact->name);
|
||||
dolibarr_fiche_head($head, 'general', $langs->trans("Contact").": ".$contact->firstname.' '.$contact->name);
|
||||
}
|
||||
|
||||
|
||||
@ -456,7 +448,11 @@ if ($user->rights->societe->contact->creer)
|
||||
else print $langs->trans("NoDolibarrAccess");
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td></tr>';
|
||||
print '<tr><td colspan="4" align="center">';
|
||||
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
print "</form>";
|
||||
@ -686,7 +682,7 @@ if ($_GET["id"] && $_GET["action"] != 'edit')
|
||||
print '<td>'.$langs->trans("Author").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Status").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
foreach ($histo as $key=>$value)
|
||||
{
|
||||
$var=!$var;
|
||||
@ -732,7 +728,7 @@ if ($_GET["id"] && $_GET["action"] != 'edit')
|
||||
$actionstatic=new ActionComm($db);
|
||||
print $actionstatic->LibStatut($histo[$key]['percent'],5);
|
||||
print '</td>';
|
||||
|
||||
|
||||
print "</tr>\n";
|
||||
}
|
||||
print "</table>";
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/contact.lib.php");
|
||||
|
||||
$user->getrights('commercial');
|
||||
|
||||
@ -79,25 +80,13 @@ $contact = new Contact($db);
|
||||
$contact->fetch($_GET["id"], $user);
|
||||
|
||||
|
||||
$h=0;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contact/fiche.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("General");
|
||||
$h++;
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
$head = contact_prepare_head($contact);
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contact/perso.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("PersonalInformations");
|
||||
$h++;
|
||||
dolibarr_fiche_head($head, 'info', $langs->trans("Contact").": ".$contact->firstname.' '.$contact->name);
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contact/exportimport.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("ExportImport");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contact/info.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Contact").": ".$contact->firstname.' '.$contact->name);
|
||||
|
||||
/*
|
||||
* Visualisation de la fiche
|
||||
|
||||
@ -144,12 +144,12 @@ 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);
|
||||
dolibarr_syslog("ldap.php: 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);
|
||||
dolibarr_syslog("ldap.php: bind",LOG_DEBUG);
|
||||
$bind=$ldap->bind();
|
||||
}
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/vcard/vcard.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/contact.lib.php");
|
||||
|
||||
$user->getrights('commercial');
|
||||
|
||||
@ -103,27 +103,13 @@ $form = new Form($db);
|
||||
$contact = new Contact($db);
|
||||
$contact->fetch($_GET["id"], $user);
|
||||
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
$head = contact_prepare_head($contact);
|
||||
|
||||
$h=0;
|
||||
dolibarr_fiche_head($head, 'perso', $langs->trans("Contact").": ".$contact->firstname.' '.$contact->name);
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contact/fiche.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("General");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contact/perso.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("PersonalInformations");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contact/exportimport.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("ExportImport");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contact/info.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$h++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Contact").": ".$contact->firstname.' '.$contact->name);
|
||||
|
||||
|
||||
if ($_GET["action"] == 'edit')
|
||||
|
||||
@ -2716,6 +2716,46 @@ class Form
|
||||
return $i;
|
||||
}
|
||||
|
||||
|
||||
function show_ldap_content($result,$level,$count,$var)
|
||||
{
|
||||
global $bc;
|
||||
|
||||
$count++;
|
||||
if ($count > 1000) return; // To avoid infinite loop
|
||||
|
||||
foreach($result as $key => $val)
|
||||
{
|
||||
if ("$key" == "objectclass") continue;
|
||||
if ("$key" == "count") continue;
|
||||
if ("$key" == "dn") continue;
|
||||
|
||||
if ("$val" == "objectclass") continue;
|
||||
if ("$val" == $lastkey[$level]) continue;
|
||||
|
||||
$lastkey[$level]=$key;
|
||||
|
||||
if (is_array($val))
|
||||
{
|
||||
if (! is_numeric($key))
|
||||
{
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>';
|
||||
print $key;
|
||||
print '</td><td>';
|
||||
}
|
||||
$this->show_ldap_content($val,$level+1,$count,$var);
|
||||
}
|
||||
else
|
||||
{
|
||||
print utf8_decode("$val");
|
||||
//print "<br>\n";
|
||||
print '</td></tr>';
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -553,7 +553,7 @@ LDAPFieldName=Name
|
||||
LDAPFieldNameExample=Suggested value : sn
|
||||
LDAPFieldFirstName=Firstname
|
||||
LDAPFieldFirstNameExample=Suggested value : givenname
|
||||
LDAPFieldMail=E-Mail address
|
||||
LDAPFieldMail=Email address
|
||||
LDAPFieldMailExample=Suggested value : mail
|
||||
LDAPFieldPhone=Phone number
|
||||
LDAPFieldPhoneExample=Suggested value : telephonenumber
|
||||
@ -561,6 +561,12 @@ LDAPFieldFax=Fax number
|
||||
LDAPFieldFaxExample=Suggested value : facsimiletelephonenumber
|
||||
LDAPFieldMobile=Cellular phone
|
||||
LDAPFieldMobileExample=Suggested value : mobile
|
||||
LDAPFieldAddress=Street
|
||||
LDAPFieldAddressExample=Valeur recommandée : street
|
||||
LDAPFieldZip=Zip
|
||||
LDAPFieldZipExample=Valeur recommandée : postalcode
|
||||
LDAPFieldTown=Town
|
||||
LDAPFieldTownExample=Valeur recommandée : l
|
||||
LDAPParametersAreStillHardCoded=LDAP parametres are still hardcoded (in contact class)
|
||||
LDAPSetupNotComplete=LDAP setup not complete (go on others tabs)
|
||||
LDAPNoUserOrPasswordProvidedAccessIsReadOnly=No administrator or password provided. LDAP access will be anonymous and in read only mode.
|
||||
|
||||
@ -525,11 +525,11 @@ LDAPFieldName=Non
|
||||
LDAPFieldNameExample=Attribut par défaut : sn
|
||||
LDAPFieldFirstName=Prénom
|
||||
LDAPFieldFirstNameExample=Attribut par défaut: givenname
|
||||
LDAPFieldMail=Adresse e-mail
|
||||
LDAPFieldMail=Email
|
||||
LDAPFieldMailExample=Attribut par défaut: mail
|
||||
LDAPFieldPhone=Numéro de téléphone
|
||||
LDAPFieldPhone=Téléphone
|
||||
LDAPFieldPhoneExample=Attribut par défaut: telephonenumber
|
||||
LDAPFieldFax=Numéro de fax
|
||||
LDAPFieldFax=Fax
|
||||
LDAPFieldFaxExample=Attribut par défaut: facsimiletelephonenumber
|
||||
LDAPFieldMobile=Téléphone cellulaire
|
||||
LDAPFieldMobileExample=Attribut par défault: mobile
|
||||
|
||||
@ -553,14 +553,20 @@ LDAPFieldName=Nom
|
||||
LDAPFieldNameExample=Valeur recommandée : sn
|
||||
LDAPFieldFirstName=Prénom
|
||||
LDAPFieldFirstNameExample=Valeur recommandée : givenname
|
||||
LDAPFieldMail=Adresse E-Mail
|
||||
LDAPFieldMail=Email
|
||||
LDAPFieldMailExample=Valeur recommandée : mail
|
||||
LDAPFieldPhone=Numéro de téléphone
|
||||
LDAPFieldPhone=Téléphone
|
||||
LDAPFieldPhoneExample=Valeur recommandée : telephonenumber
|
||||
LDAPFieldFax=Numéro de fax
|
||||
LDAPFieldFax=Fax
|
||||
LDAPFieldFaxExample=Valeur recommandée : facsimiletelephonenumber
|
||||
LDAPFieldMobile=Téléphone portable
|
||||
LDAPFieldMobileExample=Valeur recommandée : mobile
|
||||
LDAPFieldAddress=Adresse
|
||||
LDAPFieldAddressExample=Valeur recommandée : street
|
||||
LDAPFieldZip=Code postal
|
||||
LDAPFieldZipExample=Valeur recommandée : postalcode
|
||||
LDAPFieldTown=Ville
|
||||
LDAPFieldTownExample=Valeur recommandée : l
|
||||
LDAPParametersAreStillHardCoded=Les parametres LDAP sont codés en dur (dans classe contact)
|
||||
LDAPSetupNotComplete=Configuration LDAP incomplète (à compléter sur les autres onglets)
|
||||
LDAPNoUserOrPasswordProvidedAccessIsReadOnly=Administrateur ou mot de passe non renseigné. Les accès LDAP seront donc anonymes et en lecture seule.
|
||||
|
||||
@ -3,4 +3,7 @@ DomainPassword=Mot de passe du domaine
|
||||
UserMustChangePassNextLogon=L'utilisateur doit changer de mot de passe à la prochaine connexion
|
||||
LdapUacf_NORMAL_ACCOUNT=Compte Utilisateur
|
||||
LdapUacf_DONT_EXPIRE_PASSWORD=Le mot de passe n'expire jamais
|
||||
LdapUacf_ACCOUNTDISABLE=Le compte est désactivé sur le domaine
|
||||
LdapUacf_ACCOUNTDISABLE=Le compte est désactivé sur le domaine
|
||||
LDAPInformationsForThisContact=Informations en base LDAP pour ce contact
|
||||
LDAPInformationsForThisUser=Informations en base LDAP pour cet utilisateur
|
||||
LDAPAttribute=Attribut
|
||||
|
||||
@ -108,7 +108,8 @@ class AuthLdap {
|
||||
* Constructor- creates a new instance of the authentication class
|
||||
*
|
||||
*/
|
||||
function AuthLdap () {
|
||||
function AuthLdap ()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
//Server
|
||||
@ -431,8 +432,21 @@ class AuthLdap {
|
||||
*/
|
||||
function add($dn, $info)
|
||||
{
|
||||
dolibarr_syslog("authldap::add Add LDAP entry dn=".$dn);
|
||||
|
||||
global $conf;
|
||||
|
||||
// Encode en UTF8
|
||||
if ($conf->global->LDAP_SERVER_TYPE != 'activedirectory')
|
||||
{
|
||||
$dn=utf8_encode($dn);
|
||||
foreach($info as $key => $val)
|
||||
{
|
||||
if (! is_array($val)) $info[$key]=utf8_encode($val);
|
||||
}
|
||||
}
|
||||
|
||||
dolibarr_syslog("authldap::add dn=".$dn);
|
||||
dolibarr_syslog("authldap::add info=".join(',',$info));
|
||||
|
||||
//print_r($info);
|
||||
$result=@ldap_add($this->connection, $dn, $info);
|
||||
|
||||
@ -447,6 +461,14 @@ class AuthLdap {
|
||||
*/
|
||||
function delete($dn)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
// Encode en UTF8
|
||||
if ($conf->global->LDAP_SERVER_TYPE != 'activedirectory')
|
||||
{
|
||||
$dn=utf8_encode($dn);
|
||||
}
|
||||
|
||||
dolibarr_syslog("authldap::delete Delete LDAP entry dn=".$dn);
|
||||
|
||||
$result=@ldap_delete($this->connection, $dn);
|
||||
@ -456,6 +478,7 @@ class AuthLdap {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 2.4 Attribute methods -----------------------------------------------------
|
||||
/**
|
||||
* 2.4.1 : Returns an array containing a set of attribute values.
|
||||
@ -625,36 +648,37 @@ class AuthLdap {
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief fonction de recherche avec filtre
|
||||
* \param dn de recherche
|
||||
* \param filtre de recherche (ex: sn=nom_personne)
|
||||
*/
|
||||
function search( $checkDn, $filter) {
|
||||
/**
|
||||
* \brief fonction de recherche avec filtre
|
||||
* \param dn de recherche
|
||||
* \param filtre de recherche (ex: sn=nom_personne)
|
||||
*/
|
||||
function search( $checkDn, $filter) {
|
||||
|
||||
// Perform the search and get the entry handles
|
||||
|
||||
// if the directory is AD, then bind first with the search user first
|
||||
if ($this->serverType == "activedirectory") {
|
||||
$this->authBind($this->searchUser, $this->searchPassword);
|
||||
}
|
||||
|
||||
$this->result = @ldap_search( $this->connection, $checkDn, $filter);
|
||||
|
||||
$result = @ldap_get_entries( $this->connection, $this->result);
|
||||
|
||||
if (!$result)
|
||||
{
|
||||
$this->ldapErrorCode = ldap_errno( $this->connection);
|
||||
$this->ldapErrorText = ldap_error( $this->connection);
|
||||
}
|
||||
else
|
||||
{
|
||||
ldap_free_result($this->result);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
// Perform the search and get the entry handles
|
||||
|
||||
// if the directory is AD, then bind first with the search user first
|
||||
if ($this->serverType == "activedirectory") {
|
||||
$this->authBind($this->searchUser, $this->searchPassword);
|
||||
}
|
||||
|
||||
$this->result = @ldap_search( $this->connection, $checkDn, $filter);
|
||||
|
||||
$result = @ldap_get_entries( $this->connection, $this->result);
|
||||
|
||||
if (!$result)
|
||||
{
|
||||
$this->ldapErrorCode = ldap_errno( $this->connection);
|
||||
$this->ldapErrorText = ldap_error( $this->connection);
|
||||
}
|
||||
else
|
||||
{
|
||||
ldap_free_result($this->result);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief récupère les attributs de l'utilisateur
|
||||
* \param $user : utilisateur ldap
|
||||
|
||||
69
htdocs/lib/contact.lib.php
Normal file
69
htdocs/lib/contact.lib.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
* or see http://www.gnu.org/
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/lib/contact.lib.php
|
||||
\brief Ensemble de fonctions de base pour les contacts
|
||||
\version $Revision$
|
||||
|
||||
Ensemble de fonctions de base de dolibarr sous forme d'include
|
||||
*/
|
||||
|
||||
function contact_prepare_head($contrat)
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contact/fiche.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("General");
|
||||
$head[$h][2] = 'general';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contact/perso.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("PersonalInformations");
|
||||
$head[$h][2] = 'perso';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contact/exportimport.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("ExportImport");
|
||||
$head[$h][2] = 'exportimport';
|
||||
$h++;
|
||||
|
||||
if ($conf->ldap->enabled && $conf->global->LDAP_CONTACT_ACTIVE)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contact/ldap.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("LDAP");
|
||||
$head[$h][2] = 'ldap';
|
||||
$h++;
|
||||
}
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contact/info.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user