Script d'import ldap2dolibarr des adhrents 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,22 +81,21 @@ class Adherent
var $error;
/**
\brief Adherent
\param DB base de données
\param id id de l'adhérent
*/
function Adherent($DB, $id='')
{
$this->db = $DB ;
$this->id = $id;
$this->statut = -1;
// l'adherent n'est pas public par defaut
$this->public = 0;
// les champs optionnels sont vides
$this->array_options=array();
}
/**
\brief Adherent
\param DB base de données
\param id id de l'adhérent
*/
function Adherent($DB)
{
$this->db = $DB ;
$this->statut = -1;
// l'adherent n'est pas public par defaut
$this->public = 0;
// les champs optionnels sont vides
$this->array_options=array();
}
/**
@ -328,31 +327,42 @@ class Adherent
global $conf,$langs,$user;
// 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);
return -1;
}
$this->date = $this->db->idate($this->date);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent (datec)";
$sql .= " VALUES (now())";
// Insertion membre
$sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent (datec,login)";
$sql.= " VALUES (now(),'".$this->login."')";
dolibarr_syslog("Adherent.class::create sql=".$sql);
$result = $this->db->query($sql);
if ($result)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent");
$result=$this->update($user,1);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('MEMBER_CREATE',$this,$user,$langs,$conf);
if ($result < 0) $error++;
// Fin appel triggers
return $this->id;
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent");
if ($id > 0)
{
$this->id=$id;
// Mise a jour
$result=$this->update($user,1);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('MEMBER_CREATE',$this,$user,$langs,$conf);
if ($result < 0) $error++;
// Fin appel triggers
return $this->id;
}
else
{
dolibarr_print_error($this->db,'Failed to get last insert id');
return -1;
}
}
else
{
@ -388,16 +398,16 @@ class Adherent
$sql .= ",login='" .$this->login."'";
$sql .= ",pass='" .$this->pass."'";
$sql .= ",societe='".$this->societe."'";
$sql .= ",adresse='".$this->adresse."'";
$sql .= ",adresse=" .($this->adresse?"'".addslashes($this->adresse)."'":"null");
$sql .= ",cp='" .$this->cp."'";
$sql .= ",ville='" .$this->ville."'";
$sql .= ",pays='" .$this->pays_code."'";
$sql .= ",pays='" .$this->pays_id."'";
$sql .= ",email='" .$this->email."'";
$sql .= ",phone=" .($this->phone?"'".addslashes($this->phone)."'":"null");
$sql .= ",phone_perso=" .($this->phone_perso?"'".addslashes($this->phone_perso)."'":"null");
$sql .= ",phone_mobile=" .($this->phone_mobile?"'".addslashes($this->phone_mobile)."'":"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 .= ",public='" .$this->public."'";
$sql .= ",statut=" .$this->statut;
@ -466,37 +476,48 @@ class Adherent
function delete($rowid)
{
global $conf, $langs;
$result = 0;
// Suppression options
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_options WHERE adhid = ".$rowid;
if ( $this->db->query($sql) )
{
if ( $this->db->affected_rows() )
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."cotisation WHERE fk_adherent = ".$rowid;
if ($this->db->query( $sql))
{
}
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent WHERE rowid = ".$rowid;
dolibarr_syslog("Adherent.class::delete");
if ( $this->db->query($sql) )
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;
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;
dolibarr_syslog("Adherent.class::delete sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->affected_rows($resql))
{
if ( $this->db->affected_rows() )
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('CONTACT_DELETE',$this,$user,$langs,$conf);
if ($result < 0) $error++;
// Fin appel triggers
}
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('MEMBER_DELETE',$this,$user,$langs,$conf);
if ($result < 0) $error++;
// Fin appel triggers
}
}
else
{
dolibarr_print_error($this->db);
return -1;
}
}
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.= " 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.= " ".$this->db->pdate("d.datefin")." as datefin,";
$sql.= " d.pays, p.rowid as pays_id, p.code as pays_code, p.libelle as pays_lib,";
$sql.= " ".$this->db->pdate("d.datefin")." as datefin, d.pays,";
$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.= " 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";
@ -583,7 +604,6 @@ class Adherent
$this->photo = $obj->photo;
$this->statut = $obj->statut;
$this->public = $obj->public;
$this->date = $obj->datedon;
$this->datefin = $obj->datefin;
$this->commentaire = $obj->note;
$this->morphy = $obj->morphy;
@ -680,30 +700,35 @@ class Adherent
/**
\brief Fonction qui insère la cotisation dans la base de données
et eventuellement liens dans banques, mailman, etc...
\param date Date cotisation
\param montant Montant cotisation
\return int rowid de l'entrée ajoutée, <0 si erreur
\param date Date 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
*/
function cotisation($date, $montant, $accountid, $operation, $label, $num_chq)
{
global $conf,$langs,$user;
dolibarr_syslog("Adherent.class::cotisation $date, $montant, $accountid, $operation, $label, $num_chq");
$this->db->begin();
$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);
if ($result)
{
$rowid=$this->db->last_insert_id(MAIN_DB_PREFIX."cotisation");
// datefin = date + 1 an
$datefin = mktime(12, 0 , 0, strftime("%m",$date), strftime("%d",$date),
strftime("%Y",$date)+1) - (24 * 3600);
$datefin = dolibarr_time_plus_duree($date,1,'y');
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET datefin = ".$this->db->idate($datefin);
$sql.= " WHERE rowid =". $this->id;
dolibarr_syslog("Adherent.class::cotisation sql=".$sql);
$resql=$this->db->query( $sql);
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->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->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->email && $conf->global->LDAP_FIELD_MAIL) $info[$conf->global->LDAP_FIELD_MAIL] = $this->email;
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->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->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;
}

