Script d'import ldap2dolibarr des adhérents est ok

This commit is contained in:
Laurent Destailleur 2006-11-26 07:00:14 +00:00
parent 3be6ee06ce
commit 11d9bf5848
17 changed files with 395 additions and 210 deletions

View File

@ -81,16 +81,15 @@ class Adherent
var $error; var $error;
/** /**
\brief Adherent \brief Adherent
\param DB base de données \param DB base de données
\param id id de l'adhérent \param id id de l'adhérent
*/ */
function Adherent($DB)
function Adherent($DB, $id='')
{ {
$this->db = $DB ; $this->db = $DB ;
$this->id = $id;
$this->statut = -1; $this->statut = -1;
// l'adherent n'est pas public par defaut // l'adherent n'est pas public par defaut
$this->public = 0; $this->public = 0;
@ -328,21 +327,26 @@ class Adherent
global $conf,$langs,$user; global $conf,$langs,$user;
// Verification parametres // Verification parametres
if ($conf->global->ADHERENT_MAIL_REQUIRED && ! ValidEMail($this->email)) { if ($conf->global->ADHERENT_MAIL_REQUIRED && ! ValidEMail($this->email))
{
$this->error = $langs->trans("ErrorBadEMail",$this->email); $this->error = $langs->trans("ErrorBadEMail",$this->email);
return -1; return -1;
} }
$this->date = $this->db->idate($this->date); // Insertion membre
$sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent (datec,login)";
$sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent (datec)"; $sql.= " VALUES (now(),'".$this->login."')";
$sql .= " VALUES (now())";
dolibarr_syslog("Adherent.class::create sql=".$sql); dolibarr_syslog("Adherent.class::create sql=".$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent"); $id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent");
if ($id > 0)
{
$this->id=$id;
// Mise a jour
$result=$this->update($user,1); $result=$this->update($user,1);
// Appel des triggers // Appel des triggers
@ -355,6 +359,12 @@ class Adherent
return $this->id; return $this->id;
} }
else else
{
dolibarr_print_error($this->db,'Failed to get last insert id');
return -1;
}
}
else
{ {
dolibarr_print_error($this->db); dolibarr_print_error($this->db);
return -1; return -1;
@ -388,16 +398,16 @@ class Adherent
$sql .= ",login='" .$this->login."'"; $sql .= ",login='" .$this->login."'";
$sql .= ",pass='" .$this->pass."'"; $sql .= ",pass='" .$this->pass."'";
$sql .= ",societe='".$this->societe."'"; $sql .= ",societe='".$this->societe."'";
$sql .= ",adresse='".$this->adresse."'"; $sql .= ",adresse=" .($this->adresse?"'".addslashes($this->adresse)."'":"null");
$sql .= ",cp='" .$this->cp."'"; $sql .= ",cp='" .$this->cp."'";
$sql .= ",ville='" .$this->ville."'"; $sql .= ",ville='" .$this->ville."'";
$sql .= ",pays='" .$this->pays_code."'"; $sql .= ",pays='" .$this->pays_id."'";
$sql .= ",email='" .$this->email."'"; $sql .= ",email='" .$this->email."'";
$sql .= ",phone=" .($this->phone?"'".addslashes($this->phone)."'":"null"); $sql .= ",phone=" .($this->phone?"'".addslashes($this->phone)."'":"null");
$sql .= ",phone_perso=" .($this->phone_perso?"'".addslashes($this->phone_perso)."'":"null"); $sql .= ",phone_perso=" .($this->phone_perso?"'".addslashes($this->phone_perso)."'":"null");
$sql .= ",phone_mobile=" .($this->phone_mobile?"'".addslashes($this->phone_mobile)."'":"null"); $sql .= ",phone_mobile=" .($this->phone_mobile?"'".addslashes($this->phone_mobile)."'":"null");
$sql .= ",note=" .($this->commentaire?"'".addslashes($this->commentaire)."'":"null"); $sql .= ",note=" .($this->commentaire?"'".addslashes($this->commentaire)."'":"null");
$sql .= ",naiss=" .$this->db->idate($this->naiss); $sql .= ",naiss=" .($this->naiss?"'".$this->db->idate($this->naiss)."'":"null");
$sql .= ",photo=" .($this->photo?"'".$this->photo."'":"null"); $sql .= ",photo=" .($this->photo?"'".$this->photo."'":"null");
$sql .= ",public='" .$this->public."'"; $sql .= ",public='" .$this->public."'";
$sql .= ",statut=" .$this->statut; $sql .= ",statut=" .$this->statut;
@ -466,36 +476,47 @@ class Adherent
function delete($rowid) function delete($rowid)
{ {
global $conf, $langs; global $conf, $langs;
$result = 0; $result = 0;
// Suppression options
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_options WHERE adhid = ".$rowid; $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_options WHERE adhid = ".$rowid;
if ( $this->db->query($sql) )
{
if ( $this->db->affected_rows() )
{
dolibarr_syslog("Adherent.class::delete sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."cotisation WHERE fk_adherent = ".$rowid; $sql = "DELETE FROM ".MAIN_DB_PREFIX."cotisation WHERE fk_adherent = ".$rowid;
if ($this->db->query( $sql)) dolibarr_syslog("Adherent.class::delete sql=".$sql);
$resql=$this->db->query( $sql);
if ($resql)
{ {
} }
else
{
dolibarr_print_error($this->db);
return -1;
}
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent WHERE rowid = ".$rowid; $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent WHERE rowid = ".$rowid;
dolibarr_syslog("Adherent.class::delete"); dolibarr_syslog("Adherent.class::delete sql=".$sql);
$resql=$this->db->query($sql);
if ( $this->db->query($sql) ) if ($resql)
{ {
if ( $this->db->affected_rows() ) if ($this->db->affected_rows($resql))
{ {
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db); $interface=new Interfaces($this->db);
$result=$interface->run_triggers('CONTACT_DELETE',$this,$user,$langs,$conf); $result=$interface->run_triggers('MEMBER_DELETE',$this,$user,$langs,$conf);
if ($result < 0) $error++; if ($result < 0) $error++;
// Fin appel triggers // Fin appel triggers
} }
} }
else
{
dolibarr_print_error($this->db);
return -1;
} }
} }
else else
@ -545,8 +566,8 @@ class Adherent
$sql = "SELECT d.rowid, d.prenom, d.nom, d.societe, d.statut, d.public, d.adresse, d.cp, d.ville, d.note,"; $sql = "SELECT d.rowid, d.prenom, d.nom, d.societe, d.statut, d.public, d.adresse, d.cp, d.ville, d.note,";
$sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass,"; $sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass,";
$sql.= " d.naiss, d.photo, d.fk_adherent_type, d.morphy,"; $sql.= " d.naiss, d.photo, d.fk_adherent_type, d.morphy,";
$sql.= " ".$this->db->pdate("d.datefin")." as datefin,"; $sql.= " ".$this->db->pdate("d.datefin")." as datefin, d.pays,";
$sql.= " d.pays, p.rowid as pays_id, p.code as pays_code, p.libelle as pays_lib,"; $sql.= " p.rowid as pays_id, p.code as pays_code, p.libelle as pays_lib,";
$sql.= " t.libelle as type, t.cotisation as cotisation"; $sql.= " t.libelle as type, t.cotisation as cotisation";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON d.pays = p.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON d.pays = p.rowid";
@ -583,7 +604,6 @@ class Adherent
$this->photo = $obj->photo; $this->photo = $obj->photo;
$this->statut = $obj->statut; $this->statut = $obj->statut;
$this->public = $obj->public; $this->public = $obj->public;
$this->date = $obj->datedon;
$this->datefin = $obj->datefin; $this->datefin = $obj->datefin;
$this->commentaire = $obj->note; $this->commentaire = $obj->note;
$this->morphy = $obj->morphy; $this->morphy = $obj->morphy;
@ -682,28 +702,33 @@ class Adherent
et eventuellement liens dans banques, mailman, etc... et eventuellement liens dans banques, mailman, etc...
\param date Date cotisation \param date Date cotisation
\param montant Montant cotisation \param montant Montant cotisation
\param account_id Id compte bancaire
\param operation Type operation (si Id compte bancaire fourni)
\param operation Label operation (si Id compte bancaire fourni)
\param num_chq Numero cheque (si Id compte bancaire fourni)
\return int rowid de l'entrée ajoutée, <0 si erreur \return int rowid de l'entrée ajoutée, <0 si erreur
*/ */
function cotisation($date, $montant, $accountid, $operation, $label, $num_chq) function cotisation($date, $montant, $accountid, $operation, $label, $num_chq)
{ {
global $conf,$langs,$user; global $conf,$langs,$user;
dolibarr_syslog("Adherent.class::cotisation $date, $montant, $accountid, $operation, $label, $num_chq");
$this->db->begin(); $this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."cotisation (fk_adherent, datec, dateadh, cotisation)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."cotisation (fk_adherent, datec, dateadh, cotisation)";
$sql .= " VALUES ($this->id, now(), ".$this->db->idate($date).", $montant)"; $sql .= " VALUES (".$this->id.", now(), ".$this->db->idate($date).", ".$montant.")";
dolibarr_syslog("Adherent.class::cotisation sql=".$sql);
$result=$this->db->query($sql); $result=$this->db->query($sql);
if ($result) if ($result)
{ {
$rowid=$this->db->last_insert_id(MAIN_DB_PREFIX."cotisation"); $rowid=$this->db->last_insert_id(MAIN_DB_PREFIX."cotisation");
// datefin = date + 1 an // datefin = date + 1 an
$datefin = mktime(12, 0 , 0, strftime("%m",$date), strftime("%d",$date), $datefin = dolibarr_time_plus_duree($date,1,'y');
strftime("%Y",$date)+1) - (24 * 3600);
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET datefin = ".$this->db->idate($datefin); $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET datefin = ".$this->db->idate($datefin);
$sql.= " WHERE rowid =". $this->id; $sql.= " WHERE rowid =". $this->id;
dolibarr_syslog("Adherent.class::cotisation sql=".$sql);
$resql=$this->db->query( $sql); $resql=$this->db->query( $sql);
if ($resql) if ($resql)
{ {
@ -1709,12 +1734,13 @@ class Adherent
if ($this->cp && $conf->global->LDAP_FIELD_ZIP) $info[$conf->global->LDAP_FIELD_ZIP] = $this->cp; 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->ville && $conf->global->LDAP_FIELD_TOWN) $info[$conf->global->LDAP_FIELD_TOWN] = $this->ville;
if ($this->pays && $conf->global->LDAP_FIELD_COUNTRY) $info[$conf->global->LDAP_FIELD_COUNTRY] = $this->pays; if ($this->pays && $conf->global->LDAP_FIELD_COUNTRY) $info[$conf->global->LDAP_FIELD_COUNTRY] = $this->pays;
if ($this->phone_pro && $conf->global->LDAP_FIELD_PHONE) $info[$conf->global->LDAP_FIELD_PHONE] = $this->phone_pro; if ($this->email && $conf->global->LDAP_FIELD_MAIL) $info[$conf->global->LDAP_FIELD_MAIL] = $this->email;
if ($this->phone_perso) $info["homePhone"] = $this->phone_perso; if ($this->phone && $conf->global->LDAP_FIELD_PHONE) $info[$conf->global->LDAP_FIELD_PHONE] = $this->phone;
if ($this->phone_perso && $conf->global->LDAP_FIELD_PHONE_PERSO) $info[$conf->global->LDAP_FIELD_PHONE_PERSO] = $this->phone_perso;
if ($this->phone_mobile && $conf->global->LDAP_FIELD_MOBILE) $info[$conf->global->LDAP_FIELD_MOBILE] = $this->phone_mobile; 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->fax && $conf->global->LDAP_FIELD_FAX) $info[$conf->global->LDAP_FIELD_FAX] = $this->fax;
if ($this->email && $conf->global->LDAP_FIELD_MAIL) $info[$conf->global->LDAP_FIELD_MAIL] = $this->email;
if ($this->commentaire && $conf->global->LDAP_FIELD_DESCRIPTION) $info[$conf->global->LDAP_FIELD_DESCRIPTION] = $this->commentaire; if ($this->commentaire && $conf->global->LDAP_FIELD_DESCRIPTION) $info[$conf->global->LDAP_FIELD_DESCRIPTION] = $this->commentaire;
if ($this->naiss && $conf->global->LDAP_FIELD_BIRTHDATE) $info[$conf->global->LDAP_FIELD_BIRTHDATE] = dolibarr_print_date($this->naiss,'%Y%m%d%H%M%SZ');
return $info; return $info;
} }

View File

@ -43,6 +43,7 @@ $langs->load("users");
$user->getrights('adherent'); $user->getrights('adherent');
$adh = new Adherent($db);
$adho = new AdherentOptions($db); $adho = new AdherentOptions($db);
$errmsg=''; $errmsg='';
@ -58,7 +59,6 @@ $typeid=isset($_GET["typeid"])?$_GET["typeid"]:$_POST["typeid"];
if ($_POST["action"] == 'confirm_sendinfo' && $_POST["confirm"] == 'yes') if ($_POST["action"] == 'confirm_sendinfo' && $_POST["confirm"] == 'yes')
{ {
$adh = new Adherent($db);
$adh->id = $rowid; $adh->id = $rowid;
$adh->fetch($rowid); $adh->fetch($rowid);
$adh->send_an_email($adh->email,"Voici le contenu de votre fiche\n\n%INFOS%\n\n","Contenu de votre fiche adherent"); $adh->send_an_email($adh->email,"Voici le contenu de votre fiche\n\n%INFOS%\n\n","Contenu de votre fiche adherent");
@ -66,7 +66,6 @@ if ($_POST["action"] == 'confirm_sendinfo' && $_POST["confirm"] == 'yes')
if ($_POST["action"] == 'cotisation') if ($_POST["action"] == 'cotisation')
{ {
$adh = new Adherent($db);
$adh->id = $rowid; $adh->id = $rowid;
$adh->fetch($rowid); $adh->fetch($rowid);
@ -122,9 +121,13 @@ if ($_REQUEST["action"] == 'update')
{ {
if ($_POST["bouton"] == $langs->trans("Save")) if ($_POST["bouton"] == $langs->trans("Save"))
{ {
$datenaiss=mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); $datenaiss='';
if (isset($_POST["naissday"]) && $_POST["naissday"]
$adh = new Adherent($db); && isset($_POST["naissmonth"])
&& isset($_POST["naissyear"]) && $_POST["naissyear"])
{
$datenaiss=@mktime(12, 0 , 0, $_POST["naissmonth"], $_POST["naissday"], $_POST["naissyear"]);
}
$adh->id = $_POST["rowid"]; $adh->id = $_POST["rowid"];
$adh->prenom = $_POST["prenom"]; $adh->prenom = $_POST["prenom"];
@ -137,14 +140,14 @@ if ($_REQUEST["action"] == 'update')
$adh->adresse = $_POST["adresse"]; $adh->adresse = $_POST["adresse"];
$adh->cp = $_POST["cp"]; $adh->cp = $_POST["cp"];
$adh->ville = $_POST["ville"]; $adh->ville = $_POST["ville"];
$adh->pays = $_POST["pays"]; $adh->pays_id = $_POST["pays"];
$adh->phone = $_POST["phone"]; $adh->phone = $_POST["phone"];
$adh->phone_perso = $_POST["phone_perso"]; $adh->phone_perso = $_POST["phone_perso"];
$adh->phone_mobile= $_POST["phone_mobile"]; $adh->phone_mobile= $_POST["phone_mobile"];
$adh->email = $_POST["email"]; $adh->email = $_POST["email"];
$adh->naiss = $_POST["naiss"]; $adh->naiss = $datenaiss;
$adh->date = $adh->naiss; $adh->date = $datenaiss; // A virer
$adh->photo = $_POST["photo"]; $adh->photo = $_POST["photo"];
$adh->typeid = $_POST["type"]; $adh->typeid = $_POST["type"];
@ -189,12 +192,12 @@ if ($_POST["action"] == 'add')
&& isset($_POST["naissmonth"]) && isset($_POST["naissmonth"])
&& isset($_POST["naissyear"]) && $_POST["naissyear"]) && isset($_POST["naissyear"]) && $_POST["naissyear"])
{ {
$datenaiss=mktime(12, 0 , 0, $_POST["naissmonth"], $_POST["naissday"], $_POST["naissyear"]); $datenaiss=@mktime(12, 0 , 0, $_POST["naissmonth"], $_POST["naissday"], $_POST["naissyear"]);
} }
$datecotisation=''; $datecotisation='';
if (isset($_POST["naissday"]) && isset($_POST["naissmonth"]) && isset($_POST["naissyear"])) if (isset($_POST["naissday"]) && isset($_POST["naissmonth"]) && isset($_POST["naissyear"]))
{ {
$datecotisation=mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); $datecotisation=@mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
} }
$type=$_POST["type"]; $type=$_POST["type"];
@ -204,7 +207,7 @@ if ($_POST["action"] == 'add')
$adresse=$_POST["adresse"]; $adresse=$_POST["adresse"];
$cp=$_POST["cp"]; $cp=$_POST["cp"];
$ville=$_POST["ville"]; $ville=$_POST["ville"];
$pays_code=$_POST["pays_code"]; $pays_id=$_POST["pays_id"];
$phone=$_POST["phone"]; $phone=$_POST["phone"];
$phone_perso=$_POST["phone_perso"]; $phone_perso=$_POST["phone_perso"];
@ -217,14 +220,13 @@ if ($_POST["action"] == 'add')
$morphy=$_POST["morphy"]; $morphy=$_POST["morphy"];
$cotisation=$_POST["cotisation"]; $cotisation=$_POST["cotisation"];
$adh = new Adherent($db);
$adh->prenom = $prenom; $adh->prenom = $prenom;
$adh->nom = $nom; $adh->nom = $nom;
$adh->societe = $societe; $adh->societe = $societe;
$adh->adresse = $adresse; $adh->adresse = $adresse;
$adh->cp = $cp; $adh->cp = $cp;
$adh->ville = $ville; $adh->ville = $ville;
$adh->pays_code = $pays_code; $adh->pays_id = $pays_id;
$adh->phone = $phone; $adh->phone = $phone;
$adh->phone_perso = $phone_perso; $adh->phone_perso = $phone_perso;
$adh->phone_mobile= $phone_mobile; $adh->phone_mobile= $phone_mobile;
@ -333,16 +335,22 @@ if ($_POST["action"] == 'add')
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes') if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes')
{ {
$adh = new Adherent($db); $result=$adh->delete($rowid);
$adh->delete($rowid); if ($result > 0)
{
Header("Location: liste.php"); Header("Location: liste.php");
exit; exit;
} }
else
{
$mesg=$adh->error;
}
}
if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes') if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes')
{ {
$adh = new Adherent($db, $rowid); $adh->rowid=$rowid;
$adh->validate($user->id); $adh->validate($user->id);
$adh->fetch($rowid); $adh->fetch($rowid);
@ -369,7 +377,7 @@ if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes')
if ($_POST["action"] == 'confirm_resign' && $_POST["confirm"] == 'yes') if ($_POST["action"] == 'confirm_resign' && $_POST["confirm"] == 'yes')
{ {
$adh = new Adherent($db, $rowid); $adh->rowid=$rowid;
$adh->resiliate($user->id); $adh->resiliate($user->id);
$adh->fetch($rowid); $adh->fetch($rowid);
@ -388,7 +396,7 @@ if ($_POST["action"] == 'confirm_resign' && $_POST["confirm"] == 'yes')
if ($_POST["action"] == 'confirm_add_glasnost' && $_POST["confirm"] == 'yes') if ($_POST["action"] == 'confirm_add_glasnost' && $_POST["confirm"] == 'yes')
{ {
$adh = new Adherent($db, $rowid); $adh->rowid=$rowid;
$adh->fetch($rowid); $adh->fetch($rowid);
$adht = new AdherentType($db); $adht = new AdherentType($db);
$adht->fetch($adh->typeid); $adht->fetch($adh->typeid);
@ -403,7 +411,7 @@ if ($_POST["action"] == 'confirm_add_glasnost' && $_POST["confirm"] == 'yes')
if ($_POST["action"] == 'confirm_del_glasnost' && $_POST["confirm"] == 'yes') if ($_POST["action"] == 'confirm_del_glasnost' && $_POST["confirm"] == 'yes')
{ {
$adh = new Adherent($db, $rowid); $adh->rowid=$rowid;
$adh->fetch($rowid); $adh->fetch($rowid);
$adht = new AdherentType($db); $adht = new AdherentType($db);
$adht->fetch($adh->typeid); $adht->fetch($adh->typeid);
@ -418,7 +426,7 @@ if ($_POST["action"] == 'confirm_del_glasnost' && $_POST["confirm"] == 'yes')
if ($_POST["action"] == 'confirm_del_spip' && $_POST["confirm"] == 'yes') if ($_POST["action"] == 'confirm_del_spip' && $_POST["confirm"] == 'yes')
{ {
$adh = new Adherent($db, $rowid); $adh->rowid=$rowid;
$adh->fetch($rowid); $adh->fetch($rowid);
if(!$adh->del_to_spip()){ if(!$adh->del_to_spip()){
$errmsg.="Echec de la suppression de l'utilisateur dans spip: ".$adh->error."<BR>\n"; $errmsg.="Echec de la suppression de l'utilisateur dans spip: ".$adh->error."<BR>\n";
@ -427,9 +435,10 @@ if ($_POST["action"] == 'confirm_del_spip' && $_POST["confirm"] == 'yes')
if ($_POST["action"] == 'confirm_add_spip' && $_POST["confirm"] == 'yes') if ($_POST["action"] == 'confirm_add_spip' && $_POST["confirm"] == 'yes')
{ {
$adh = new Adherent($db, $rowid); $adh->rowid=$rowid;
$adh->fetch($rowid); $adh->fetch($rowid);
if (!$adh->add_to_spip()){ if (!$adh->add_to_spip())
{
$errmsg.="Echec du rajout de l'utilisateur dans spip: ".$adh->error."<BR>\n"; $errmsg.="Echec du rajout de l'utilisateur dans spip: ".$adh->error."<BR>\n";
} }
} }
@ -556,7 +565,7 @@ if ($action == 'edit')
// Date naissance // Date naissance
print "<tr><td>".$langs->trans("Birthday")."</td><td>\n"; print "<tr><td>".$langs->trans("Birthday")."</td><td>\n";
$htmls->select_date(-1,'naiss','','',1,'update'); $htmls->select_date(($adh->naiss ? $adh->naiss : -1),'naiss','','',1,'update');
print "</td></tr>\n"; print "</td></tr>\n";
// Url photo // Url photo
@ -599,8 +608,8 @@ if ($action == 'create')
// Prenom // Prenom
print '<tr><td>'.$langs->trans("Firstname").'*</td><td><input type="text" name="prenom" size="40" value="'.$adh->prenom.'"></td>'; print '<tr><td>'.$langs->trans("Firstname").'*</td><td><input type="text" name="prenom" size="40" value="'.$adh->prenom.'"></td>';
$rowspan=15; $rowspan=16;
print '<td valign="top" rowspan="'.$rowspan.'"><textarea name="comment" wrap="soft" cols="60" rows="12">'.$adh->commantaire.'</textarea></td></tr>'; print '<td valign="top" rowspan="'.$rowspan.'"><textarea name="comment" wrap="soft" cols="70" rows="14">'.$adh->commantaire.'</textarea></td></tr>';
// Login // Login
print '<tr><td>'.$langs->trans("Login").'*</td><td><input type="text" name="member_login" size="40" value="'.$adh->login.'"></td></tr>'; print '<tr><td>'.$langs->trans("Login").'*</td><td><input type="text" name="member_login" size="40" value="'.$adh->login.'"></td></tr>';
@ -637,7 +646,7 @@ if ($action == 'create')
// Pays // Pays
print '<tr><td>'.$langs->trans("Country").'</td><td>'; print '<tr><td>'.$langs->trans("Country").'</td><td>';
$htmls->select_pays($adh->pays_code?$adh->pays_code:$mysoc->pays_code,'pays_code'); $htmls->select_pays($adh->pays_id ? $adh->pays_id : $mysoc->pays_id,'pays_id');
print '</td></tr>'; print '</td></tr>';
// Tel pro // Tel pro
@ -662,6 +671,13 @@ if ($action == 'create')
foreach($adho->attribute_label as $key=>$value){ foreach($adho->attribute_label as $key=>$value){
print "<tr><td>$value</td><td><input type=\"text\" name=\"options_$key\" size=\"40\"></td></tr>\n"; print "<tr><td>$value</td><td><input type=\"text\" name=\"options_$key\" size=\"40\"></td></tr>\n";
} }
// Profil public
print "<tr><td>".$langs->trans("Public")."</td><td>\n";
$htmls->select_YesNo($adh->public);
print "</td></tr>\n";
print "</table>\n"; print "</table>\n";
print '<br>'; print '<br>';
@ -826,7 +842,7 @@ if ($rowid && $action != 'edit')
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td class="valeur">'.$adh->cp.' '.$adh->ville.'&nbsp;</td></tr>'; print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td class="valeur">'.$adh->cp.' '.$adh->ville.'&nbsp;</td></tr>';
// Pays // Pays
print '<tr><td>'.$langs->trans("Country").'</td><td class="valeur">'.$adh->pays.'</td></tr>'; print '<tr><td>'.$langs->trans("Country").'</td><td class="valeur">'.$html->pays_name($adh->pays_id).'</td></tr>';
// Tel pro. // Tel pro.
print '<tr><td>'.$langs->trans("PhonePro").'</td><td class="valeur">'.$adh->phone.'</td></tr>'; print '<tr><td>'.$langs->trans("PhonePro").'</td><td class="valeur">'.$adh->phone.'</td></tr>';
@ -847,10 +863,7 @@ if ($rowid && $action != 'edit')
print '<tr><td>URL Photo</td><td class="valeur">'.$adh->photo.'&nbsp;</td></tr>'; print '<tr><td>URL Photo</td><td class="valeur">'.$adh->photo.'&nbsp;</td></tr>';
// Public // Public
print '<tr><td>'.$langs->trans("Public").'</td><td class="valeur">'; print '<tr><td>'.$langs->trans("Public").'</td><td class="valeur">'.yn($adh->public).'</td></tr>';
if ($adh->public==1) print $langs->trans("Yes");
else print $langs->trans("No");
print '</td></tr>';
// Status // Status
print '<tr><td>'.$langs->trans("Status").'</td><td class="valeur">'.$adh->getLibStatut(4).'</td></tr>'; print '<tr><td>'.$langs->trans("Status").'</td><td class="valeur">'.$adh->getLibStatut(4).'</td></tr>';

View File

@ -147,13 +147,20 @@ if ($result > 0)
$info=$adh->_load_ldap_info(); $info=$adh->_load_ldap_info();
$dn=$adh->_load_ldap_dn($info,1); $dn=$adh->_load_ldap_dn($info,1);
$search = "(".$adh->_load_ldap_dn($info,2).")"; $search = "(".$adh->_load_ldap_dn($info,2).")";
$result=$ldap->search($dn,$search); $records=$ldap->search($dn,$search);
// Affichage arbre // Affichage arbre
if (sizeof($result)) if (sizeof($records))
{
if (! is_array($records))
{
print '<tr><td colspan="2">'.$langs->trans("ErrorFailedToReadLDAP").'</td></tr>';
}
else
{ {
$html=new Form($db); $html=new Form($db);
$html->show_ldap_content($result,0,0,true); $result=$html->show_ldap_content($records,0,0,true);
}
} }
else else
{ {

View File

@ -78,9 +78,6 @@ llxHeader();
$head = ldap_prepare_head(); $head = ldap_prepare_head();
print_fiche_titre($langs->trans("LDAPSetup"),'','setup');
// Test si fonction LDAP actives // Test si fonction LDAP actives
if (! function_exists("ldap_connect")) if (! function_exists("ldap_connect"))
{ {
@ -88,12 +85,10 @@ if (! function_exists("ldap_connect"))
} }
if ($mesg) print '<div class="error">'.$mesg.'</div>'; if ($mesg) print '<div class="error">'.$mesg.'</div>';
else print '<br>';
dolibarr_fiche_head($head, 'ldap', $langs->trans("LDAPSetup"));
dolibarr_fiche_head($head, 'ldap', $langs->trans("LDAP"));
$var=true; $var=true;
$html=new Form($db); $html=new Form($db);

View File

@ -78,9 +78,6 @@ llxHeader();
$head = ldap_prepare_head(); $head = ldap_prepare_head();
print_fiche_titre($langs->trans("LDAPSetup"),'','setup');
// Test si fonction LDAP actives // Test si fonction LDAP actives
if (! function_exists("ldap_connect")) if (! function_exists("ldap_connect"))
{ {
@ -88,10 +85,9 @@ if (! function_exists("ldap_connect"))
} }
if ($mesg) print '<div class="error">'.$mesg.'</div>'; if ($mesg) print '<div class="error">'.$mesg.'</div>';
else print '<br>';
dolibarr_fiche_head($head, 'contacts', $langs->trans("LDAP")); dolibarr_fiche_head($head, 'contacts', $langs->trans("LDAPSetup"));
print $langs->trans("LDAPDescContact").'<br>'; print $langs->trans("LDAPDescContact").'<br>';
@ -99,25 +95,35 @@ print '<br>';
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
$html=new Form($db);
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
$var=true;
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("LDAPSynchronizeUsers").'</td>'; print '<td colspan="4">'.$langs->trans("LDAPSynchronizeUsers").'</td>';
print '<td>'.$langs->trans("LDAPNamingAttribute").'</td>';
print "</tr>\n"; print "</tr>\n";
$var=true;
$html=new Form($db);
// DN Pour les contacts // DN Pour les contacts
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td><b>'.$langs->trans("LDAPContactDn").picto_required().'</b></td><td>'; print '<tr '.$bc[$var].'><td width="25%"><b>'.$langs->trans("LDAPContactDn").picto_required().'</b></td><td>';
print '<input size="48" type="text" name="contactdn" value="'.$conf->global->LDAP_CONTACT_DN.'">'; print '<input size="48" type="text" name="contactdn" value="'.$conf->global->LDAP_CONTACT_DN.'">';
print '</td><td>'.$langs->trans("LDAPContactDnExample").'</td>'; print '</td><td>'.$langs->trans("LDAPContactDnExample").'</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '</tr>'; print '</tr>';
print '</table>';
print '<br>';
print '<table class="noborder" width="100%">';
$var=true;
print '<tr class="liste_titre">';
print '<td width="25%">'.$langs->trans("LDAPDolibarrMapping").'</td>';
print '<td colspan="2">'.$langs->trans("LDAPLdapMapping").'</td>';
print '<td align="right">'.$langs->trans("LDAPNamingAttribute").'</td>';
print "</tr>\n";
// Common name // Common name
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFullname").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFullname").'</td><td>';

View File

@ -72,9 +72,6 @@ llxHeader();
$head = ldap_prepare_head(); $head = ldap_prepare_head();
print_fiche_titre($langs->trans("LDAPSetup"),'','setup');
// Test si fonction LDAP actives // Test si fonction LDAP actives
if (! function_exists("ldap_connect")) if (! function_exists("ldap_connect"))
{ {
@ -82,10 +79,9 @@ if (! function_exists("ldap_connect"))
} }
if ($mesg) print '<div class="error">'.$mesg.'</div>'; if ($mesg) print '<div class="error">'.$mesg.'</div>';
else print '<br>';
dolibarr_fiche_head($head, 'groups', $langs->trans("LDAP")); dolibarr_fiche_head($head, 'groups', $langs->trans("LDAPSetup"));
print $langs->trans("LDAPDescGroups").'<br>'; print $langs->trans("LDAPDescGroups").'<br>';
@ -94,24 +90,34 @@ print '<br>';
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
print '<table class="noborder" width="100%">';
$var=true;
$html=new Form($db); $html=new Form($db);
print '<table class="noborder" width="100%">';
$var=true;
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("LDAPSynchronizeUsers").'</td>'; print '<td colspan="4">'.$langs->trans("LDAPSynchronizeUsers").'</td>';
print '<td>'.$langs->trans("LDAPNamingAttribute").'</td>';
print "</tr>\n"; print "</tr>\n";
// DN pour les groupes // DN pour les groupes
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td><b>'.$langs->trans("LDAPGroupDn").picto_required().'</b></td><td>'; print '<tr '.$bc[$var].'><td width="25%"><b>'.$langs->trans("LDAPGroupDn").picto_required().'</b></td><td>';
print '<input size="48" type="text" name="group" value="'.$conf->global->LDAP_GROUP_DN.'">'; print '<input size="48" type="text" name="group" value="'.$conf->global->LDAP_GROUP_DN.'">';
print '</td><td>'.$langs->trans("LDAPGroupDnExample").'</td>'; print '</td><td>'.$langs->trans("LDAPGroupDnExample").'</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '</tr>'; print '</tr>';
print '</table>';
print '<br>';
print '<table class="noborder" width="100%">';
$var=true;
print '<tr class="liste_titre">';
print '<td width="25%">'.$langs->trans("LDAPDolibarrMapping").'</td>';
print '<td colspan="2">'.$langs->trans("LDAPLdapMapping").'</td>';
print '<td align="right">'.$langs->trans("LDAPNamingAttribute").'</td>';
print "</tr>\n";
// Filtre // Filtre
/* /*
$var=!$var; $var=!$var;

View File

@ -59,13 +59,15 @@ if ($_GET["action"] == 'setvalue' && $user->admin)
if (! dolibarr_set_const($db, 'LDAP_FIELD_FIRSTNAME',$_POST["fieldfirstname"])) $error++; 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_MAIL',$_POST["fieldmail"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_PHONE',$_POST["fieldphone"])) $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_PHONE_PERSO',$_POST["fieldphoneperso"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_MOBILE',$_POST["fieldmobile"])) $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_ADDRESS',$_POST["fieldaddress"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_ZIP',$_POST["fieldzip"])) $error++; if (! dolibarr_set_const($db, 'LDAP_FIELD_ZIP',$_POST["fieldzip"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_TOWN',$_POST["fieldtown"])) $error++; if (! dolibarr_set_const($db, 'LDAP_FIELD_TOWN',$_POST["fieldtown"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_COUNTRY',$_POST["fieldcountry"])) $error++; if (! dolibarr_set_const($db, 'LDAP_FIELD_COUNTRY',$_POST["fieldcountry"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_DESCRIPTION',$_POST["fielddescription"])) $error++; if (! dolibarr_set_const($db, 'LDAP_FIELD_DESCRIPTION',$_POST["fielddescription"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_BIRTHDATE',$_POST["fieldbirthdate"])) $error++;
if ($error) if ($error)
{ {
@ -83,9 +85,6 @@ llxHeader();
$head = ldap_prepare_head(); $head = ldap_prepare_head();
print_fiche_titre($langs->trans("LDAPSetup"),'','setup');
// Test si fonction LDAP actives // Test si fonction LDAP actives
if (! function_exists("ldap_connect")) if (! function_exists("ldap_connect"))
{ {
@ -93,10 +92,9 @@ if (! function_exists("ldap_connect"))
} }
if ($mesg) print '<div class="error">'.$mesg.'</div>'; if ($mesg) print '<div class="error">'.$mesg.'</div>';
else print '<br>';
dolibarr_fiche_head($head, 'members', $langs->trans("LDAP")); dolibarr_fiche_head($head, 'members', $langs->trans("LDAPSetup"));
print $langs->trans("LDAPDescMembers").'<br>'; print $langs->trans("LDAPDescMembers").'<br>';
@ -105,25 +103,35 @@ print '<br>';
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
print '<table class="noborder" width="100%">';
$var=true;
$html=new Form($db); $html=new Form($db);
print '<table class="noborder" width="100%">';
$var=true;
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("LDAPSynchronizeUsers").'</td>'; print '<td colspan="4">'.$langs->trans("LDAPSynchronizeUsers").'</td>';
print '<td>'.$langs->trans("LDAPNamingAttribute").'</td>';
print "</tr>\n"; print "</tr>\n";
// DN Pour les adherents // DN Pour les adherents
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td><b>'.$langs->trans("LDAPMemberDn").picto_required().'</b></td><td>'; print '<tr '.$bc[$var].'><td width="25%"><b>'.$langs->trans("LDAPMemberDn").picto_required().'</b></td><td>';
print '<input size="48" type="text" name="user" value="'.$conf->global->LDAP_MEMBER_DN.'">'; print '<input size="48" type="text" name="user" value="'.$conf->global->LDAP_MEMBER_DN.'">';
print '</td><td>'.$langs->trans("LDAPMemberDnExample").'</td>'; print '</td><td>'.$langs->trans("LDAPMemberDnExample").'</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '</tr>'; print '</tr>';
print '</table>';
print '<br>';
print '<table class="noborder" width="100%">';
$var=true;
print '<tr class="liste_titre">';
print '<td width="25%">'.$langs->trans("LDAPDolibarrMapping").'</td>';
print '<td colspan="2">'.$langs->trans("LDAPLdapMapping").'</td>';
print '<td align="right">'.$langs->trans("LDAPNamingAttribute").'</td>';
print "</tr>\n";
// Filtre // Filtre
/* /*
$var=!$var; $var=!$var;
@ -181,7 +189,7 @@ print '</td><td>'.$langs->trans("LDAPFieldMailExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_MAIL.'"'.($conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_MAIL?' checked="true"':'')."></td>"; print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_MAIL.'"'.($conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_MAIL?' checked="true"':'')."></td>";
print '</tr>'; print '</tr>';
// Phone // Phone pro
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldPhone").'</td><td>'; 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 '<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_FIELD_PHONE.'">';
@ -189,6 +197,14 @@ print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_PHONE.'"'.($conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_PHONE?' checked="true"':'')."></td>"; print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_PHONE.'"'.($conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_PHONE?' checked="true"':'')."></td>";
print '</tr>'; print '</tr>';
// Phone perso
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldPhonePerso").'</td><td>';
print '<input size="25" type="text" name="fieldphoneperso" value="'.$conf->global->LDAP_FIELD_PHONE_PERSO.'">';
print '</td><td>'.$langs->trans("LDAPFieldPhonePersoExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_PHONE_PERSO.'"'.($conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_PHONEHOME?' checked="true"':'')."></td>";
print '</tr>';
// Mobile // Mobile
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldMobile").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldMobile").'</td><td>';
@ -245,6 +261,14 @@ print '</td><td>'.$langs->trans("LDAPFieldDescriptionExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_DESCRIPTION.'"'.($conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_DESCRIPTION?' checked="true"':'')."></td>"; print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_DESCRIPTION.'"'.($conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_DESCRIPTION?' checked="true"':'')."></td>";
print '</tr>'; print '</tr>';
// Date naissance
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldBirthdate").'</td><td>';
print '<input size="25" type="text" name="fieldbirthdate" value="'.$conf->global->LDAP_FIELD_BIRTHDATE.'">';
print '</td><td>'.$langs->trans("LDAPFieldBirthdateExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_BIRTHDATE.'"'.($conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_BIRTHDATE?' checked="true"':'')."></td>";
print '</tr>';
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>'; print '<tr '.$bc[$var].'><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
print '</table>'; print '</table>';
@ -255,6 +279,7 @@ print '</div>';
print info_admin($langs->trans("LDAPDescValues")); print info_admin($langs->trans("LDAPDescValues"));
/* /*
* Test de la connexion * Test de la connexion
*/ */

View File

@ -80,9 +80,6 @@ llxHeader();
$head = ldap_prepare_head(); $head = ldap_prepare_head();
print_fiche_titre($langs->trans("LDAPSetup"),'','setup');
// Test si fonction LDAP actives // Test si fonction LDAP actives
if (! function_exists("ldap_connect")) if (! function_exists("ldap_connect"))
{ {
@ -90,10 +87,9 @@ if (! function_exists("ldap_connect"))
} }
if ($mesg) print '<div class="error">'.$mesg.'</div>'; if ($mesg) print '<div class="error">'.$mesg.'</div>';
else print '<br>';
dolibarr_fiche_head($head, 'users', $langs->trans("LDAP")); dolibarr_fiche_head($head, 'users', $langs->trans("LDAPSetup"));
print $langs->trans("LDAPDescUsers").'<br>'; print $langs->trans("LDAPDescUsers").'<br>';
@ -102,25 +98,35 @@ print '<br>';
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
print '<table class="noborder" width="100%">';
$var=true;
$html=new Form($db); $html=new Form($db);
print '<table class="noborder" width="100%">';
$var=true;
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("LDAPSynchronizeUsers").'</td>'; print '<td colspan="4">'.$langs->trans("LDAPSynchronizeUsers").'</td>';
print '<td>'.$langs->trans("LDAPNamingAttribute").'</td>';
print "</tr>\n"; print "</tr>\n";
// DN Pour les utilisateurs // DN Pour les utilisateurs
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td><b>'.$langs->trans("LDAPUserDn").picto_required().'</b></td><td>'; print '<tr '.$bc[$var].'><td width="25%"><b>'.$langs->trans("LDAPUserDn").picto_required().'</b></td><td>';
print '<input size="48" type="text" name="user" value="'.$conf->global->LDAP_USER_DN.'">'; print '<input size="48" type="text" name="user" value="'.$conf->global->LDAP_USER_DN.'">';
print '</td><td>'.$langs->trans("LDAPUserDnExample").'</td>'; print '</td><td>'.$langs->trans("LDAPUserDnExample").'</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '</tr>'; print '</tr>';
print '</table>';
print '<br>';
print '<table class="noborder" width="100%">';
$var=true;
print '<tr class="liste_titre">';
print '<td width="25%">'.$langs->trans("LDAPDolibarrMapping").'</td>';
print '<td colspan="2">'.$langs->trans("LDAPLdapMapping").'</td>';
print '<td align="right">'.$langs->trans("LDAPNamingAttribute").'</td>';
print "</tr>\n";
// Filtre // Filtre
/* /*
$var=!$var; $var=!$var;
@ -228,6 +234,7 @@ print '</div>';
print info_admin($langs->trans("LDAPDescValues")); print info_admin($langs->trans("LDAPDescValues"));
/* /*
* Test de la connexion * Test de la connexion
*/ */
@ -282,6 +289,7 @@ if (function_exists("ldap_connect"))
} }
} }
$db->close(); $db->close();
llxFooter('$Date$ - $Revision$'); llxFooter('$Date$ - $Revision$');

View File

@ -316,17 +316,18 @@ class Form
$sql.= " WHERE active = 1"; $sql.= " WHERE active = 1";
$sql.= " ORDER BY code ASC;"; $sql.= " ORDER BY code ASC;";
if ($this->db->query($sql)) $resql=$this->db->query($sql);
if ($resql)
{ {
print '<select class="flat" name="'.$htmlname.'" '.$htmloption.'>'; print '<select class="flat" name="'.$htmlname.'" '.$htmloption.'>';
$num = $this->db->num_rows(); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
if ($num) if ($num)
{ {
$foundselected=false; $foundselected=false;
while ($i < $num) while ($i < $num)
{ {
$obj = $this->db->fetch_object(); $obj = $this->db->fetch_object($resql);
if ($selected && $selected != '-1' && ($selected == $obj->rowid || $selected == $obj->code)) if ($selected && $selected != '-1' && ($selected == $obj->rowid || $selected == $obj->code))
{ {
$foundselected=true; $foundselected=true;
@ -1085,7 +1086,7 @@ class Form
* \param selected Id présélectionné * \param selected Id présélectionné
* \param htmlname Nom de la zone select * \param htmlname Nom de la zone select
*/ */
function select_YesNo($selected='',$htmlname='') function select_YesNo($selected='',$htmlname='yesno')
{ {
global $langs; global $langs;
print '<select class="flat" name="'.$htmlname.'">'; print '<select class="flat" name="'.$htmlname.'">';
@ -2722,7 +2723,8 @@ class Form
global $bc; global $bc;
$count++; $count++;
if ($count > 1000) return; // To avoid infinite loop if ($count > 1000) return -1; // To avoid infinite loop
if (! is_array($result)) return -1;
foreach($result as $key => $val) foreach($result as $key => $val)
{ {

View File

@ -554,6 +554,8 @@ LDAPConnectToDNSuccessfull=Connection au DN (%s) r
LDAPConnectToDNFailed=Connection au DN (%s) échouée LDAPConnectToDNFailed=Connection au DN (%s) échouée
LDAPSetupForVersion3=LDAP server configured for version 3 LDAPSetupForVersion3=LDAP server configured for version 3
LDAPSetupForVersion2=LDAP server configured for version 2 LDAPSetupForVersion2=LDAP server configured for version 2
LDAPDolibarrMapping=Dolibarr Mapping
LDAPLdapMapping=LDAP Mapping
LDAPFieldLoginUnix=Login (unix) LDAPFieldLoginUnix=Login (unix)
LDAPFieldLoginExample=Example : uid LDAPFieldLoginExample=Example : uid
LDAPFilterConnection=Search filter LDAPFilterConnection=Search filter
@ -570,12 +572,14 @@ LDAPFieldFirstName=Firstname
LDAPFieldFirstNameExample=Example : givenname LDAPFieldFirstNameExample=Example : givenname
LDAPFieldMail=Email address LDAPFieldMail=Email address
LDAPFieldMailExample=Example : mail LDAPFieldMailExample=Example : mail
LDAPFieldPhone=Phone number LDAPFieldPhone=Professional phone number
LDAPFieldPhoneExample=Example : telephonenumber LDAPFieldPhoneExample=Example : telephonenumber
LDAPFieldFax=Fax number LDAPFieldPhonePerso=Personal phone number
LDAPFieldFaxExample=Example : facsimiletelephonenumber LDAPFieldPhonePersoExample=Example : homephone
LDAPFieldMobile=Cellular phone LDAPFieldMobile=Cellular phone
LDAPFieldMobileExample=Example : mobile LDAPFieldMobileExample=Example : mobile
LDAPFieldFax=Fax number
LDAPFieldFaxExample=Example : facsimiletelephonenumber
LDAPFieldAddress=Street LDAPFieldAddress=Street
LDAPFieldAddressExample=Example : street LDAPFieldAddressExample=Example : street
LDAPFieldZip=Zip LDAPFieldZip=Zip
@ -586,6 +590,8 @@ LDAPFieldCountry=Country
LDAPFieldCountryExample=Example : LDAPFieldCountryExample=Example :
LDAPFieldDescription=Description LDAPFieldDescription=Description
LDAPFieldDescriptionExample=Example : description LDAPFieldDescriptionExample=Example : description
LDAPFieldBirthdate=Birthdate
LDAPFieldBirthdateExample=Exemple :
LDAPFieldSid=SID LDAPFieldSid=SID
LDAPFieldSidExample=Example : objectsid LDAPFieldSidExample=Example : objectsid
LDAPParametersAreStillHardCoded=LDAP parametres are still hardcoded (in contact class) LDAPParametersAreStillHardCoded=LDAP parametres are still hardcoded (in contact class)

View File

@ -18,7 +18,7 @@ ErrorGoToModuleSetup=Go to Module setup to fix this
ErrorFailedToSendMail=Failed to send mail (sender=%s, receiver=%s) ErrorFailedToSendMail=Failed to send mail (sender=%s, receiver=%s)
ErrorAttachedFilesDisabled=Attaching files feature is disabled on this serveur ErrorAttachedFilesDisabled=Attaching files feature is disabled on this serveur
ErrorFileNotUploaded=File was not uploaded ErrorFileNotUploaded=File was not uploaded
ErrorInternalErrorDetected=Internal error detected ErrorInternalErrorDetected=Error detected
ErrorNoRequestRan=No request ran ErrorNoRequestRan=No request ran
ErrorWrongHostParameter=Wrong host parameter ErrorWrongHostParameter=Wrong host parameter
ErrorYourCountryIsNotDefined=Your country is not defined. Go to Home-Setup-Edit and post again the form. ErrorYourCountryIsNotDefined=Your country is not defined. Go to Home-Setup-Edit and post again the form.

View File

@ -18,7 +18,7 @@ ErrorGoToModuleSetup=Allez dans la Configuration du module pour corriger
ErrorFailedToSendMail=Échec de l'envoi du mail (emetteur=%s, destinataire=%s) ErrorFailedToSendMail=Échec de l'envoi du mail (emetteur=%s, destinataire=%s)
ErrorAttachedFilesDisabled=La gestion des fichiers associés est désactivée sur ce serveur ErrorAttachedFilesDisabled=La gestion des fichiers associés est désactivée sur ce serveur
ErrorFileNotUploaded=Le fichier n'a pas été transféré ErrorFileNotUploaded=Le fichier n'a pas été transféré
ErrorInternalErrorDetected=Erreur interne détectée ErrorInternalErrorDetected=Erreur detectee
ErrorNoRequestRan=Aucune requête exécutée ErrorNoRequestRan=Aucune requête exécutée
ErrorWrongHostParameter=Mauvais paramètre Serveur ErrorWrongHostParameter=Mauvais paramètre Serveur
ErrorYourCountryIsNotDefined=Votre pays n'est pas défini. Corriger en allant dans Configuration-Général-Editer. ErrorYourCountryIsNotDefined=Votre pays n'est pas défini. Corriger en allant dans Configuration-Général-Editer.

View File

@ -554,6 +554,8 @@ LDAPConnectToDNSuccessfull=Connection au DN (%s) r
LDAPConnectToDNFailed=Connection au DN (%s) échouée LDAPConnectToDNFailed=Connection au DN (%s) échouée
LDAPSetupForVersion3=Serveur LDAP configuré en version 3 LDAPSetupForVersion3=Serveur LDAP configuré en version 3
LDAPSetupForVersion2=Serveur LDAP configuré en version 2 LDAPSetupForVersion2=Serveur LDAP configuré en version 2
LDAPDolibarrMapping=Mapping Dolibarr
LDAPLdapMapping=Mapping LDAP
LDAPFieldLoginUnix=Login (unix) LDAPFieldLoginUnix=Login (unix)
LDAPFieldLoginExample=Exemple : uid LDAPFieldLoginExample=Exemple : uid
LDAPFilterConnection=Filtre de recherche LDAPFilterConnection=Filtre de recherche
@ -570,12 +572,14 @@ LDAPFieldFirstName=Pr
LDAPFieldFirstNameExample=Exemple : givenname LDAPFieldFirstNameExample=Exemple : givenname
LDAPFieldMail=Email LDAPFieldMail=Email
LDAPFieldMailExample=Exemple : mail LDAPFieldMailExample=Exemple : mail
LDAPFieldPhone=Téléphone LDAPFieldPhone=Téléphone professionnel
LDAPFieldPhoneExample=Exemple : telephonenumber LDAPFieldPhoneExample=Exemple : telephonenumber
LDAPFieldFax=Fax LDAPFieldPhonePerso=Téléphone perso
LDAPFieldFaxExample=Exemple : facsimiletelephonenumber LDAPFieldPhonePersoExample=Exemple : homephone
LDAPFieldMobile=Téléphone portable LDAPFieldMobile=Téléphone portable
LDAPFieldMobileExample=Exemple : mobile LDAPFieldMobileExample=Exemple : mobile
LDAPFieldFax=Fax
LDAPFieldFaxExample=Exemple : facsimiletelephonenumber
LDAPFieldAddress=Adresse LDAPFieldAddress=Adresse
LDAPFieldAddressExample=Exemple : street LDAPFieldAddressExample=Exemple : street
LDAPFieldZip=Code postal LDAPFieldZip=Code postal
@ -586,6 +590,8 @@ LDAPFieldCountry=Pays
LDAPFieldCountryExample=Exemple : LDAPFieldCountryExample=Exemple :
LDAPFieldDescription=Description LDAPFieldDescription=Description
LDAPFieldDescriptionExample=Exemple : description LDAPFieldDescriptionExample=Exemple : description
LDAPFieldBirthdate=Date de naissance
LDAPFieldBirthdateExample=Exemple :
LDAPFieldSid=SID LDAPFieldSid=SID
LDAPFieldSidExample=Exemple : objectsid LDAPFieldSidExample=Exemple : objectsid
LDAPParametersAreStillHardCoded=Les parametres LDAP sont codés en dur (dans classe contact) LDAPParametersAreStillHardCoded=Les parametres LDAP sont codés en dur (dans classe contact)

View File

@ -18,7 +18,7 @@ ErrorGoToModuleSetup=Allez dans la Configuration du module pour corriger
ErrorFailedToSendMail=Échec de l'envoi du mail (emetteur=%s, destinataire=%s) ErrorFailedToSendMail=Échec de l'envoi du mail (emetteur=%s, destinataire=%s)
ErrorAttachedFilesDisabled=La gestion des fichiers associés est désactivée sur ce serveur ErrorAttachedFilesDisabled=La gestion des fichiers associés est désactivée sur ce serveur
ErrorFileNotUploaded=Le fichier n'a pas été transféré ErrorFileNotUploaded=Le fichier n'a pas été transféré
ErrorInternalErrorDetected=Erreur interne détectée ErrorInternalErrorDetected=Erreur detectee
ErrorNoRequestRan=Aucune requête exécutée ErrorNoRequestRan=Aucune requête exécutée
ErrorWrongHostParameter=Mauvais paramètre Serveur ErrorWrongHostParameter=Mauvais paramètre Serveur
ErrorYourCountryIsNotDefined=Votre pays n'est pas défini. Corriger en allant dans Configuration-Général-Editer. ErrorYourCountryIsNotDefined=Votre pays n'est pas défini. Corriger en allant dans Configuration-Général-Editer.

View File

@ -491,7 +491,7 @@ function dolibarr_time_plus_duree($time,$duration_value,$duration_unit)
\param time Date 'timestamp' ou format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS' \param time Date 'timestamp' ou format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS'
\param format Format d'affichage de la date \param format Format d'affichage de la date
"%d %b %Y", "%d %b %Y",
"%d/%m/%Y %h:%M:%s", "%d/%m/%Y %H:%M:%S",
"day", "daytext", "dayhour", "dayhourtext" "day", "daytext", "dayhour", "dayhourtext"
\return string Date formatée ou '' si time null \return string Date formatée ou '' si time null
*/ */
@ -538,6 +538,20 @@ function dolibarr_print_date($time,$format='')
} }
/**
\brief Retourne une date fabriqué depuis une chaine
\param string Date formatée en chaine (YYYYMMDD ou YYYYMMDDHHMMSS)
\return date Date
*/
function dolibarr_mktime($string)
{
$string=eregi_replace('[^0-9]','',$string);
$tmp=$string.'000000'; // Si date YYYYMMDD
$date=mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4));
return $date;
}
/** /**
\brief Affiche les informations d'un objet \brief Affiche les informations d'un objet
\param object objet a afficher \param object objet a afficher
@ -1240,7 +1254,7 @@ function accessforbidden($message='')
*/ */
function dolibarr_print_error($db='',$msg='') function dolibarr_print_error($db='',$msg='')
{ {
global $langs; global $langs,$argv;
$syslog = ''; $syslog = '';
// Si erreur intervenue avant chargement langue // Si erreur intervenue avant chargement langue
@ -1267,7 +1281,7 @@ function dolibarr_print_error($db='',$msg='')
else // Mode CLI else // Mode CLI
{ {
print $langs->trans("ErrorInternalErrorDetected")."\n"; print $langs->trans("ErrorInternalErrorDetected").": ".$argv[0]."\n";
$syslog.="pid=".getmypid(); $syslog.="pid=".getmypid();
} }
@ -1293,7 +1307,8 @@ function dolibarr_print_error($db='',$msg='')
$syslog.=", db_error=".$db->error(); $syslog.=", db_error=".$db->error();
} }
if ($msg) { if ($msg)
{
if ($_SERVER['DOCUMENT_ROOT']) // Mode web if ($_SERVER['DOCUMENT_ROOT']) // Mode web
{ {
print "<b>".$langs->trans("Message").":</b> ".$msg."<br>\n" ; print "<b>".$langs->trans("Message").":</b> ".$msg."<br>\n" ;

View File

@ -608,9 +608,17 @@ class Ldap
//print_r($info); //print_r($info);
$result=@ldap_add($this->connection, $dn, $info); $result=@ldap_add($this->connection, $dn, $info);
if ($result) return 1; if ($result)
{
dolibarr_syslog("Ldap.class::add successfull");
return 1;
}
else
{
dolibarr_syslog("Ldap.class::add failed");
return -1; return -1;
} }
}
/* /*
* \brief Delete a LDAP entry * \brief Delete a LDAP entry

View File

@ -49,6 +49,7 @@ $path=eregi_replace($script_file,'',$_SERVER["PHP_SELF"]);
require_once($path."../../htdocs/master.inc.php"); require_once($path."../../htdocs/master.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/ldap.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/ldap.class.php");
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php");
require_once(DOL_DOCUMENT_ROOT."/adherents/cotisation.class.php");
$error=0; $error=0;
@ -66,6 +67,38 @@ if (! $conf->global->LDAP_MEMBER_ACTIVE)
} }
*/ */
// Charge tableau de correspondance des pays
$hashlib2rowid=array();
$countries=array();
$sql = "SELECT rowid, code, libelle, active";
$sql.= " FROM ".MAIN_DB_PREFIX."c_pays";
$sql.= " WHERE active = 1";
$sql.= " ORDER BY code ASC;";
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
if ($num)
{
while ($i < $num)
{
$obj = $db->fetch_object($resql);
if ($obj)
{
//print 'Load cache for country '.strtolower($obj->libelle).' rowid='.$obj->rowid."\n";
$hashlib2rowid[strtolower($obj->libelle)]=$obj->rowid;
$countries[$obj->rowid]=array('rowid' => $obj->rowid, 'label' => $obj->libelle, 'code' => $obj->code);
}
$i++;
}
}
}
else
{
dolibarr_print_error($db);
exit;
}
$ldap = new Ldap(); $ldap = new Ldap();
$result = $ldap->connect_bind(); $result = $ldap->connect_bind();
@ -73,6 +106,9 @@ if ($result >= 0)
{ {
$justthese=array(); $justthese=array();
print 'DN='.$conf->global->LDAP_MEMBER_DN."\n";
print 'Filter=('.$conf->global->LDAP_KEY_MEMBERS.'=*)'."\n";
$ldaprecords = $ldap->search($conf->global->LDAP_MEMBER_DN, '('.$conf->global->LDAP_KEY_MEMBERS.'=*)'); $ldaprecords = $ldap->search($conf->global->LDAP_MEMBER_DN, '('.$conf->global->LDAP_KEY_MEMBERS.'=*)');
if (is_array($ldaprecords)) if (is_array($ldaprecords))
{ {
@ -88,53 +124,79 @@ if ($result >= 0)
$member->prenom=$ldapuser[$conf->global->LDAP_FIELD_FIRSTNAME][0]; $member->prenom=$ldapuser[$conf->global->LDAP_FIELD_FIRSTNAME][0];
$member->nom=$ldapuser[$conf->global->LDAP_FIELD_NAME][0]; $member->nom=$ldapuser[$conf->global->LDAP_FIELD_NAME][0];
$member->fullname=($ldapuser[$conf->global->LDAP_FIELD_FULLNAME][0] ? $ldapuser[$conf->global->LDAP_FIELD_FULLNAME][0] : trim($member->prenom." ".$member->nom)); $member->fullname=($ldapuser[$conf->global->LDAP_FIELD_FULLNAME][0] ? $ldapuser[$conf->global->LDAP_FIELD_FULLNAME][0] : trim($member->prenom." ".$member->nom));
//$member->societe;
//$member->adresse=$ldapuser[$conf->global->LDAP_FIELD_FULLNAME]
//$member->cp;
//$member->ville;
//$member->pays_id;
//$member->pays_code;
//$member->pays;
//$member->morphy;
$member->email=$ldapuser[$conf->global->LDAP_FIELD_EMAIL][0];
//$member->public;
//$member->commentaire;
$member->statut=-1;
$member->login=$ldapuser[$conf->global->LDAP_FIELD_LOGIN][0]; $member->login=$ldapuser[$conf->global->LDAP_FIELD_LOGIN][0];
//$member->pass; //$member->pass;
//$member->naiss;
//$member->societe;
$member->adresse=$ldapuser[$conf->global->LDAP_FIELD_ADDRESS][0];
$member->cp=$ldapuser[$conf->global->LDAP_FIELD_ZIP][0];
$member->ville=$ldapuser[$conf->global->LDAP_FIELD_TOWN][0];
$member->pays=$ldapuser[$conf->global->LDAP_FIELD_COUNTRY][0]; // Pays en libelle
$member->pays_id=$countries[$hashlib2rowid[strtolower($member->pays)]]['rowid'];
$member->pays_code=$countries[$hashlib2rowid[strtolower($member->pays)]]['code'];
$member->phone=$ldapuser[$conf->global->LDAP_FIELD_PHONE][0];
$member->phone_perso=$ldapuser[$conf->global->LDAP_FIELD_PHONE_PERSO][0];
$member->phone_mobile=$ldapuser[$conf->global->LDAP_FIELD_MOBILE][0];
$member->email=$ldapuser[$conf->global->LDAP_FIELD_MAIL][0];
$member->naiss=dolibarr_mktime($ldapuser[$conf->global->LDAP_FIELD_BIRTHDATE][0]);
$member->commentaire=$ldapuser[$conf->global->LDAP_FIELD_DESCRIPTION][0];
$member->morphy='phy';
//$member->photo; //$member->photo;
$member->public=1;
$member->statut=-1; // Par defaut, statut brouillon
if (isset($ldapuser["prnxstatus"][0])) $member->statut=($ldapuser["prnxstatus"][0]==1 ? 1 : 0);
// Propriete type membre // Propriete type membre
$member->typeid=$typeid; $member->typeid=$typeid;
// Creation membre
//---------------------------- print $langs->trans("MemberCreate").' no '.$key.': '.$member->fullname;
// YOUR OWN RULES HERE $member_id=$member->create();
//---------------------------- if ($member_id > 0)
{
print ' --> '.$member_id;
}
//---------------------------- else
// END {
//----------------------------
print $langs->trans("MemberCreate").' no '.$key.': '.$member->fullname."\n";
print_r($member);
exit;
// $member->create();
$error++; $error++;
print ' --> '.$member->error;
}
print "\n";
//print_r($member);
//----------------------------
// YOUR OWN CODE HERE
//----------------------------
$datefirst=dolibarr_mktime($ldapuser["prnxfirtscontribution"][0]);
$datelast=dolibarr_mktime($ldapuser["prnxlastcontribution"][0]);
if ($datefirst)
{
$crowid=$member->cotisation($datefirst, 0, 0, $operation, $label, $num_chq);
}
if ($datelast)
{
$price=price2num($ldapuser["prnxlastcontributionprice"][0]);
$crowid=$member->cotisation($datelast, $price, 0, $operation, $label, $num_chq);
}
//----------------------------
// END OF OWN CODE HERE
//----------------------------
} }
if (! $error) if (! $error)
{ {
print $langs->trans("NoErrorCommitIsDone")."\n";
$db->commit(); $db->commit();
} }
else else
{ {
print $langs->trans("SommeErrorWereFoundRollbackIsDone",$error)."\n";
$db->rollback(); $db->rollback();
} }
} }