From 11d9bf5848b2eba8713c0889f6525f1fcadace03 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 26 Nov 2006 07:00:14 +0000 Subject: [PATCH] =?UTF-8?q?Script=20d'import=20ldap2dolibarr=20des=20adh?= =?UTF-8?q?=E9rents=20est=20ok?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/adherents/adherent.class.php | 168 ++++++++++-------- htdocs/adherents/fiche.php | 81 +++++---- htdocs/adherents/ldap.php | 15 +- htdocs/admin/ldap.php | 7 +- htdocs/admin/ldap_contacts.php | 34 ++-- htdocs/admin/ldap_groups.php | 28 +-- htdocs/admin/ldap_members.php | 51 ++++-- htdocs/admin/ldap_users.php | 28 +-- htdocs/html.form.class.php | 14 +- htdocs/langs/en_US/admin.lang | 12 +- htdocs/langs/en_US/main.lang | 2 +- htdocs/langs/fr_BE/main.lang | 2 +- htdocs/langs/fr_FR/admin.lang | 12 +- htdocs/langs/fr_FR/main.lang | 2 +- htdocs/lib/functions.inc.php | 23 ++- htdocs/lib/ldap.class.php | 12 +- .../adherents/sync_member_ldap2dolibarr.php | 114 +++++++++--- 17 files changed, 395 insertions(+), 210 deletions(-) diff --git a/htdocs/adherents/adherent.class.php b/htdocs/adherents/adherent.class.php index 60794b17164..1e2f5d21ea4 100644 --- a/htdocs/adherents/adherent.class.php +++ b/htdocs/adherents/adherent.class.php @@ -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; } diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index 6d9ed5da733..bb4ca9eeb24 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -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."
\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."
\n"; } } @@ -556,7 +565,7 @@ if ($action == 'edit') // Date naissance print "".$langs->trans("Birthday")."\n"; - $htmls->select_date(-1,'naiss','','',1,'update'); + $htmls->select_date(($adh->naiss ? $adh->naiss : -1),'naiss','','',1,'update'); print "\n"; // Url photo @@ -599,8 +608,8 @@ if ($action == 'create') // Prenom print ''.$langs->trans("Firstname").'*'; - $rowspan=15; - print ''; + $rowspan=16; + print ''; // Login print ''.$langs->trans("Login").'*'; @@ -637,7 +646,7 @@ if ($action == 'create') // Pays print ''.$langs->trans("Country").''; - $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 ''; // Tel pro @@ -662,6 +671,13 @@ if ($action == 'create') foreach($adho->attribute_label as $key=>$value){ print "$value\n"; } + + // Profil public + print "".$langs->trans("Public")."\n"; + $htmls->select_YesNo($adh->public); + print "\n"; + + print "\n"; print '
'; @@ -824,9 +840,9 @@ if ($rowid && $action != 'edit') // CP / Ville print ''.$langs->trans("Zip").' / '.$langs->trans("Town").''.$adh->cp.' '.$adh->ville.' '; - + // Pays - print ''.$langs->trans("Country").''.$adh->pays.''; + print ''.$langs->trans("Country").''.$html->pays_name($adh->pays_id).''; // Tel pro. print ''.$langs->trans("PhonePro").''.$adh->phone.''; @@ -847,10 +863,7 @@ if ($rowid && $action != 'edit') print 'URL Photo'.$adh->photo.' '; // Public - print ''.$langs->trans("Public").''; - if ($adh->public==1) print $langs->trans("Yes"); - else print $langs->trans("No"); - print ''; + print ''.$langs->trans("Public").''.yn($adh->public).''; // Status print ''.$langs->trans("Status").''.$adh->getLibStatut(4).''; diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php index ab9a3b35010..46914a01d9d 100644 --- a/htdocs/adherents/ldap.php +++ b/htdocs/adherents/ldap.php @@ -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 ''.$langs->trans("ErrorFailedToReadLDAP").''; + } + else + { + $html=new Form($db); + $result=$html->show_ldap_content($records,0,0,true); + } } else { diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php index 5b5967be20d..82a4fe53216 100644 --- a/htdocs/admin/ldap.php +++ b/htdocs/admin/ldap.php @@ -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 '
'.$mesg.'
'; -else print '
'; - -dolibarr_fiche_head($head, 'ldap', $langs->trans("LDAP")); +dolibarr_fiche_head($head, 'ldap', $langs->trans("LDAPSetup")); $var=true; $html=new Form($db); diff --git a/htdocs/admin/ldap_contacts.php b/htdocs/admin/ldap_contacts.php index 2bb0c04371b..76c2e0db762 100644 --- a/htdocs/admin/ldap_contacts.php +++ b/htdocs/admin/ldap_contacts.php @@ -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 '
'.$mesg.'
'; -else print '
'; -dolibarr_fiche_head($head, 'contacts', $langs->trans("LDAP")); +dolibarr_fiche_head($head, 'contacts', $langs->trans("LDAPSetup")); print $langs->trans("LDAPDescContact").'
'; @@ -99,25 +95,35 @@ print '
'; print '
'; -print ''; - -print ''; -print ''; -print ''; -print "\n"; - -$var=true; $html=new Form($db); +print '
'.$langs->trans("LDAPSynchronizeUsers").''.$langs->trans("LDAPNamingAttribute").'
'; +$var=true; + +print ''; +print ''; +print "\n"; + // DN Pour les contacts $var=!$var; -print ''; print ''; print ''; +print '
'.$langs->trans("LDAPSynchronizeUsers").'
'.$langs->trans("LDAPContactDn").picto_required().''; +print '
'.$langs->trans("LDAPContactDn").picto_required().''; print ''; print ''.$langs->trans("LDAPContactDnExample").' 
'; +print '
'; +print ''; +$var=true; + +print ''; +print ''; +print ''; +print ''; +print "\n"; + // Common name $var=!$var; print '
'.$langs->trans("LDAPDolibarrMapping").''.$langs->trans("LDAPLdapMapping").''.$langs->trans("LDAPNamingAttribute").'
'.$langs->trans("LDAPFieldFullname").''; diff --git a/htdocs/admin/ldap_groups.php b/htdocs/admin/ldap_groups.php index cde2bfa0aa5..1734006e7ef 100644 --- a/htdocs/admin/ldap_groups.php +++ b/htdocs/admin/ldap_groups.php @@ -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 '
'.$mesg.'
'; -else print '
'; -dolibarr_fiche_head($head, 'groups', $langs->trans("LDAP")); +dolibarr_fiche_head($head, 'groups', $langs->trans("LDAPSetup")); print $langs->trans("LDAPDescGroups").'
'; @@ -94,24 +90,34 @@ print '
'; print ''; -print ''; - -$var=true; $html=new Form($db); +print '
'; +$var=true; + print ''; -print ''; -print ''; +print ''; print "\n"; // DN pour les groupes $var=!$var; -print ''; print ''; print ''; +print '
'.$langs->trans("LDAPSynchronizeUsers").''.$langs->trans("LDAPNamingAttribute").''.$langs->trans("LDAPSynchronizeUsers").'
'.$langs->trans("LDAPGroupDn").picto_required().''; +print '
'.$langs->trans("LDAPGroupDn").picto_required().''; print ''; print ''.$langs->trans("LDAPGroupDnExample").' 
'; +print '
'; +print ''; +$var=true; + +print ''; +print ''; +print ''; +print ''; +print "\n"; + // Filtre /* $var=!$var; diff --git a/htdocs/admin/ldap_members.php b/htdocs/admin/ldap_members.php index 40400f125a5..6c1b4ab60e9 100644 --- a/htdocs/admin/ldap_members.php +++ b/htdocs/admin/ldap_members.php @@ -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 '
'.$mesg.'
'; -else print '
'; -dolibarr_fiche_head($head, 'members', $langs->trans("LDAP")); +dolibarr_fiche_head($head, 'members', $langs->trans("LDAPSetup")); print $langs->trans("LDAPDescMembers").'
'; @@ -105,25 +103,35 @@ print '
'; print ''; -print '
'.$langs->trans("LDAPDolibarrMapping").''.$langs->trans("LDAPLdapMapping").''.$langs->trans("LDAPNamingAttribute").'
'; - -$var=true; $html=new Form($db); +print '
'; +$var=true; + print ''; -print ''; -print ''; +print ''; print "\n"; // DN Pour les adherents $var=!$var; -print ''; print ''; print ''; +print '
'.$langs->trans("LDAPSynchronizeUsers").''.$langs->trans("LDAPNamingAttribute").''.$langs->trans("LDAPSynchronizeUsers").'
'.$langs->trans("LDAPMemberDn").picto_required().''; +print '
'.$langs->trans("LDAPMemberDn").picto_required().''; print ''; print ''.$langs->trans("LDAPMemberDnExample").' 
'; +print '
'; +print ''; +$var=true; + +print ''; +print ''; +print ''; +print ''; +print "\n"; + // Filtre /* $var=!$var; @@ -181,7 +189,7 @@ print ''; print '"; print ''; -// Phone +// Phone pro $var=!$var; print ''; print '"; print ''; +// Phone perso +$var=!$var; +print ''; +print '"; +print ''; + // Mobile $var=!$var; print ''; print '"; print ''; +// Date naissance +$var=!$var; +print ''; +print '"; +print ''; + $var=!$var; print ''; print '
'.$langs->trans("LDAPDolibarrMapping").''.$langs->trans("LDAPLdapMapping").''.$langs->trans("LDAPNamingAttribute").'
'.$langs->trans("LDAPFieldMailExample").'global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_MAIL?' checked="true"':'').">
'.$langs->trans("LDAPFieldPhone").''; print ''; @@ -189,6 +197,14 @@ print ''.$langs->trans("LDAPFieldPhoneExample").'global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_PHONE?' checked="true"':'').">
'.$langs->trans("LDAPFieldPhonePerso").''; +print ''; +print ''.$langs->trans("LDAPFieldPhonePersoExample").'global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_PHONEHOME?' checked="true"':'').">
'.$langs->trans("LDAPFieldMobile").''; @@ -245,6 +261,14 @@ print ''.$langs->trans("LDAPFieldDescriptionExample").'global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_DESCRIPTION?' checked="true"':'').">
'.$langs->trans("LDAPFieldBirthdate").''; +print ''; +print ''.$langs->trans("LDAPFieldBirthdateExample").'global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_BIRTHDATE?' checked="true"':'').">
'; @@ -255,6 +279,7 @@ print ''; print info_admin($langs->trans("LDAPDescValues")); + /* * Test de la connexion */ diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php index fcb8f077ef8..83f4e1d53aa 100644 --- a/htdocs/admin/ldap_users.php +++ b/htdocs/admin/ldap_users.php @@ -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 '
'.$mesg.'
'; -else print '
'; -dolibarr_fiche_head($head, 'users', $langs->trans("LDAP")); +dolibarr_fiche_head($head, 'users', $langs->trans("LDAPSetup")); print $langs->trans("LDAPDescUsers").'
'; @@ -102,25 +98,35 @@ print '
'; print ''; -print ''; -$var=true; $html=new Form($db); +print '
'; +$var=true; print ''; -print ''; -print ''; +print ''; print "\n"; // DN Pour les utilisateurs $var=!$var; -print ''; print ''; print ''; +print '
'.$langs->trans("LDAPSynchronizeUsers").''.$langs->trans("LDAPNamingAttribute").''.$langs->trans("LDAPSynchronizeUsers").'
'.$langs->trans("LDAPUserDn").picto_required().''; +print '
'.$langs->trans("LDAPUserDn").picto_required().''; print ''; print ''.$langs->trans("LDAPUserDnExample").' 
'; +print '
'; +print ''; +$var=true; + +print ''; +print ''; +print ''; +print ''; +print "\n"; + // Filtre /* $var=!$var; @@ -228,6 +234,7 @@ print ''; print info_admin($langs->trans("LDAPDescValues")); + /* * Test de la connexion */ @@ -282,6 +289,7 @@ if (function_exists("ldap_connect")) } } + $db->close(); llxFooter('$Date$ - $Revision$'); diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index b5a5b2e7703..f55254df286 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -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 ''; @@ -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; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index c9767ecf7f9..16de1ced8ca 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -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) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 6ba481b570d..3abbca2179c 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -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. diff --git a/htdocs/langs/fr_BE/main.lang b/htdocs/langs/fr_BE/main.lang index 63555df343c..3293cd59ae6 100644 --- a/htdocs/langs/fr_BE/main.lang +++ b/htdocs/langs/fr_BE/main.lang @@ -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. diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index bca901442f8..149a12c5879 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -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) diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 67fd36fc424..6f109b3b3b0 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -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. diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index 90c10f41b62..71538684e54 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -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 "".$langs->trans("Message").": ".$msg."
\n" ; diff --git a/htdocs/lib/ldap.class.php b/htdocs/lib/ldap.class.php index 5f51611fa31..a2872c867b3 100644 --- a/htdocs/lib/ldap.class.php +++ b/htdocs/lib/ldap.class.php @@ -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; + } } /* diff --git a/scripts/adherents/sync_member_ldap2dolibarr.php b/scripts/adherents/sync_member_ldap2dolibarr.php index e9e84553d64..49f0c8bedf0 100644 --- a/scripts/adherents/sync_member_ldap2dolibarr.php +++ b/scripts/adherents/sync_member_ldap2dolibarr.php @@ -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(); } }
'.$langs->trans("LDAPDolibarrMapping").''.$langs->trans("LDAPLdapMapping").''.$langs->trans("LDAPNamingAttribute").'