View File

@ -43,6 +43,7 @@ $langs->load("users");
$user->getrights('adherent');
$adh = new Adherent($db);
$adho = new AdherentOptions($db);
$errmsg='';
@ -58,7 +59,6 @@ $typeid=isset($_GET["typeid"])?$_GET["typeid"]:$_POST["typeid"];
if ($_POST["action"] == 'confirm_sendinfo' && $_POST["confirm"] == 'yes')
{
$adh = new Adherent($db);
$adh->id = $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");
@ -66,7 +66,6 @@ if ($_POST["action"] == 'confirm_sendinfo' && $_POST["confirm"] == 'yes')
if ($_POST["action"] == 'cotisation')
{
$adh = new Adherent($db);
$adh->id = $rowid;
$adh->fetch($rowid);
@ -122,9 +121,13 @@ if ($_REQUEST["action"] == 'update')
{
if ($_POST["bouton"] == $langs->trans("Save"))
{
$datenaiss=mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
$adh = new Adherent($db);
$datenaiss='';
if (isset($_POST["naissday"]) && $_POST["naissday"]
&& isset($_POST["naissmonth"])
&& isset($_POST["naissyear"]) && $_POST["naissyear"])
{
$datenaiss=@mktime(12, 0 , 0, $_POST["naissmonth"], $_POST["naissday"], $_POST["naissyear"]);
}
$adh->id = $_POST["rowid"];
$adh->prenom = $_POST["prenom"];
@ -137,14 +140,14 @@ if ($_REQUEST["action"] == 'update')
$adh->adresse = $_POST["adresse"];
$adh->cp = $_POST["cp"];
$adh->ville = $_POST["ville"];
$adh->pays = $_POST["pays"];
$adh->pays_id = $_POST["pays"];
$adh->phone = $_POST["phone"];
$adh->phone_perso = $_POST["phone_perso"];
$adh->phone_mobile= $_POST["phone_mobile"];
$adh->email = $_POST["email"];
$adh->naiss = $_POST["naiss"];
$adh->date = $adh->naiss;
$adh->naiss = $datenaiss;
$adh->date = $datenaiss; // A virer
$adh->photo = $_POST["photo"];
$adh->typeid = $_POST["type"];
@ -189,12 +192,12 @@ if ($_POST["action"] == 'add')
&& isset($_POST["naissmonth"])
&& 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='';
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"];
@ -204,7 +207,7 @@ if ($_POST["action"] == 'add')
$adresse=$_POST["adresse"];
$cp=$_POST["cp"];
$ville=$_POST["ville"];
$pays_code=$_POST["pays_code"];
$pays_id=$_POST["pays_id"];
$phone=$_POST["phone"];
$phone_perso=$_POST["phone_perso"];
@ -217,14 +220,13 @@ if ($_POST["action"] == 'add')
$morphy=$_POST["morphy"];
$cotisation=$_POST["cotisation"];
$adh = new Adherent($db);
$adh->prenom = $prenom;
$adh->nom = $nom;
$adh->societe = $societe;
$adh->adresse = $adresse;
$adh->cp = $cp;
$adh->ville = $ville;
$adh->pays_code = $pays_code;
$adh->pays_id = $pays_id;
$adh->phone = $phone;
$adh->phone_perso = $phone_perso;
$adh->phone_mobile= $phone_mobile;
@ -333,16 +335,22 @@ if ($_POST["action"] == 'add')
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes')
{
$adh = new Adherent($db);
$adh->delete($rowid);
Header("Location: liste.php");
exit;
$result=$adh->delete($rowid);
if ($result > 0)
{
Header("Location: liste.php");
exit;
}
else
{
$mesg=$adh->error;
}
}
if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes')
{
$adh = new Adherent($db, $rowid);
$adh->rowid=$rowid;
$adh->validate($user->id);
$adh->fetch($rowid);
@ -369,7 +377,7 @@ if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes')
if ($_POST["action"] == 'confirm_resign' && $_POST["confirm"] == 'yes')
{
$adh = new Adherent($db, $rowid);
$adh->rowid=$rowid;
$adh->resiliate($user->id);
$adh->fetch($rowid);
@ -388,7 +396,7 @@ if ($_POST["action"] == 'confirm_resign' && $_POST["confirm"] == 'yes')
if ($_POST["action"] == 'confirm_add_glasnost' && $_POST["confirm"] == 'yes')
{
$adh = new Adherent($db, $rowid);
$adh->rowid=$rowid;
$adh->fetch($rowid);
$adht = new AdherentType($db);
$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')
{
$adh = new Adherent($db, $rowid);
$adh->rowid=$rowid;
$adh->fetch($rowid);
$adht = new AdherentType($db);
$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')
{
$adh = new Adherent($db, $rowid);
$adh->rowid=$rowid;
$adh->fetch($rowid);
if(!$adh->del_to_spip()){
$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')
{
$adh = new Adherent($db, $rowid);
$adh->rowid=$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";
}
}
@ -556,7 +565,7 @@ if ($action == 'edit')
// Date naissance
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";
// Url photo
@ -599,8 +608,8 @@ if ($action == 'create')
// Prenom
print '<tr><td>'.$langs->trans("Firstname").'*</td><td><input type="text" name="prenom" size="40" value="'.$adh->prenom.'"></td>';
$rowspan=15;
print '<td valign="top" rowspan="'.$rowspan.'"><textarea name="comment" wrap="soft" cols="60" rows="12">'.$adh->commantaire.'</textarea></td></tr>';
$rowspan=16;
print '<td valign="top" rowspan="'.$rowspan.'"><textarea name="comment" wrap="soft" cols="70" rows="14">'.$adh->commantaire.'</textarea></td></tr>';
// Login
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
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>';
// Tel pro
@ -662,6 +671,13 @@ if ($action == 'create')
foreach($adho->attribute_label as $key=>$value){
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 '<br>';
@ -824,9 +840,9 @@ if ($rowid && $action != 'edit')
// CP / Ville
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td class="valeur">'.$adh->cp.' '.$adh->ville.'&nbsp;</td></tr>';
// 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.
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>';
// Public
print '<tr><td>'.$langs->trans("Public").'</td><td class="valeur">';
if ($adh->public==1) print $langs->trans("Yes");
else print $langs->trans("No");
print '</td></tr>';
print '<tr><td>'.$langs->trans("Public").'</td><td class="valeur">'.yn($adh->public).'</td></tr>';
// Status
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();
$dn=$adh->_load_ldap_dn($info,1);
$search = "(".$adh->_load_ldap_dn($info,2).")";
$result=$ldap->search($dn,$search);
$records=$ldap->search($dn,$search);
// Affichage arbre
if (sizeof($result))
if (sizeof($records))
{
$html=new Form($db);
$html->show_ldap_content($result,0,0,true);
if (! is_array($records))
{
print '<tr><td colspan="2">'.$langs->trans("ErrorFailedToReadLDAP").'</td></tr>';
}
else
{
$html=new Form($db);
$result=$html->show_ldap_content($records,0,0,true);
}
}
else
{

View File

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

View File

@ -78,9 +78,6 @@ llxHeader();
$head = ldap_prepare_head();
print_fiche_titre($langs->trans("LDAPSetup"),'','setup');
// Test si fonction LDAP actives
if (! function_exists("ldap_connect"))
{
@ -88,10 +85,9 @@ if (! function_exists("ldap_connect"))
}
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>';
@ -99,25 +95,35 @@ print '<br>';
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("LDAPSynchronizeUsers").'</td>';
print '<td>'.$langs->trans("LDAPNamingAttribute").'</td>';
print "</tr>\n";
$var=true;
$html=new Form($db);
print '<table class="noborder" width="100%">';
$var=true;
print '<tr class="liste_titre">';
print '<td colspan="4">'.$langs->trans("LDAPSynchronizeUsers").'</td>';
print "</tr>\n";
// DN Pour les contacts
$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 '</td><td>'.$langs->trans("LDAPContactDnExample").'</td>';
print '<td>&nbsp;</td>';
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
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFullname").'</td><td>';

View File

@ -72,9 +72,6 @@ llxHeader();
$head = ldap_prepare_head();
print_fiche_titre($langs->trans("LDAPSetup"),'','setup');
// Test si fonction LDAP actives
if (! function_exists("ldap_connect"))
{
@ -82,10 +79,9 @@ if (! function_exists("ldap_connect"))
}
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>';
@ -94,24 +90,34 @@ print '<br>';
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
print '<table class="noborder" width="100%">';
$var=true;
$html=new Form($db);
print '<table class="noborder" width="100%">';
$var=true;
print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("LDAPSynchronizeUsers").'</td>';
print '<td>'.$langs->trans("LDAPNamingAttribute").'</td>';
print '<td colspan="4">'.$langs->trans("LDAPSynchronizeUsers").'</td>';
print "</tr>\n";
// DN pour les groupes
$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 '</td><td>'.$langs->trans("LDAPGroupDnExample").'</td>';
print '<td>&nbsp;</td>';
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
/*
$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_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_PHONE_PERSO',$_POST["fieldphoneperso"])) $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 (! 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_BIRTHDATE',$_POST["fieldbirthdate"])) $error++;
if ($error)
{
@ -83,9 +85,6 @@ llxHeader();
$head = ldap_prepare_head();
print_fiche_titre($langs->trans("LDAPSetup"),'','setup');
// Test si fonction LDAP actives
if (! function_exists("ldap_connect"))
{
@ -93,10 +92,9 @@ if (! function_exists("ldap_connect"))
}
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>';
@ -105,25 +103,35 @@ print '<br>';
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
print '<table class="noborder" width="100%">';
$var=true;
$html=new Form($db);
print '<table class="noborder" width="100%">';
$var=true;
print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("LDAPSynchronizeUsers").'</td>';
print '<td>'.$langs->trans("LDAPNamingAttribute").'</td>';
print '<td colspan="4">'.$langs->trans("LDAPSynchronizeUsers").'</td>';
print "</tr>\n";
// DN Pour les adherents
$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 '</td><td>'.$langs->trans("LDAPMemberDnExample").'</td>';
print '<td>&nbsp;</td>';
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
/*
$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 '</tr>';
// Phone
// Phone pro
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldPhone").'</td><td>';
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 '</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
$var=!$var;
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 '</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;
print '<tr '.$bc[$var].'><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
print '</table>';
@ -255,6 +279,7 @@ print '</div>';
print info_admin($langs->trans("LDAPDescValues"));
/*
* Test de la connexion
*/

View File

@ -80,9 +80,6 @@ llxHeader();
$head = ldap_prepare_head();
print_fiche_titre($langs->trans("LDAPSetup"),'','setup');
// Test si fonction LDAP actives
if (! function_exists("ldap_connect"))
{
@ -90,10 +87,9 @@ if (! function_exists("ldap_connect"))
}
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>';
@ -102,25 +98,35 @@ print '<br>';
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
print '<table class="noborder" width="100%">';
$var=true;
$html=new Form($db);
print '<table class="noborder" width="100%">';
$var=true;
print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("LDAPSynchronizeUsers").'</td>';
print '<td>'.$langs->trans("LDAPNamingAttribute").'</td>';
print '<td colspan="4">'.$langs->trans("LDAPSynchronizeUsers").'</td>';
print "</tr>\n";
// DN Pour les utilisateurs
$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 '</td><td>'.$langs->trans("LDAPUserDnExample").'</td>';
print '<td>&nbsp;</td>';
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
/*
$var=!$var;
@ -228,6 +234,7 @@ print '</div>';
print info_admin($langs->trans("LDAPDescValues"));
/*
* Test de la connexion
*/
@ -282,6 +289,7 @@ if (function_exists("ldap_connect"))
}
}
$db->close();
llxFooter('$Date$ - $Revision$');

View File

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

View File

@ -554,6 +554,8 @@ LDAPConnectToDNSuccessfull=Connection au DN (%s) r
LDAPConnectToDNFailed=Connection au DN (%s) échouée
LDAPSetupForVersion3=LDAP server configured for version 3
LDAPSetupForVersion2=LDAP server configured for version 2
LDAPDolibarrMapping=Dolibarr Mapping
LDAPLdapMapping=LDAP Mapping
LDAPFieldLoginUnix=Login (unix)
LDAPFieldLoginExample=Example : uid
LDAPFilterConnection=Search filter
@ -570,12 +572,14 @@ LDAPFieldFirstName=Firstname
LDAPFieldFirstNameExample=Example : givenname
LDAPFieldMail=Email address
LDAPFieldMailExample=Example : mail
LDAPFieldPhone=Phone number
LDAPFieldPhone=Professional phone number
LDAPFieldPhoneExample=Example : telephonenumber
LDAPFieldFax=Fax number
LDAPFieldFaxExample=Example : facsimiletelephonenumber
LDAPFieldPhonePerso=Personal phone number
LDAPFieldPhonePersoExample=Example : homephone
LDAPFieldMobile=Cellular phone
LDAPFieldMobileExample=Example : mobile
LDAPFieldFax=Fax number
LDAPFieldFaxExample=Example : facsimiletelephonenumber
LDAPFieldAddress=Street
LDAPFieldAddressExample=Example : street
LDAPFieldZip=Zip
@ -586,6 +590,8 @@ LDAPFieldCountry=Country
LDAPFieldCountryExample=Example :
LDAPFieldDescription=Description
LDAPFieldDescriptionExample=Example : description
LDAPFieldBirthdate=Birthdate
LDAPFieldBirthdateExample=Exemple :
LDAPFieldSid=SID
LDAPFieldSidExample=Example : objectsid
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)
ErrorAttachedFilesDisabled=Attaching files feature is disabled on this serveur
ErrorFileNotUploaded=File was not uploaded
ErrorInternalErrorDetected=Internal error detected
ErrorInternalErrorDetected=Error detected
ErrorNoRequestRan=No request ran
ErrorWrongHostParameter=Wrong host parameter
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)
ErrorAttachedFilesDisabled=La gestion des fichiers associés est désactivée sur ce serveur
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
ErrorWrongHostParameter=Mauvais paramètre Serveur
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
LDAPSetupForVersion3=Serveur LDAP configuré en version 3
LDAPSetupForVersion2=Serveur LDAP configuré en version 2
LDAPDolibarrMapping=Mapping Dolibarr
LDAPLdapMapping=Mapping LDAP
LDAPFieldLoginUnix=Login (unix)
LDAPFieldLoginExample=Exemple : uid
LDAPFilterConnection=Filtre de recherche
@ -570,12 +572,14 @@ LDAPFieldFirstName=Pr
LDAPFieldFirstNameExample=Exemple : givenname
LDAPFieldMail=Email
LDAPFieldMailExample=Exemple : mail
LDAPFieldPhone=Téléphone
LDAPFieldPhone=Téléphone professionnel
LDAPFieldPhoneExample=Exemple : telephonenumber
LDAPFieldFax=Fax
LDAPFieldFaxExample=Exemple : facsimiletelephonenumber
LDAPFieldPhonePerso=Téléphone perso
LDAPFieldPhonePersoExample=Exemple : homephone
LDAPFieldMobile=Téléphone portable
LDAPFieldMobileExample=Exemple : mobile
LDAPFieldFax=Fax
LDAPFieldFaxExample=Exemple : facsimiletelephonenumber
LDAPFieldAddress=Adresse
LDAPFieldAddressExample=Exemple : street
LDAPFieldZip=Code postal
@ -586,6 +590,8 @@ LDAPFieldCountry=Pays
LDAPFieldCountryExample=Exemple :
LDAPFieldDescription=Description
LDAPFieldDescriptionExample=Exemple : description
LDAPFieldBirthdate=Date de naissance
LDAPFieldBirthdateExample=Exemple :
LDAPFieldSid=SID
LDAPFieldSidExample=Exemple : objectsid
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)
ErrorAttachedFilesDisabled=La gestion des fichiers associés est désactivée sur ce serveur
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
ErrorWrongHostParameter=Mauvais paramètre Serveur
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 format Format d'affichage de la date
"%d %b %Y",
"%d/%m/%Y %h:%M:%s",
"%d/%m/%Y %H:%M:%S",
"day", "daytext", "dayhour", "dayhourtext"
\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
\param object objet a afficher
@ -1240,7 +1254,7 @@ function accessforbidden($message='')
*/
function dolibarr_print_error($db='',$msg='')
{
global $langs;
global $langs,$argv;
$syslog = '';
// Si erreur intervenue avant chargement langue
@ -1267,7 +1281,7 @@ function dolibarr_print_error($db='',$msg='')
else // Mode CLI
{
print $langs->trans("ErrorInternalErrorDetected")."\n";
print $langs->trans("ErrorInternalErrorDetected").": ".$argv[0]."\n";
$syslog.="pid=".getmypid();
}
@ -1293,7 +1307,8 @@ function dolibarr_print_error($db='',$msg='')
$syslog.=", db_error=".$db->error();
}
if ($msg) {
if ($msg)
{
if ($_SERVER['DOCUMENT_ROOT']) // Mode web
{
print "<b>".$langs->trans("Message").":</b> ".$msg."<br>\n" ;

View File

@ -608,8 +608,16 @@ class Ldap
//print_r($info);
$result=@ldap_add($this->connection, $dn, $info);
if ($result) return 1;
return -1;
if ($result)
{
dolibarr_syslog("Ldap.class::add successfull");
return 1;
}
else
{
dolibarr_syslog("Ldap.class::add failed");
return -1;
}
}
/*

View File

@ -49,6 +49,7 @@ $path=eregi_replace($script_file,'',$_SERVER["PHP_SELF"]);
require_once($path."../../htdocs/master.inc.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/cotisation.class.php");
$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();
$result = $ldap->connect_bind();
@ -73,6 +106,9 @@ if ($result >= 0)
{
$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.'=*)');
if (is_array($ldaprecords))
{
@ -81,60 +117,86 @@ if ($result >= 0)
foreach ($ldaprecords as $key => $ldapuser)
{
if ($key == 'count') continue;
$member = new Adherent($db);
// Propriete membre
$member->prenom=$ldapuser[$conf->global->LDAP_FIELD_FIRSTNAME][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->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->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->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
$member->typeid=$typeid;
// Creation membre
print $langs->trans("MemberCreate").' no '.$key.': '.$member->fullname;
$member_id=$member->create();
if ($member_id > 0)
{
print ' --> '.$member_id;
}
else
{
$error++;
print ' --> '.$member->error;
}
print "\n";
//print_r($member);
//----------------------------
// YOUR OWN RULES HERE
// 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
// END OF OWN CODE HERE
//----------------------------
print $langs->trans("MemberCreate").' no '.$key.': '.$member->fullname."\n";
print_r($member);
exit;
// $member->create();
$error++;
}
if (! $error)
{
print $langs->trans("NoErrorCommitIsDone")."\n";
$db->commit();
}
else
{
print $langs->trans("SommeErrorWereFoundRollbackIsDone",$error)."\n";
$db->rollback();
}
}