Skip to content

Commit

Permalink
New: use dolGetFirstLastname() everywher we should.
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Mar 11, 2013
1 parent 34fed3e commit 5bc6631
Show file tree
Hide file tree
Showing 16 changed files with 45 additions and 42 deletions.
4 changes: 2 additions & 2 deletions htdocs/admin/prelevement.php
Expand Up @@ -181,7 +181,7 @@
$var=!$var;
if (!$obj->fk_societe)
{
$username= $obj->firstname.' '.$obj->lastname;
$username=dolGetFirstLastname($obj->firstname,$obj->lastname);
$internalusers[$obj->rowid] = $username;
}

Expand Down Expand Up @@ -254,7 +254,7 @@
$var=!$var;

print "<tr ".$bc[$var].">";
print '<td>'.$obj->firstname." ".$obj->lastname.'</td>';
print '<td>'.dolGetFirstLastname($obj->firstname,$obj->lastname).'</td>';
$label=($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label);
print '<td>'.$label.'</td>';
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=deletenotif&amp;notif='.$obj->rowid.'">'.img_delete().'</a></td>';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/action/class/actioncomm.class.php
Expand Up @@ -948,7 +948,7 @@ function build_exportfile($format,$type,$cachedelay,$filename,$filters)
$event['startdate']=$datestart;
$event['duration']=$duration; // Not required with type 'journal'
$event['enddate']=$dateend; // Not required with type 'journal'
$event['author']=$obj->firstname.($obj->lastname?" ".$obj->lastname:"");
$event['author']=dolGetFirstLastname($obj->firstname, $obj->lastname);
$event['priority']=$obj->priority;
$event['fulldayevent']=$obj->fulldayevent;
$event['location']=$obj->location;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/action/index.php
Expand Up @@ -486,7 +486,7 @@
$event->datep=dol_mktime(0,0,0,$datearray['mon'],$datearray['mday'],$year,true); // For full day events, date are also GMT but they wont but converted during output
$event->datef=$event->datep;
$event->type_code='BIRTHDAY';
$event->libelle=$langs->trans("Birthday").' '.$obj->firstname.' '.$obj->lastname;
$event->libelle=$langs->trans("Birthday").' '.dolGetFirstLastname($obj->firstname,$obj->lastname);
$event->percentage=100;
$event->fulldayevent=true;

Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/mailing/fiche.php
Expand Up @@ -209,7 +209,7 @@
$obj = $db->fetch_object($resql);

// sendto en RFC2822
$sendto = str_replace(',',' ',$obj->firstname." ".$obj->lastname)." <".$obj->email.">";
$sendto = str_replace(',',' ',dolGetFirstLastname($obj->firstname, $obj->lastname))." <".$obj->email.">";

// Make substitutions on topic and body. From (AA=YY;BB=CC;...) we keep YY, CC, ...
$other=explode(';',$obj->other);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/prelevement/class/bonprelevement.class.php
Expand Up @@ -540,7 +540,7 @@ function set_infotrans($user, $date, $method)
$this->method_trans = $method;
$langs->load('withdrawals');
$subject = $langs->trans("InfoTransSubject", $this->ref);
$message = $langs->trans("InfoTransMessage", $this->ref, $user->firstname, $user->lastname);
$message = $langs->trans("InfoTransMessage", $this->ref, dolGetFirstLastname($user->firstname, $user->lastname));
$message .=$langs->trans("InfoTransData", price($this->amount), $this->methodes_trans[$this->method_trans], dol_print_date($date,'day'));

// TODO Call trigger to create a notification using notification module
Expand Down
15 changes: 1 addition & 14 deletions htdocs/core/class/commonobject.class.php
Expand Up @@ -73,21 +73,8 @@ function getFullName($langs,$option=0,$nameorder=-1,$maxlen=0)
else $ret.=$this->civilite_id.' ';
}

// If order not defined, we use the setup
if ($nameorder < 0) $nameorder=(empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION));
$ret.=dolGetFirstLastname($firstname, $lastname, $nameorder);

if ($nameorder)
{
$ret.=$firstname;
if ($firstname && $lastname) $ret.=' ';
$ret.=$lastname;
}
else
{
$ret.=$lastname;
if ($firstname && $lastname) $ret.=' ';
$ret.=$firstname;
}
return dol_trunc($ret,$maxlen);
}

Expand Down
22 changes: 19 additions & 3 deletions htdocs/core/lib/functions.lib.php
Expand Up @@ -3643,13 +3643,29 @@ function get_date_range($date_start,$date_end,$format = '',$outputlangs='')
*
* @param string $firstname Firstname
* @param string $lastname Lastname
* @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname
* @return string Firstname + lastname or Lastname + firstname
*/
function dolGetFirstLastname($firstname,$lastname)
function dolGetFirstLastname($firstname,$lastname,$nameorder=-1)
{
global $conf;
if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) return $firstname.' '.$lastname;
else return $lastname.' '.$firstname;

