diff --git a/htdocs/adherents/adherent.class.php b/htdocs/adherents/adherent.class.php index 49dc2d46c99..60794b17164 100644 --- a/htdocs/adherents/adherent.class.php +++ b/htdocs/adherents/adherent.class.php @@ -50,6 +50,8 @@ class Adherent var $prenom; var $nom; var $fullname; + var $login; + var $pass; var $societe; var $adresse; var $cp; @@ -57,18 +59,21 @@ class Adherent var $pays_id; var $pays_code; var $pays; - var $morphy; + var $email; + var $phone; + var $phone_perso; + var $phone_mobile; + + var $morphy; var $public; var $commentaire; - var $statut; - var $login; - var $pass; + var $statut; // -1=brouillon, 0=résilié, 1=validé,payé var $naiss; var $photo; var $typeid; // Id type adherent - var $type; // Libellé type adherent + var $type; // Libellé type adherent var $need_subscription; // var $public; @@ -95,7 +100,7 @@ class Adherent /** - \brief function envoyant un email au destinataire (recipient) avec le text fourni en parametre. + \brief Fonction envoyant un email au destinataire (recipient) avec le text fourni en parametre. \param recipients destinataires \param text contenu du message \param subject sujet du message @@ -338,7 +343,7 @@ class Adherent if ($result) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent"); - $result=$this->update(1); + $result=$this->update($user,1); // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); @@ -362,9 +367,9 @@ class Adherent \param notrigger 1=désactive le trigger UPDATE (quand appelé par creation) \return int <0 si KO, >0 si OK */ - function update($notrigger=0) + function update($user,$notrigger=0) { - global $conf,$langs,$user; + global $conf,$langs; dolibarr_syslog("Adherent.class::update $notrigger"); @@ -380,21 +385,24 @@ class Adherent $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; $sql .= " prenom = '".$this->prenom ."'"; $sql .= ",nom='" .$this->nom."'"; + $sql .= ",login='" .$this->login."'"; + $sql .= ",pass='" .$this->pass."'"; $sql .= ",societe='".$this->societe."'"; $sql .= ",adresse='".$this->adresse."'"; $sql .= ",cp='" .$this->cp."'"; $sql .= ",ville='" .$this->ville."'"; $sql .= ",pays='" .$this->pays_code."'"; - $sql .= ",note='" .$this->commentaire."'"; $sql .= ",email='" .$this->email."'"; - $sql .= ",login='" .$this->login."'"; - $sql .= ",pass='" .$this->pass."'"; - $sql .= ",naiss=" .($this->naiss?"'".$this->naiss."'":"null"); + $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 .= ",photo=" .($this->photo?"'".$this->photo."'":"null"); $sql .= ",public='" .$this->public."'"; $sql .= ",statut=" .$this->statut; $sql .= ",fk_adherent_type=".$this->typeid; - $sql .= ",morphy='".$this->morphy."'"; + $sql .= ",morphy='" .$this->morphy."'"; $sql .= " WHERE rowid = ".$this->id; dolibarr_syslog("Adherent::update sql=$sql"); @@ -500,30 +508,29 @@ class Adherent } -/** - \brief Fonction qui récupére l'adhérent en donnant son login - \param login login de l'adhérent -*/ - + /** + * \brief Fonction qui récupére l'adhérent en donnant son login + * \param login login de l'adhérent + */ function fetch_login($login) - { - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent WHERE login='$login' LIMIT 1"; - - $result=$this->db->query( $sql); - - if ($result) - { - if ($this->db->num_rows()) - { - $obj = $this->db->fetch_object($result); - $this->fetch($obj->rowid); - } - } - else - { - dolibarr_print_error($this->db); - } - } + { + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent WHERE login='$login' LIMIT 1"; + + $result=$this->db->query( $sql); + + if ($result) + { + if ($this->db->num_rows()) + { + $obj = $this->db->fetch_object($result); + $this->fetch($obj->rowid); + } + } + else + { + dolibarr_print_error($this->db); + } + } /** @@ -535,7 +542,9 @@ class Adherent { global $langs; - $sql = "SELECT d.rowid, d.prenom, d.nom, d.societe, d.statut, d.public, d.adresse, d.cp, d.ville, d.note, d.email, d.login, d.pass, d.naiss, d.photo, d.fk_adherent_type, d.morphy,"; + $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.= " t.libelle as type, t.cotisation as cotisation"; @@ -552,12 +561,11 @@ class Adherent $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; - $this->statut = $obj->statut; - $this->public = $obj->public; - $this->date = $obj->datedon; $this->prenom = $obj->prenom; $this->nom = $obj->nom; $this->fullname = trim($obj->nom.' '.$obj->prenom); + $this->login = $obj->login; + $this->pass = $obj->pass; $this->societe = $obj->societe; $this->adresse = $obj->adresse; $this->cp = $obj->cp; @@ -567,11 +575,15 @@ class Adherent if ($langs->trans("Country".$obj->pays_code) != "Country".$obj->pays_code) $this->pays = $langs->trans("Country".$obj->pays_code); elseif ($obj->pays_lib) $this->pays=$obj->pays_lib; else $this->pays=$obj->pays; + $this->phone = $obj->phone; + $this->phone_perso = $obj->phone_perso; + $this->phone_mobile = $obj->phone_mobile; $this->email = $obj->email; - $this->login = $obj->login; - $this->pass = $obj->pass; $this->naiss = $obj->naiss; $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; @@ -1614,10 +1626,11 @@ class Adherent // Initialise paramètres $this->id=0; $this->specimen=1; - $this->fullname = 'DOLIBARR SPECIMEN'; $this->nom = 'DOLIBARR'; $this->prenom = 'SPECIMEN'; $this->fullname=trim($this->nom.' '.$this->prenom); + $this->login='dolibspec'; + $this->pass='dolibspec'; $this->societe = 'Societe ABC'; $this->adresse = '61 jump street'; $this->cp = '75000'; @@ -1625,15 +1638,16 @@ class Adherent $this->pays_id = 1; $this->pays_code = 'FR'; $this->pays = 'France'; - $this->moraphy = 1; + $this->morphy = 1; $this->email = 'specimen@specimen.com'; - $this->public=1; + $this->phone = '0999999999'; + $this->phone_perso = '0999999998'; + $this->phone_mobile = '0999999997'; $this->commentaire='No comment'; - $this->statut=1; - $this->login='dolibspec'; - $this->pass='dolibspec'; $this->naiss=time(); $this->photo=''; + $this->public=1; + $this->statut=1; $this->typeid=1; // Id type adherent $this->type='Type adherent'; // Libellé type adherent @@ -1687,19 +1701,20 @@ class Adherent // Champs if ($this->fullname && $conf->global->LDAP_FIELD_FULLNAME) $info[$conf->global->LDAP_FIELD_FULLNAME] = $this->fullname; - if ($this->nom && $conf->global->LDAP_FIELD_NAME) $info[$conf->global->LDAP_FIELD_NAME] = $this->nom; + if ($this->nom && $conf->global->LDAP_FIELD_NAME) $info[$conf->global->LDAP_FIELD_NAME] = $this->nom; if ($this->prenom && $conf->global->LDAP_FIELD_FIRSTNAME) $info[$conf->global->LDAP_FIELD_FIRSTNAME] = $this->prenom; - if ($this->login && $conf->global->LDAP_FIELD_LOGIN) $info[$conf->global->LDAP_FIELD_LOGIN] = $this->login; - if ($this->poste) $info["title"] = $this->poste; - if ($this->address && $conf->global->LDAP_FIELD_ADDRESS) $info[$conf->global->LDAP_FIELD_ADDRESS] = $this->address; - if ($this->cp && $conf->global->LDAP_FIELD_ZIP) $info[$conf->global->LDAP_FIELD_ZIP] = $this->cp; - if ($this->ville && $conf->global->LDAP_FIELD_TOWN) $info[$conf->global->LDAP_FIELD_TOWN] = $this->ville; - if ($this->phone_pro && $conf->global->LDAP_FIELD_PHONE) $info[$conf->global->LDAP_FIELD_PHONE] = $this->phone_pro; + if ($this->login && $conf->global->LDAP_FIELD_LOGIN) $info[$conf->global->LDAP_FIELD_LOGIN] = $this->login; + if ($this->poste && $conf->global->LDAP_FIELD_TITLE) $info[$conf->global->LDAP_FIELD_TITLE] = $this->poste; + if ($this->address && $conf->global->LDAP_FIELD_ADDRESS) $info[$conf->global->LDAP_FIELD_ADDRESS] = $this->address; + if ($this->cp && $conf->global->LDAP_FIELD_ZIP) $info[$conf->global->LDAP_FIELD_ZIP] = $this->cp; + if ($this->ville && $conf->global->LDAP_FIELD_TOWN) $info[$conf->global->LDAP_FIELD_TOWN] = $this->ville; + if ($this->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->phone_mobile && $conf->global->LDAP_FIELD_MOBILE) $info[$conf->global->LDAP_FIELD_MOBILE] = $this->phone_mobile; - if ($this->fax && $conf->global->LDAP_FIELD_FAX) $info[$conf->global->LDAP_FIELD_FAX] = $this->fax; - if ($this->note && $conf->global->LDAP_FIELD_DESCRIPTION) $info[$conf->global->LDAP_FIELD_DESCRIPTION] = $this->note; - if ($this->email && $conf->global->LDAP_FIELD_MAIL) $info[$conf->global->LDAP_FIELD_MAIL] = $this->email; + 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; return $info; } diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index d0da4e278ee..6d9ed5da733 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -129,22 +129,30 @@ if ($_REQUEST["action"] == 'update') $adh->id = $_POST["rowid"]; $adh->prenom = $_POST["prenom"]; $adh->nom = $_POST["nom"]; - $adh->societe = $_POST["societe"]; - $adh->adresse = $_POST["adresse"]; - $adh->amount = $_POST["amount"]; - $adh->cp = $_POST["cp"]; - $adh->ville = $_POST["ville"]; - $adh->email = $_POST["email"]; + $adh->fullname = trim($adh->prenom.' '.$adh->nom); $adh->login = $_POST["login"]; $adh->pass = $_POST["pass"]; - $adh->naiss = $_POST["naiss"]; - $adh->photo = $_POST["photo"]; - $adh->date = $datenaiss; - $adh->note = $_POST["note"]; + + $adh->societe = $_POST["societe"]; + $adh->adresse = $_POST["adresse"]; + $adh->cp = $_POST["cp"]; + $adh->ville = $_POST["ville"]; $adh->pays = $_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->photo = $_POST["photo"]; + $adh->typeid = $_POST["type"]; $adh->commentaire = $_POST["comment"]; $adh->morphy = $_POST["morphy"]; + + $adh->amount = $_POST["amount"]; + // recuperation du statut et public $adh->statut = $_POST["statut"]; $adh->public = $_POST["public"]; @@ -156,7 +164,7 @@ if ($_REQUEST["action"] == 'update') $adh->array_options[$key]=$_POST[$key]; } } - if ($adh->update(0) >= 0) + if ($adh->update($user,0) >= 0) { Header("Location: fiche.php?rowid=".$adh->id); exit; @@ -197,11 +205,14 @@ if ($_POST["action"] == 'add') $cp=$_POST["cp"]; $ville=$_POST["ville"]; $pays_code=$_POST["pays_code"]; + + $phone=$_POST["phone"]; + $phone_perso=$_POST["phone_perso"]; + $phone_mobile=$_POST["phone_mobile"]; $email=$_POST["member_email"]; $login=$_POST["member_login"]; $pass=$_POST["member_pass"]; $photo=$_POST["photo"]; - $note=$_POST["note"]; $comment=$_POST["comment"]; $morphy=$_POST["morphy"]; $cotisation=$_POST["cotisation"]; @@ -214,12 +225,14 @@ if ($_POST["action"] == 'add') $adh->cp = $cp; $adh->ville = $ville; $adh->pays_code = $pays_code; + $adh->phone = $phone; + $adh->phone_perso = $phone_perso; + $adh->phone_mobile= $phone_mobile; $adh->email = $email; $adh->login = $login; $adh->pass = $pass; $adh->naiss = $datenaiss; $adh->photo = $photo; - $adh->note = $note; $adh->typeid = $type; $adh->commentaire = $comment; $adh->morphy = $morphy; @@ -482,17 +495,26 @@ if ($action == 'edit') print "public."\">"; $htmls = new Form($db); + + // Ref + print ''.$langs->trans("Ref").''.$adh->id.' '; // Nom print ''.$langs->trans("Name").''; - print ''.$langs->trans("Comments").''; + print ''.$langs->trans("Notes").''; // Prenom print ''.$langs->trans("Firstname").''; - $rowspan=13; + $rowspan=16; print ''; print ''; + // Login + print ''.$langs->trans("Login").''; + + // Password + print ''.$langs->trans("Password").''; + // Type print ''.$langs->trans("Type").''; $htmls->select_array("type", $adht->liste_array(), $adh->typeid); @@ -511,14 +533,27 @@ if ($action == 'edit') // Adresse print ''.$langs->trans("Address").''; print ''; + + // Cp print ''.$langs->trans("Zip").'/'.$langs->trans("Town").' '; + + // Pays print ''.$langs->trans("Country").''; $htmls->select_pays($adh->pays_code?$adh->pays_code:$mysoc->pays_code,'pays'); print ''; - print ''.$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'*':'').''; - print ''.$langs->trans("Login").''; - print ''.$langs->trans("Password").''; + + // Tel + print ''.$langs->trans("PhonePro").''; + // Tel perso + print ''.$langs->trans("PhonePerso").''; + + // Tel mobile + print ''.$langs->trans("PhoneMobile").''; + + // EMail + print ''.$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'*':'').''; + // Date naissance print "".$langs->trans("Birthday")."\n"; $htmls->select_date(-1,'naiss','','',1,'update'); @@ -560,18 +595,18 @@ if ($action == 'create') // Nom print ''.$langs->trans("Lastname").'*'; - print ''.$langs->trans("Comments").' :'; + print ''.$langs->trans("Notes").' :'; // Prenom print ''.$langs->trans("Firstname").'*'; - $rowspan=12; - print ''; + $rowspan=15; + print ''; // Login print ''.$langs->trans("Login").'*'; // Mot de pass - print ''.$langs->trans("Password").'*'; + print ''.$langs->trans("Password").'*'; // Type print ''.$langs->trans("MemberType").'*'; @@ -595,22 +630,31 @@ if ($action == 'create') // Adresse print ''.$langs->trans("Address").''; - print ''; + print ''; - // CP + // CP / Ville print ''.$langs->trans("Zip").' / '.$langs->trans("Town").' '; - // Ville + // Pays print ''.$langs->trans("Country").''; $htmls->select_pays($adh->pays_code?$adh->pays_code:$mysoc->pays_code,'pays_code'); print ''; + // Tel pro + print ''.$langs->trans("PhonePro").''; + + // Tel perso + print ''.$langs->trans("PhonePerso").''; + + // Tel mobile + print ''.$langs->trans("PhoneMobile").''; + // EMail print ''.$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'*':'').''; // Date naissance print "".$langs->trans("Birthday")."\n"; - $htmls->select_date(-1,'naiss','','',1,'add'); + $htmls->select_date(($adh->naiss ? $adh->naiss : -1),'naiss','','',1,'add'); print "\n"; // Url photo @@ -756,7 +800,7 @@ if ($rowid && $action != 'edit') // Nom print ''.$langs->trans("Lastname").'*'.$adh->nom.' '; - print ''.$langs->trans("Comments").''; + print ''.$langs->trans("Notes").''; // Prenom print ''.$langs->trans("Firstname").'*'.$adh->prenom.' '; @@ -768,22 +812,50 @@ if ($rowid && $action != 'edit') // Type print ''.$langs->trans("Type").'*'.$adh->type."\n"; + + // Morphy print ''.$langs->trans("Person").''.$adh->getmorphylib().''; + // Tiers print ''.$langs->trans("Company").''.$adh->societe.' '; + + // Adresse print ''.$langs->trans("Address").''.nl2br($adh->adresse).' '; + + // CP / Ville print ''.$langs->trans("Zip").' / '.$langs->trans("Town").''.$adh->cp.' '.$adh->ville.' '; + + // Pays print ''.$langs->trans("Country").''.$adh->pays.''; + + // Tel pro. + print ''.$langs->trans("PhonePro").''.$adh->phone.''; + + // Tel perso + print ''.$langs->trans("PhonePerso").''.$adh->phone_perso.''; + + // Tel mobile + print ''.$langs->trans("PhoneMobile").''.$adh->phone_mobile.''; + + // EMail print ''.$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'*':'').''.$adh->email.' '; - // print 'Pass'.$adh->pass.' '; + + // Date naissance print ''.$langs->trans("Birthday").''.$adh->naiss.' '; + + // URL print 'URL Photo'.$adh->photo.' '; + + // Public print ''.$langs->trans("Public").''; if ($adh->public==1) print $langs->trans("Yes"); else print $langs->trans("No"); print ''; + + // Status print ''.$langs->trans("Status").''.$adh->getLibStatut(4).''; + // Autres attributs foreach($adho->attribute_label as $key=>$value){ print "$value".$adh->array_options["options_$key"]." \n"; } diff --git a/htdocs/admin/ldap_members.php b/htdocs/admin/ldap_members.php index 10cd377c67f..40400f125a5 100644 --- a/htdocs/admin/ldap_members.php +++ b/htdocs/admin/ldap_members.php @@ -61,6 +61,11 @@ if ($_GET["action"] == 'setvalue' && $user->admin) if (! dolibarr_set_const($db, 'LDAP_FIELD_PHONE',$_POST["fieldphone"])) $error++; if (! dolibarr_set_const($db, 'LDAP_FIELD_FAX',$_POST["fieldfax"])) $error++; if (! dolibarr_set_const($db, 'LDAP_FIELD_MOBILE',$_POST["fieldmobile"])) $error++; + if (! dolibarr_set_const($db, 'LDAP_FIELD_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 ($error) { @@ -200,6 +205,45 @@ print ''.$langs->trans("LDAPFieldFaxExample").''; print 'global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_FAX?' checked="true"':'').">"; print ''; +// Address +$var=!$var; +print ''.$langs->trans("LDAPFieldAddress").''; +print ''; +print ''.$langs->trans("LDAPFieldAddressExample").''; +print 'global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_ADDRESS?' checked="true"':'').">"; +print ''; + +// CP +$var=!$var; +print ''.$langs->trans("LDAPFieldZip").''; +print ''; +print ''.$langs->trans("LDAPFieldZipExample").''; +print 'global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_ZIP?' checked="true"':'').">"; +print ''; + +// Ville +$var=!$var; +print ''.$langs->trans("LDAPFieldTown").''; +print ''; +print ''.$langs->trans("LDAPFieldTownExample").''; +print 'global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_TOWN?' checked="true"':'').">"; +print ''; + +// Pays +$var=!$var; +print ''.$langs->trans("LDAPFieldCountry").''; +print ''; +print ''.$langs->trans("LDAPFieldCountryExample").''; +print 'global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_COUNTRY?' checked="true"':'').">"; +print ''; + +// Description +$var=!$var; +print ''.$langs->trans("LDAPFieldDescription").''; +print ''; +print ''.$langs->trans("LDAPFieldDescriptionExample").''; +print 'global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_DESCRIPTION?' checked="true"':'').">"; +print ''; $var=!$var; print ''; diff --git a/htdocs/conf/conf.class.php b/htdocs/conf/conf.class.php index a0c43774c86..fb3821eb105 100644 --- a/htdocs/conf/conf.class.php +++ b/htdocs/conf/conf.class.php @@ -297,6 +297,7 @@ class Conf $this->export->dir_temp =DOL_DATA_ROOT."/export/temp"; // Module ldap $this->ldap->enabled=defined("MAIN_MODULE_LDAP")?MAIN_MODULE_LDAP:0; + $this->ldap->dir_temp=DOL_DATA_ROOT."/ldap/temp"; // Module FCKeditor $this->fckeditor->enabled=defined("MAIN_MODULE_FCKEDITOR")?MAIN_MODULE_FCKEDITOR:0; $this->fckeditor->dir_output=DOL_DATA_ROOT."/fckeditor"; diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index e3fdbc8e862..6cb701b338c 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -304,10 +304,10 @@ if ($user->rights->societe->contact->creer) $form->select_pays($contact->fk_pays); print ''; - print 'Tel Pro'; - print 'Tel Perso'; + print ''.$langs->trans("PhonePro").''; + print ''.$langs->trans("PhonePerso").''; - print 'Portable'; + print ''.$langs->trans("PhoneMobile").''; print ''.$langs->trans("Fax").''; print ''.$langs->trans("Email").''; @@ -382,10 +382,10 @@ if ($user->rights->societe->contact->creer) $form->select_pays($contact->fk_pays); print ''; - print 'Tel Pro'; - print 'Tel Perso'; + print ''.$langs->trans("PhonePro").''; + print ''.$langs->trans("PhonePerso").''; - print 'Portable'; + print ''.$langs->trans("PhoneMobile").''; print ''.$langs->trans("Fax").''; print ''.$langs->trans("EMail").''; @@ -501,10 +501,10 @@ if ($_GET["id"] && $_GET["action"] != 'edit') print $contact->pays; print ''; - print 'Tel Pro'.$contact->phone_pro.''; - print 'Tel Perso'.$contact->phone_perso.''; + print ''.$langs->trans("PhonePro").''.$contact->phone_pro.''; + print ''.$langs->trans("PhonePerso").''.$contact->phone_perso.''; - print 'Portable'.$contact->phone_mobile.''; + print ''.$langs->trans("PhoneMobile").''.$contact->phone_mobile.''; print ''.$langs->trans("Fax").''.$contact->fax.''; print ''.$langs->trans("EMail").''; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index ef4c208d4a2..c9767ecf7f9 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -582,6 +582,8 @@ LDAPFieldZip=Zip LDAPFieldZipExample=Example : postalcode LDAPFieldTown=Town LDAPFieldTownExample=Example : l +LDAPFieldCountry=Country +LDAPFieldCountryExample=Example : LDAPFieldDescription=Description LDAPFieldDescriptionExample=Example : description LDAPFieldSid=SID diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 2c3bc920db1..03c942e1957 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -38,6 +38,9 @@ Region=Region Country=Country CountryCode=Country code Phone=Phone +PhonePro=Prof. phone +PhonePerso=Pers. phone +PhoneMobile=Mobile Fax=Fax Zip=Zip Code Town=Town diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 771c9f3029b..bca901442f8 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -582,6 +582,8 @@ LDAPFieldZip=Code postal LDAPFieldZipExample=Exemple : postalcode LDAPFieldTown=Ville LDAPFieldTownExample=Exemple : l +LDAPFieldCountry=Pays +LDAPFieldCountryExample=Exemple : LDAPFieldDescription=Description LDAPFieldDescriptionExample=Exemple : description LDAPFieldSid=SID diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index 011af6f8819..7487d8de3a8 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -38,6 +38,9 @@ Region=R Country=Pays CountryCode=Code pays Phone=Téléphone +PhonePro=Tél pro. +PhonePerso=Tél perso. +PhoneMobile=Tél portable Fax=Fax Zip=Code postal Town=Ville diff --git a/htdocs/lib/ldap.class.php b/htdocs/lib/ldap.class.php index cdffc121284..5f51611fa31 100644 --- a/htdocs/lib/ldap.class.php +++ b/htdocs/lib/ldap.class.php @@ -221,8 +221,8 @@ class Ldap // Try in auth mode if ($conf->global->LDAP_ADMIN_DN && $conf->global->LDAP_ADMIN_PASS) { - dolibarr_syslog("Ldap.class::connect_bind try authBind on ".$host." user=".$conf->global->LDAP_ADMIN_DN,LOG_DEBUG); - $result=$this->authBind($conf->global->LDAP_ADMIN_DN,$conf->global->LDAP_ADMIN_PASS); + dolibarr_syslog("Ldap.class::connect_bind try bindauth on ".$host." user=".$conf->global->LDAP_ADMIN_DN,LOG_DEBUG); + $result=$this->bindauth($conf->global->LDAP_ADMIN_DN,$conf->global->LDAP_ADMIN_PASS); if ($result) { $this->bind=$this->result; @@ -287,8 +287,8 @@ class Ldap { if (! $this->result=@ldap_bind($this->connection)) { - $this->ldapErrorCode = ldap_errno( $this->connection); - $this->ldapErrorText = ldap_error( $this->connection); + $this->ldapErrorCode = ldap_errno($this->connection); + $this->ldapErrorText = ldap_error($this->connection); $this->error=$this->ldapErrorCode." ".$this->ldapErrorText; return false; } @@ -304,14 +304,17 @@ class Ldap * "cn=Directory Manager" under iPlanet. For a user, it will be something * like "uid=jbloggs,ou=People,dc=foo,dc=com". */ - function authBind( $bindDn,$pass) + function bindauth($bindDn,$pass) { - if ( !$this->result = @ldap_bind( $this->connection,$bindDn,$pass)) { - $this->ldapErrorCode = ldap_errno( $this->connection); - $this->ldapErrorText = ldap_error( $this->connection); + if (! $this->result = @ldap_bind( $this->connection,$bindDn,$pass)) + { + $this->ldapErrorCode = ldap_errno($this->connection); + $this->ldapErrorText = ldap_error($this->connection); $this->error=$this->ldapErrorCode." ".$this->ldapErrorText; return false; - } else { + } + else + { return true; } } @@ -585,7 +588,7 @@ class Ldap * \param dn DN entry key * \param info Attributes array * \param user Objet utilisateru qui crée - * \return boolean <0 si KO, >0 si OK + * \return int <0 si KO, >0 si OK */ function add($dn, $info, $user) { @@ -600,6 +603,8 @@ class Ldap if (! is_array($val)) $info[$key]=$this->ldap_utf8_encode($val); } + $this->dump($dn,$info); + //print_r($info); $result=@ldap_add($this->connection, $dn, $info); @@ -610,7 +615,7 @@ class Ldap /* * \brief Delete a LDAP entry * \param dn DN entry key - * \return boolean <0 si KO, >0 si OK + * \return int <0 si KO, >0 si OK */ function delete($dn) { @@ -628,6 +633,40 @@ class Ldap } + /* + * \brief Dump a LDAP message to ldapinput.in file + * \param dn DN entry key + * \param info Attributes array + * \return int <0 si KO, >0 si OK + */ + function dump($dn, $info) + { + global $conf; + create_exdir($conf->ldap->dir_temp); + + $file=$conf->ldap->dir_temp.'/ldapinput.in'; + $fp=fopen($file,"w"); + if ($fp) + { + fputs($fp, "dn: ".$dn."\n"); + foreach($info as $key => $value) + { + if (! is_array($value)) + { + fputs($fp, "$key: $value\n"); + } + else + { + foreach($value as $valuekey => $valuevalue) + { + fputs($fp, "$key: $valuevalue\n"); + } + } + } + fclose($fp); + } + } + // 2.4 Attribute methods ----------------------------------------------------- /** @@ -680,7 +719,7 @@ class Ldap // if the directory is AD, then bind first with the search user first if ($this->serverType == "activedirectory") { - $this->authBind($this->searchUser, $this->searchPassword); + $this->bindauth($this->searchUser, $this->searchPassword); } $filter = '('.$useridentifier.'='.$search.')'; @@ -715,25 +754,6 @@ class Ldap return $userslist; } - /** - * Récupère le SID de l'utilisateur - * ldapuser. le login de l'utilisateur - * \deprecated - */ - function getObjectSid($ldapUser) - { - $criteria = $this->getUserIdentifier()."=$ldapUser"; - $justthese = array("objectsid"); - - $ldapSearchResult = ldap_search($this->connection, $this->people, $criteria, $justthese); - - $entry = ldap_first_entry($this->connection, $ldapSearchResult); - $ldapBinary = ldap_get_values_len ($this->connection, $entry, "objectsid"); - $SIDText = $this->binSIDtoText($ldapBinary[0]); - return $SIDText; - return $ldapBinary; - } - /** * Converts a little-endian hex-number to one, that 'hexdec' can convert * \deprecated @@ -745,26 +765,9 @@ class Ldap return $result; } - /** - * Returns the textual SID - * \deprecated - */ - function binSIDtoText($binsid) { - $hex_sid=bin2hex($binsid); - $rev = hexdec(substr($hex_sid,0,2)); // Get revision-part of SID - $subcount = hexdec(substr($hex_sid,2,2)); // Get count of sub-auth entries - $auth = hexdec(substr($hex_sid,4,12)); // SECURITY_NT_AUTHORITY - $result = "$rev-$auth"; - for ($x=0;$x < $subcount; $x++) { - $subauth[$x] = hexdec($this->littleEndian(substr($hex_sid,16+($x*8),8))); // get all SECURITY_NT_AUTHORITY - $result .= "-".$subauth[$x]; - } - return $result; - } - /** * \brief Fonction de recherche avec filtre - * \remarks this->connection doit etre défini donc la methode bind ou authbind doit avoir deja été appelée + * \remarks this->connection doit etre défini donc la methode bind ou bindauth doit avoir deja été appelée * \param checkDn DN de recherche (Ex: ou=users,cn=my-domain,cn=com) * \param filter Filtre de recherche (ex: (sn=nom_personne) ) * \return array Tableau des reponses @@ -778,7 +781,7 @@ class Ldap // if the directory is AD, then bind first with the search user first if ($this->serverType == "activedirectory") { - $this->authBind($this->searchUser, $this->searchPassword); + $this->bindauth($this->searchUser, $this->searchPassword); } $this->result = @ldap_search($this->connection, $checkDn, $filter); @@ -807,7 +810,7 @@ class Ldap // if the directory is AD, then bind first with the search user first if ($this->serverType == "activedirectory") { - $this->authBind($this->searchUser, $this->searchPassword); + $this->bindauth($this->searchUser, $this->searchPassword); } $userIdentifier = $this->getUserIdentifier(); @@ -877,23 +880,6 @@ class Ldap } } - /** - * \brief permet d'enlever les accents d'une chaine. - * \param str - * \return string - */ - function dolibarr_ldap_unacc($str) - { - $stu = ereg_replace("é","e",$str); - $stu = ereg_replace("è","e",$stu); - $stu = ereg_replace("ê","e",$stu); - $stu = ereg_replace("à","a",$stu); - $stu = ereg_replace("ç","c",$stu); - $stu = ereg_replace("ï","i",$stu); - $stu = ereg_replace("ä","a",$stu); - return $stu; - } - /** * \brief UserAccountControl Flgs to more human understandable form... * diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 83682e9e9fc..81ec83da46c 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -442,7 +442,7 @@ if (($action == 'create') || ($action == 'adduserldap')) print '
'; print ''; - if ($ldap_SID) print ''; + if ($ldap_sid) print ''; print ''; @@ -488,7 +488,7 @@ if (($action == 'create') || ($action == 'adduserldap')) } print ''; - if (!$ldap_SID) + if (!$ldap_sid) { $generated_password=''; if ($conf->global->USER_PASSWORD_GENERATED) @@ -505,7 +505,7 @@ if (($action == 'create') || ($action == 'adduserldap')) // Mot de passe print ''; print '
'.$langs->trans("Password").''; - if ($ldap_SID) + if ($ldap_sid) { print 'mot de passe du domaine'; } diff --git a/mysql/migration/2.0.0-2.1.0.sql b/mysql/migration/2.0.0-2.1.0.sql index 241cb340d84..5e10b30c3ab 100644 --- a/mysql/migration/2.0.0-2.1.0.sql +++ b/mysql/migration/2.0.0-2.1.0.sql @@ -479,6 +479,11 @@ alter table llx_facturedet_rec add column total_ht real; alter table llx_facturedet_rec add column total_tva real; alter table llx_facturedet_rec add column total_ttc real; +alter table llx_adherent add column phone varchar(30) after email; +alter table llx_adherent add column phone_perso varchar(30) after phone; +alter table llx_adherent add column phone_mobile varchar(30) after phone_perso; + + update llx_facture set fk_facture_source=null where fk_facture_source is not null and type = 0; diff --git a/mysql/tables/llx_adherent.sql b/mysql/tables/llx_adherent.sql index 7335b51d4f8..9e11bd7c904 100644 --- a/mysql/tables/llx_adherent.sql +++ b/mysql/tables/llx_adherent.sql @@ -22,36 +22,42 @@ -- =================================================================== -- -- statut --- 0 : non adherent --- 1 : adherent +-- -1 : brouillon +-- 0 : resilie +-- 1 : valide create table llx_adherent ( rowid integer AUTO_INCREMENT PRIMARY KEY, - tms timestamp, - statut smallint NOT NULL DEFAULT 0, - public smallint NOT NULL DEFAULT 0, -- certain champ de la fiche sont ils public ou pas ? + nom varchar(50), + prenom varchar(50), + login varchar(50) NOT NULL, -- login + pass varchar(50), -- password fk_adherent_type smallint, morphy enum('mor','phy') NOT NULL, -- personne morale / personne physique - datevalid datetime, -- date de validation - datec datetime, -- date de creation - prenom varchar(50), - nom varchar(50), societe varchar(50), adresse text, cp varchar(30), ville varchar(50), pays varchar(50), email varchar(255), - login varchar(50) NOT NULL, -- login utilise pour editer sa fiche - pass varchar(50), -- pass utilise pour editer sa fiche + phone varchar(30), + phone_perso varchar(30), + phone_mobile varchar(30), naiss date, -- date de naissance - photo varchar(255), -- url vers la photo de l'adherent - fk_user_author integer NOT NULL, - fk_user_mod integer NOT NULL, - fk_user_valid integer NOT NULL, + photo varchar(255), -- url vers photo + + statut smallint NOT NULL DEFAULT 0, + public smallint NOT NULL DEFAULT 0, -- certain champ de la fiche sont ils public ou pas ? datefin datetime, -- date de fin de validité de la cotisation note text, + + datevalid datetime, -- date de validation + datec datetime, -- date de creation + tms timestamp, -- date de modification + fk_user_author integer NOT NULL, + fk_user_mod integer NOT NULL, + fk_user_valid integer NOT NULL UNIQUE INDEX(login) )type=innodb; diff --git a/scripts/adherents/sync_member_dolibarr2ldap.php b/scripts/adherents/sync_member_dolibarr2ldap.php index 031649120b6..0e1f7e8a13c 100644 --- a/scripts/adherents/sync_member_dolibarr2ldap.php +++ b/scripts/adherents/sync_member_dolibarr2ldap.php @@ -72,8 +72,13 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; + $ldap=new Ldap(); + $ldap->connect_bind(); + while ($i < $num) { + $ldap->error=""; + $obj = $db->fetch_object($resql); $member = new Adherent($db); @@ -81,7 +86,10 @@ if ($resql) print $langs->trans("UpdateMember")." rowid=".$member->id." ".$member->fullname; - $result=$member->update_ldap($user); + $info=$member->_load_ldap_info(); + $dn=$member->_load_ldap_dn($info); + + $result=$ldap->update($dn,$info,$user); if ($result > 0) { print " - ".$langs->trans("OK"); @@ -89,12 +97,15 @@ if ($resql) else { $error++; - print " - ".$langs->trans("KO").' - '.$member->error; + print " - ".$langs->trans("KO").' - '.$ldap->error; } print "\n"; $i++; } + + $ldap->unbind(); + $ldap->close(); } else { diff --git a/scripts/adherents/sync_member_ldap2dolibarr.php b/scripts/adherents/sync_member_ldap2dolibarr.php new file mode 100644 index 00000000000..e9e84553d64 --- /dev/null +++ b/scripts/adherents/sync_member_ldap2dolibarr.php @@ -0,0 +1,155 @@ + + * Copyright (C) 2006 Laurent Destailleur + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + */ + +/** + \file scripts/adherents/sync_member_ldap2dolibarr.php + \ingroup ldap adherent + \brief Script de mise a jour des adherents dans Dolibarr depuis LDAP +*/ + +// Test si mode batch +$sapi_type = php_sapi_name(); +$script_file=__FILE__; +if (eregi('([^\\\/]+)$',$script_file,$reg)) $script_file=$reg[1]; + +if (substr($sapi_type, 0, 3) == 'cgi') { + echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer $script_file en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n"; + exit; +} + +if (! isset($argv[1]) || ! is_numeric($argv[1])) { + print "Usage: $script_file id_member_type\n"; + exit; +} +$typeid=$argv[1]; + +// Recupere env dolibarr +$version='$Revision$'; +$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"); + +$error=0; + + +print "***** $script_file ($version) *****\n"; + +if ($argv[2]) $conf->global->LDAP_SERVER_HOST=$argv[2]; +if ($argv[2]) $conf->global->LDAP_SERVER_HOST=$argv[2]; + +/* +if (! $conf->global->LDAP_MEMBER_ACTIVE) +{ + print $langs->trans("LDAPSynchronizationNotSetupInDolibarr"); + exit 1; +} +*/ + + +$ldap = new Ldap(); +$result = $ldap->connect_bind(); +if ($result >= 0) +{ + $justthese=array(); + + $ldaprecords = $ldap->search($conf->global->LDAP_MEMBER_DN, '('.$conf->global->LDAP_KEY_MEMBERS.'=*)'); + if (is_array($ldaprecords)) + { + $db->begin(); + + 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->photo; + + // Propriete type membre + $member->typeid=$typeid; + + + //---------------------------- + // YOUR OWN RULES HERE + //---------------------------- + + + + //---------------------------- + // END + //---------------------------- + + print $langs->trans("MemberCreate").' no '.$key.': '.$member->fullname."\n"; + + print_r($member); + exit; + +// $member->create(); + + $error++; + } + + if (! $error) + { + $db->commit(); + } + else + { + $db->rollback(); + } + } + else + { + dolibarr_print_error('',$ldap->error); + $error++; + } +} +else +{ + dolibarr_print_error('',$ldap->error); + $error++; +} + + +return $error; +?> diff --git a/scripts/company/sync_contacts_dolibarr2ldap.php b/scripts/company/sync_contacts_dolibarr2ldap.php index 854d1a6caab..107a4b409f1 100644 --- a/scripts/company/sync_contacts_dolibarr2ldap.php +++ b/scripts/company/sync_contacts_dolibarr2ldap.php @@ -72,8 +72,13 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; + $ldap=new Ldap(); + $ldap->connect_bind(); + while ($i < $num) { + $ldap->error=""; + $obj = $db->fetch_object($resql); $contact = new Contact($db); @@ -82,9 +87,6 @@ if ($resql) print $langs->trans("UpdateContact")." rowid=".$contact->id." ".$contact->fullname; - $ldap=new Ldap(); - $ldap->connect_bind(); - $info=$contact->_load_ldap_info(); $dn=$contact->_load_ldap_dn($info); @@ -102,6 +104,9 @@ if ($resql) $i++; } + + $ldap->unbind(); + $ldap->close(); } else { diff --git a/scripts/user/sync_group_dolibarr2ldap.php b/scripts/user/sync_group_dolibarr2ldap.php index 9d9af14b52c..1342a50ec84 100644 --- a/scripts/user/sync_group_dolibarr2ldap.php +++ b/scripts/user/sync_group_dolibarr2ldap.php @@ -72,8 +72,13 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; + $ldap=new Ldap(); + $ldap->connect_bind(); + while ($i < $num) { + $ldap->error=""; + $obj = $db->fetch_object($resql); $fgroup = new UserGroup($db); @@ -82,9 +87,6 @@ if ($resql) print $langs->trans("UpdateGroup")." rowid=".$fgroup->id." ".$fgroup->nom; - $ldap=new Ldap(); - $ldap->connect_bind(); - $info=$fgroup->_load_ldap_info(); $dn=$fgroup->_load_ldap_dn($info); @@ -96,12 +98,15 @@ if ($resql) else { $error++; - print " - ".$langs->trans("KO").' - '.$fgroup->error; + print " - ".$langs->trans("KO").' - '.$ldap->error; } print "\n"; $i++; } + + $ldap->unbind(); + $ldap->close(); } else { diff --git a/scripts/user/sync_user_dolibarr2ldap.php b/scripts/user/sync_user_dolibarr2ldap.php index 58d97f8dcc4..4f18cffaa9f 100644 --- a/scripts/user/sync_user_dolibarr2ldap.php +++ b/scripts/user/sync_user_dolibarr2ldap.php @@ -72,8 +72,13 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; + $ldap=new Ldap(); + $ldap->connect_bind(); + while ($i < $num) { + $ldap->error=""; + $obj = $db->fetch_object($resql); $fuser = new User($db); @@ -82,9 +87,6 @@ if ($resql) print $langs->trans("UpdateUser")." rowid=".$fuser->id." ".$fuser->fullname; - $ldap=new Ldap(); - $ldap->connect_bind(); - $info=$fuser->_load_ldap_info(); $dn=$fuser->_load_ldap_dn($info); @@ -96,12 +98,15 @@ if ($resql) else { $error++; - print " - ".$langs->trans("KO").' - '.$fuser->error; + print " - ".$langs->trans("KO").' - '.$ldap->error; } print "\n"; $i++; } + + $ldap->unbind(); + $ldap->close(); } else {