From 18221503b656ba26f6f5a2c250fbc79d2afd79ac Mon Sep 17 00:00:00 2001 From: mgalgoci Date: Thu, 26 Aug 2004 18:47:29 +0000 Subject: [PATCH] - re-write display_fullname to be more readable and suck much less - add support for Lastname, Firstname username account views --- phpgwapi/inc/class.common.inc.php | 45 ++++++++++++++----------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/phpgwapi/inc/class.common.inc.php b/phpgwapi/inc/class.common.inc.php index d0d9e9e5eb..410759500a 100644 --- a/phpgwapi/inc/class.common.inc.php +++ b/phpgwapi/inc/class.common.inc.php @@ -464,42 +464,37 @@ $display = $GLOBALS['phpgw_info']['user']['preferences']['common']['account_display']; - if (!$firstname && !$lastname || $display == 'username') + if ($firstname && $lastname) { - return $lid; + $delimiter = ', '; } - if ($lastname) + else { - $a[] = $lastname; + $delimiter = ''; } - - if ($firstname) - { - $a[] = $firstname; - } - + $name = ''; switch($display) { - case 'all': - if ($lid) - { - $name = '['.$lid.'] '; - } - // fall-through + case 'firstname': + $name = $firstname . ' ' . $lastname; + break; case 'lastname': - $name .= implode(', ',$a); + $name = $lastname . $delimiter . $firstname; + break; + case 'username': + $name = $lid; break; case 'firstall': - if ($lid) - { - $name = ' ['.$lid.']'; - } - // fall-through - case 'firstname': - default: - $name = $firstname . ' ' . $lastname . $name; + $name = $firstname . ' ' . $lastname . ' ['.$lid.']'; break; + case 'lastall': + $name = $lastname . $delimiter . $firstname . ' ['.$lid.']'; + break; + case 'all': + /* fall through */ + default: + $name = '['.$lid.'] ' . $firstname . ' ' . $lastname; } return $name; }