$ret='';
// If order not defined, we use the setup
if ($nameorder < 0) $nameorder=(empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION));
if ($nameorder)
{
$ret.=$firstname;
if ($firstname && $lastname) $ret.=' ';
$ret.=$lastname;
}
else
{
$ret.=$lastname;
if ($firstname && $lastname) $ret.=' ';
$ret.=$firstname;
}
return $ret;
}


Expand Down
8 changes: 4 additions & 4 deletions htdocs/holiday/fiche.php
Expand Up @@ -319,7 +319,7 @@
}

$message.= "\n";
$message.= "- ".$langs->transnoentitiesnoconv("Name")." : ".$expediteur->firstname." ".$expediteur->lastname."\n";
$message.= "- ".$langs->transnoentitiesnoconv("Name")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n";
$message.= "- ".$langs->transnoentitiesnoconv("Period")." : ".dol_print_date($cp->date_debut,'day')." ".$langs->transnoentitiesnoconv("To")." ".dol_print_date($cp->date_fin,'day')."\n";
$message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/fiche.php?id=".$cp->rowid."\n\n";
$message.= "\n";
Expand Down Expand Up @@ -400,7 +400,7 @@
$message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n";
$message.= "\n";
$message.= "Votre demande de congés payés du ".dol_print_date($cp->date_debut,'day')." au ".dol_print_date($cp->date_fin,'day')." vient d'être validée!\n";
$message.= "- ".$langs->transnoentitiesnoconv("ValidatedBy")." : ".$expediteur->firstname." ".$expediteur->lastname."\n";
$message.= "- ".$langs->transnoentitiesnoconv("ValidatedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n";
$message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/fiche.php?id=".$cp->rowid."\n\n";
$message.= "\n";

Expand Down Expand Up @@ -469,7 +469,7 @@
$message.= "\n";
$message.= "Votre demande de congés payés ".dol_print_date($cp->date_debut,'day')." ".$langs->transnoentitiesnoconv("To")." ".dol_print_date($cp->date_fin,'day')." vient d'être refusée pour le motif suivant :\n";
$message.= $_POST['detail_refuse']."\n\n";
$message.= "- ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".$expediteur->firstname." ".$expediteur->lastname."\n";
$message.= "- ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n";
$message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/fiche.php?id=".$cp->rowid."\n\n";
$message.= "\n";

Expand Down Expand Up @@ -539,7 +539,7 @@
$message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n";
$message.= "\n";
$message.= "Votre demande de congés ".dol_print_date($cp->date_debut,'day')." ".$langs->transnoentitiesnoconv("To")." ".dol_print_date($cp->date_fin,'day')." va été annulée.\n";
$message.= "- ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".$expediteur->firstname." ".$expediteur->lastname."\n";
$message.= "- ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n";
$message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/fiche.php?id=".$cp->rowid."\n\n";
$message.= "\n";

Expand Down
2 changes: 1 addition & 1 deletion htdocs/mailmanspip/class/mailmanspip.class.php
Expand Up @@ -176,7 +176,7 @@ function add_to_spip($object)
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
$mdpass=dol_hash($object->pass);
$htpass=crypt($object->pass,makesalt());
$query = "INSERT INTO spip_auteurs (nom, email, login, pass, htpass, alea_futur, statut) VALUES(\"".$object->firstname." ".$object->lastname."\",\"".$object->email."\",\"".$object->login."\",\"$mdpass\",\"$htpass\",FLOOR(32000*RAND()),\"1comite\")";
$query = "INSERT INTO spip_auteurs (nom, email, login, pass, htpass, alea_futur, statut) VALUES(\"".dolGetFirstLastname($object->firstname,$object->lastname)."\",\"".$object->email."\",\"".$object->login."\",\"$mdpass\",\"$htpass\",FLOOR(32000*RAND()),\"1comite\")";

$result = $mydb->query($query);

Expand Down
4 changes: 2 additions & 2 deletions htdocs/public/donations/donateurs_code.php
Expand Up @@ -81,10 +81,10 @@ function llxFooterVierge() { print '</body></html>'; }
$objp = $db->fetch_object($resql);

$var=!$var;
print "<TR $bc[$var]>";
print "<tr ".$bc[$var].">";
if ($objp->public)
{
print "<td>".$objp->firstname." ".$objp->lastname." ".$objp->societe."</td>\n";
print "<td>".dolGetFirstLastname($objp->firstname, $objp->lastname)." ".$objp->societe."</td>\n";
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion htdocs/public/members/public_list.php
Expand Up @@ -140,7 +140,7 @@ function llxFooterVierge()
$objp = $db->fetch_object($result);
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="public_card.php?id='.$objp->rowid.'">'.$objp->firstname.' '.$objp->lastname.($objp->societe?' / '.$objp->societe:'').'</a></td>'."\n";
print '<td><a href="public_card.php?id='.$objp->rowid.'">'.dolGetFirstLastname($obj->firstname, $obj->lastname).($objp->societe?' / '.$objp->societe:'').'</a></td>'."\n";
//print "<td>$objp->naiss</td>\n"; // est-ce nécessaire ??
print '<td>'.$objp->email.'</td>'."\n";
print '<td>'.$objp->zip.'</td>'."\n";
Expand Down
6 changes: 3 additions & 3 deletions htdocs/societe/class/societe.class.php
Expand Up @@ -1616,7 +1616,7 @@ function contact_property_array($mode='email')
$obj = $this->db->fetch_object($resql);
if ($mode == 'email') $property=$obj->email;
else if ($mode == 'mobile') $property=$obj->phone_mobile;
$contact_property[$obj->rowid] = trim($obj->firstname." ".$obj->lastname)." &lt;".$property."&gt;";
$contact_property[$obj->rowid] = trim(dolGetFirstLastname($obj->firstname,$obj->lastname))." &lt;".$property."&gt;";
$i++;
}
}
Expand Down Expand Up @@ -1649,7 +1649,7 @@ function contact_array()
while ($i < $nump)
{
$obj = $this->db->fetch_object($resql);
$contacts[$obj->rowid] = $obj->firstname." ".$obj->lastname;
$contacts[$obj->rowid] = dolGetFirstLastname($obj->firstname,$obj->lastname);
$i++;
}
}
Expand Down Expand Up @@ -1685,7 +1685,7 @@ function contact_get_property($rowid,$mode)
{
$obj = $this->db->fetch_object($resql);

if ($mode == 'email') $contact_property = "$obj->firstname $obj->lastname <$obj->email>";
if ($mode == 'email') $contact_property = dolGetFirstLastname($obj->firstname, $obj->lastname)." <".$obj->email.">";
else if ($mode == 'mobile') $contact_property = $obj->phone_mobile;
}
return $contact_property;
Expand Down
4 changes: 2 additions & 2 deletions htdocs/societe/commerciaux.php
Expand Up @@ -188,7 +188,7 @@

