diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index cbf1b75afb8..11dd53f374d 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -544,8 +544,6 @@ class Adherent extends CommonObject } } - $this->fullname=trim($this->nom.' '.$this->prenom); - if (! $error && ! $notrigger) { $this->use_webcal=($conf->global->PHPWEBCALENDAR_MEMBERSTATUS=='always'?1:0); @@ -973,7 +971,6 @@ class Adherent extends CommonObject $this->civilite_id = $obj->civilite; $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; @@ -1709,23 +1706,42 @@ class Adherent extends CommonObject } /** - * \brief Return full name of member - * \return string Full name + * \brief Return full name (civility+' '+name+' '+lastname) + * \param langs Language object for translation of civility + * \param option 0=No option, 1=Add civility + * \param nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname + * \return string String with full name */ - function getFullname($outputlangs) + function getFullName($langs,$option=0,$nameorder=-1) { global $conf; - if ($this->nom && $this->prenom) + $ret=''; + if ($option && $this->civilite_id) { - if (! empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) return $this->nom.' '.$this->prenom; - else return $this->prenom.' '.$this->nom; + if ($langs->transnoentitiesnoconv("Civility".$this->civilite_id)!="Civility".$this->civilite_id) $ret.=$langs->transnoentitiesnoconv("Civility".$this->civilite_id).' '; + else $ret.=$this->civilite_id.' '; } - if ($this->nom) return $this->nom; - if ($this->prenom) return $this->prenom; - return ''; + + // If order not defined, we use the setup + if ($nameorder < 0) $nameorder=(! $conf->global->MAIN_FIRSTNAME_NAME_POSITION); + + if ($nameorder) + { + if ($this->prenom) $ret.=$this->prenom; + if ($this->prenom && $this->nom) $ret.=' '; + if ($this->nom) $ret.=$this->nom; + } + else + { + if ($this->nom) $ret.=$this->nom; + if ($this->prenom && $this->nom) $ret.=' '; + if ($this->prenom) $ret.=$this->prenom; + } + return trim($ret); } + /** * \brief Retourne le libelle de civilite du contact * \return string Nom traduit de la civilite @@ -1949,7 +1965,6 @@ class Adherent extends CommonObject $this->civilite_id = 0; $this->nom = 'DOLIBARR'; $this->prenom = 'SPECIMEN'; - $this->fullname=trim($this->nom.' '.$this->prenom); $this->login='dolibspec'; $this->pass='dolibspec'; $this->societe = 'Societe ABC'; @@ -2016,8 +2031,10 @@ class Adherent extends CommonObject // Object classes $info["objectclass"]=explode(',',$conf->global->LDAP_MEMBER_OBJECT_CLASS); + $this->fullname=$this->getFullName($langs); + // Member - if ($this->fullname && $conf->global->LDAP_MEMBER_FIELD_FULLNAME) $info[$conf->global->LDAP_MEMBER_FIELD_FULLNAME] = $this->fullname; + if ($this->fullname && $conf->global->LDAP_MEMBER_FIELD_FULLNAME) $info[$conf->global->LDAP_MEMBER_FIELD_FULLNAME] = $this->fullname; if ($this->nom && $conf->global->LDAP_MEMBER_FIELD_NAME) $info[$conf->global->LDAP_MEMBER_FIELD_NAME] = $this->nom; if ($this->prenom && $conf->global->LDAP_MEMBER_FIELD_FIRSTNAME) $info[$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME] = $this->prenom; if ($this->login && $conf->global->LDAP_MEMBER_FIELD_LOGIN) $info[$conf->global->LDAP_MEMBER_FIELD_LOGIN] = $this->login; diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index d294737fa6f..d5ab221ce70 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -144,7 +144,7 @@ if ($_POST['action'] == 'setsocid') $thirdparty=new Societe($db); $thirdparty->fetch($_POST["socid"]); $error++; - $mesg='
| '.$langs->trans("Informations").' | |||||
| '.$langs->trans("User").' | '.$userstring.' | ||||
| '.$langs->trans("PreviousConnexion").' | '; diff --git a/htdocs/livraison/fiche.php b/htdocs/livraison/fiche.php index 25bd122287c..4fafe727a01 100644 --- a/htdocs/livraison/fiche.php +++ b/htdocs/livraison/fiche.php @@ -259,7 +259,7 @@ if ($_GET["action"] == 'create') print ' | '; } - print "".$langs->trans("Author")." | $author->fullname | \n"; + print "".$langs->trans("Author")." | ".$author->getFullName($langs)." | \n"; if ($commande->note) { diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 4bd74bd9d30..00ff94162d3 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -945,7 +945,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a $logintext.=$menutop->atarget?(' target="'.$menutop->atarget.'"'):''; $logintext.='>'.$user->login.''; $loginhtmltext.=''.$langs->trans("User").''; - $loginhtmltext.='
| '.$langs->trans("Member"); - print ' | '.$member->fullname.''; + print ' | '.$member->getFullName($langs).''; // Object $var=!$var; diff --git a/htdocs/soc.php b/htdocs/soc.php index a5d4cabcae2..30a525a086b 100644 --- a/htdocs/soc.php +++ b/htdocs/soc.php @@ -1449,7 +1449,7 @@ else $result=$adh->fetch('','',$soc->id); if ($result > 0) { - $adh->ref=$adh->fullname; + $adh->ref=$adh->getFullName($langs); print $adh->getNomUrl(1); } else diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index a8d411253c6..4429029eef3 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -169,7 +169,6 @@ class User extends CommonObject $this->nom = $obj->name; $this->prenom = $obj->firstname; - $this->fullname = trim($this->prenom . ' ' . $this->nom); $this->login = $obj->login; $this->pass_indatabase = $obj->pass; $this->pass_indatabase_crypted = $obj->pass_crypted; @@ -973,7 +972,6 @@ class User extends CommonObject // Clean parameters $this->nom = trim($this->nom); $this->prenom = trim($this->prenom); - $this->fullname = $this->prenom." ".$this->nom; $this->login = trim($this->login); $this->pass = trim($this->pass); $this->office_phone = trim($this->office_phone); @@ -1325,7 +1323,7 @@ class User extends CommonObject $url = "http://".$_SERVER["HTTP_HOST"].DOL_URL_ROOT; $mesg.= 'Click here to go to Dolibarr: '.$url."\n\n"; $mesg.= "--\n"; - $mesg.= $user->fullname; // Username that make then sending + $mesg.= $user->getFullName($langs); // Username that make then sending } else { @@ -1464,10 +1462,11 @@ class User extends CommonObject } /** - * \brief Renvoie nom clicable (avec eventuellement le picto) - * \param withpicto Inclut le picto dans le lien - * \param option Sur quoi pointe le lien - * \return string Chaine avec URL + * \brief Return a link to the user card (with optionnaly the picto) + * \param withpicto Include picto in link + * \param option On what the link point to + * \return string String with URL + * \remarks Use this->id,this->nom, this->prenom */ function getNomUrl($withpicto=0,$option='') { @@ -1485,7 +1484,7 @@ class User extends CommonObject } if ($withpicto) $result.=($lien.img_object($langs->trans("ShowUser"),'user').$lienfin.' '); - $result.=$lien.$this->nom.' '.$this->prenom.$lienfin; + $result.=$lien.$this->getFullName($langs).$lienfin; return $result; } @@ -1515,6 +1514,44 @@ class User extends CommonObject return $result; } + /** + * \brief Return full name (civility+' '+name+' '+lastname) + * \param langs Language object for translation of civility + * \param option 0=No option, 1=Add civility + * \param nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname + * \return string String with full name + */ + function getFullName($langs,$option=0,$nameorder=-1) + { + global $conf; + + $ret=''; + if ($option && $this->civilite_id) + { + if ($langs->transnoentitiesnoconv("Civility".$this->civilite_id)!="Civility".$this->civilite_id) $ret.=$langs->transnoentitiesnoconv("Civility".$this->civilite_id).' '; + else $ret.=$this->civilite_id.' '; + } + + // If order not defined, we use the setup + if ($nameorder < 0) $nameorder=(! $conf->global->MAIN_FIRSTNAME_NAME_POSITION); + + if ($nameorder) + { + if ($this->prenom) $ret.=$this->prenom; + if ($this->prenom && $this->nom) $ret.=' '; + if ($this->nom) $ret.=$this->nom; + } + else + { + if ($this->nom) $ret.=$this->nom; + if ($this->prenom && $this->nom) $ret.=' '; + if ($this->prenom) $ret.=$this->prenom; + } + + return trim($ret); + } + + /** * \brief Retourne le libelle du statut d'un user (actif, inactif) * \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long @@ -1607,8 +1644,10 @@ class User extends CommonObject // Object classes $info["objectclass"]=explode(',',$conf->global->LDAP_USER_OBJECT_CLASS); + $this->fullname=$this->getFullName($langs); + // Champs - if ($this->fullname && $conf->global->LDAP_FIELD_FULLNAME) $info[$conf->global->LDAP_FIELD_FULLNAME] = $this->fullname; + 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->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; @@ -1677,7 +1716,6 @@ class User extends CommonObject $this->nom='DOLIBARR'; $this->prenom='SPECIMEN'; - $this->fullname=trim($this->prenom.' '.$this->nom); $this->note='This is a note'; $this->email='email@specimen.com'; $this->office_phone='0999999999'; diff --git a/htdocs/webcalendar/inc/triggers/interface_modWebcalendar_Webcalsynchro.class.php b/htdocs/webcalendar/inc/triggers/interface_modWebcalendar_Webcalsynchro.class.php index b2c7b1938aa..cd4f955ebd4 100644 --- a/htdocs/webcalendar/inc/triggers/interface_modWebcalendar_Webcalsynchro.class.php +++ b/htdocs/webcalendar/inc/triggers/interface_modWebcalendar_Webcalsynchro.class.php @@ -113,7 +113,7 @@ class InterfaceWebcalsynchro $langs->load("other"); // Initialisation donnees (date,duree,texte,desc) - if ($object->type_id == 5 && $object->contact->fullname) + if ($object->type_id == 5 && $object->contact->getFullName($langs)) { $libellecal =$langs->transnoentities("TaskRDVWith",$object->contact->getFullName($langs))."\n"; $libellecal.=$object->note; @@ -273,7 +273,7 @@ class InterfaceWebcalsynchro $this->duree=0; $this->texte=$langs->transnoentities("NewMemberCreated",$object->ref); $this->desc=$langs->transnoentities("NewMemberCreated",$object->ref); - $this->desc.="\n".$langs->transnoentities("Member").': '.$object->fullname; + $this->desc.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); $this->desc.="\n".$langs->transnoentities("Type").': '.$object->type; $this->desc.="\n".$langs->transnoentities("Author").': '.$user->login; } @@ -287,7 +287,7 @@ class InterfaceWebcalsynchro $this->duree=0; $this->texte=$langs->transnoentities("MemberValidatedInDolibarr",$object->ref); $this->desc=$langs->transnoentities("MemberValidatedInDolibarr",$object->ref); - $this->desc.="\n".$langs->transnoentities("Member").': '.$object->fullname; + $this->desc.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); $this->desc.="\n".$langs->transnoentities("Type").': '.$object->type; $this->desc.="\n".$langs->transnoentities("Author").': '.$user->login; } @@ -301,7 +301,7 @@ class InterfaceWebcalsynchro $this->duree=0; $this->texte=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref); $this->desc=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref); - $this->desc.="\n".$langs->transnoentities("Member").': '.$object->fullname; + $this->desc.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); $this->desc.="\n".$langs->transnoentities("Type").': '.$object->type; $this->desc.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount; $this->desc.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day'); @@ -317,7 +317,7 @@ class InterfaceWebcalsynchro $this->duree=0; $this->texte=$langs->transnoentities("MemberModifiedInDolibarr",$object->ref); $this->desc=$langs->transnoentities("MemberModifiedInDolibarr",$object->ref); - $this->desc.="\n".$langs->transnoentities("Member").': '.$object->fullname; + $this->desc.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); $this->desc.="\n".$langs->transnoentities("Type").': '.$object->type; $this->desc.="\n".$langs->transnoentities("Author").': '.$user->login; } @@ -331,7 +331,7 @@ class InterfaceWebcalsynchro $this->duree=0; $this->texte=$langs->transnoentities("MemberResiliatedInDolibarr",$object->ref); $this->desc=$langs->transnoentities("MemberResiliatedInDolibarr",$object->ref); - $this->desc.="\n".$langs->transnoentities("Member").': '.$object->fullname; + $this->desc.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); $this->desc.="\n".$langs->transnoentities("Type").': '.$object->type; $this->desc.="\n".$langs->transnoentities("Author").': '.$user->login; } @@ -345,7 +345,7 @@ class InterfaceWebcalsynchro $this->duree=0; $this->texte=$langs->transnoentities("MemberDeletedInDolibarr",$object->ref); $this->desc=$langs->transnoentities("MemberDeletedInDolibarr",$object->ref); - $this->desc.="\n".$langs->transnoentities("Member").': '.$object->fullname; + $this->desc.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); $this->desc.="\n".$langs->transnoentities("Type").': '.$object->type; $this->desc.="\n".$langs->transnoentities("Author").': '.$user->login; } diff --git a/scripts/members/sync_members_dolibarr2ldap.php b/scripts/members/sync_members_dolibarr2ldap.php index aa314659871..fd1bad66219 100644 --- a/scripts/members/sync_members_dolibarr2ldap.php +++ b/scripts/members/sync_members_dolibarr2ldap.php @@ -121,7 +121,7 @@ if ($resql) exit; } - print $langs->transnoentities("UpdateMember")." rowid=".$member->id." ".$member->fullname; + print $langs->transnoentities("UpdateMember")." rowid=".$member->id." ".$member->getFullName($langs); $oldobject=$member; diff --git a/scripts/members/sync_members_ldap2dolibarr.php b/scripts/members/sync_members_ldap2dolibarr.php index 9989ec3ba7c..2dc0bccd857 100644 --- a/scripts/members/sync_members_ldap2dolibarr.php +++ b/scripts/members/sync_members_ldap2dolibarr.php @@ -182,7 +182,6 @@ if ($result >= 0) // Propriete membre $member->prenom=$ldapuser[$conf->global->LDAP_FIELD_FIRSTNAME]; $member->nom=$ldapuser[$conf->global->LDAP_FIELD_NAME]; - $member->fullname=($ldapuser[$conf->global->LDAP_FIELD_FULLNAME] ? $ldapuser[$conf->global->LDAP_FIELD_FULLNAME] : trim($member->prenom." ".$member->nom)); $member->login=$ldapuser[$conf->global->LDAP_FIELD_LOGIN]; $member->pass=$ldapuser[$conf->global->LDAP_FIELD_PASSWORD]; @@ -221,7 +220,7 @@ if ($result >= 0) $member->typeid=$typeid; // Creation membre - print $langs->transnoentities("MemberCreate").' # '.$key.': login='.$member->login.', fullname='.$member->fullname; + print $langs->transnoentities("MemberCreate").' # '.$key.': login='.$member->login.', fullname='.$member->getFullName($langs); print ', datec='.$member->datec; $member_id=$member->create($user); if ($member_id > 0) diff --git a/scripts/user/sync_users_dolibarr2ldap.php b/scripts/user/sync_users_dolibarr2ldap.php index cb46df3d6f0..c4459fd3a12 100644 --- a/scripts/user/sync_users_dolibarr2ldap.php +++ b/scripts/user/sync_users_dolibarr2ldap.php @@ -81,7 +81,7 @@ if ($resql) $fuser = new User($db); $fuser->fetch($obj->rowid); - print $langs->trans("UpdateUser")." rowid=".$fuser->id." ".$fuser->fullname; + print $langs->trans("UpdateUser")." rowid=".$fuser->id." ".$fuser->getFullName($langs); $oldobject=$fuser; | |||