print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->rowid.'">';
print img_object($langs->trans("ShowUser"),"user").' ';
print $obj->firstname." " .$obj->lastname."\n";
print dolGetFirstLastname($obj->firstname, $obj->lastname)."\n";
print '</a>&nbsp;';
if ($user->rights->societe->creer)
{
Expand Down Expand Up @@ -254,7 +254,7 @@
print "<tr $bc[$var]><td>";
print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->rowid.'">';
print img_object($langs->trans("ShowUser"),"user").' ';
print $obj->firstname." " .$obj->lastname."\n";
print dolGetFirstLastname($obj->firstname, $obj->lastname)."\n";
print '</a>';
print '</td><td>'.$obj->login.'</td>';
print '<td><a href="commerciaux.php?socid='.$_GET["socid"].'&amp;commid='.$obj->rowid.'">'.$langs->trans("Add").'</a></td>';
Expand Down
8 changes: 4 additions & 4 deletions htdocs/societe/notify/index.php
Expand Up @@ -93,9 +93,9 @@

$var=!$var;

print "<tr $bc[$var]>";
print "<td><a href=\"fiche.php?socid=".$obj->socid."\">$obj->nom</A></td>\n";
print "<td>".$obj->firstname." ".$obj->lastname."</td>\n";
print "<tr ".$bc[$var].">";
print "<td><a href=\"fiche.php?socid=".$obj->socid."\">".$obj->nom."</a></td>\n";
print "<td>".dolGetFirstLastname($obj->firstname, $obj->lastname)."</td>\n";
print "<td>".$obj->titre."</td>\n";
print "</tr>\n";
$i++;
Expand All @@ -108,7 +108,7 @@
dol_print_error($db);
}

$db->close();

llxFooter();
$db->close();
?>
2 changes: 1 addition & 1 deletion scripts/emailings/cron-mailing-send.php
Expand Up @@ -120,7 +120,7 @@
$obj2 = $db->fetch_object($resql);

// sendto en RFC2822
$sendto = str_replace(',',' ',$obj2->firstname." ".$obj2->lastname) ." <".$obj2->email.">";
$sendto = str_replace(',',' ',dolGetFirstLastname($obj2->firstname, $obj2->lastname)) ." <".$obj2->email.">";

// Make subtsitutions on topic and body
$other=explode(';',$obj2->other);
Expand Down
2 changes: 1 addition & 1 deletion scripts/emailings/mailing-send.php
Expand Up @@ -127,7 +127,7 @@
$obj = $db->fetch_object($resql);

// sendto en RFC2822
$sendto = str_replace(',',' ',$obj->firstname." ".$obj->lastname) ." <".$obj->email.">";
$sendto = str_replace(',',' ',dolGetFirstLastname($obj->firstname, $obj->lastname) ." <".$obj->email.">";

// Make subtsitutions on topic and body
$other=explode(';',$obj->other);
Expand Down

0 comments on commit 5bc6631

Please sign in to comment.