From 5b1c13d395ef532c720be940fcd75b1236027c72 Mon Sep 17 00:00:00 2001 From: tokul Date: Tue, 15 Aug 2006 17:01:41 +0000 Subject: [PATCH] fullname layout is controled in gettext string instead of $squirrelmail_language removed unfinished pagination code added list_addr() error handling git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11593 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/addressbook.php | 21 +++++++++++++-------- src/addressbook.php | 20 ++++++++++++-------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/functions/addressbook.php b/functions/addressbook.php index 59256d7d..14ffb3e8 100644 --- a/functions/addressbook.php +++ b/functions/addressbook.php @@ -679,7 +679,7 @@ class AddressBook { /** * Return all addresses * @param integer $bnum backend number - * @return array search results + * @return mixed array with search results or boolean false on error. */ function list_addr($bnum = -1) { $ret = array(); @@ -1001,18 +1001,23 @@ class addressbook_backend { /** * Creates full name from given name and surname * - * Handles name order differences + * Handles name order differences. Function always runs in SquirrelMail gettext domain. + * Plugins don't have to switch domains before calling this function. * @param string $firstname given name * @param string $lastname surname * @return string full name * @since 1.5.2 */ function fullname($firstname,$lastname) { - global $squirrelmail_language; - if ($squirrelmail_language=='ja_JP') { - return trim($lastname . ' ' . $firstname); - } else { - return trim($firstname . ' ' . $lastname); - } + /** + * i18n: allows to control fullname layout in address book listing + * first %s is for first name, second %s is for last name. + * Translate it to '%2$s %1$s', if surname must be displayed first in your language. + * Please note that variables can be set to empty string and extra formating + * (for example '%2$s, %1$s' as in 'Smith, John') might break. Use it only for + * setting name and surname order. scripts will remove all prepended and appended + * whitespace. + */ + return trim(sprintf(dgettext('squirrelmail',"%s %s"),$firstname,$lastname)); } } diff --git a/src/addressbook.php b/src/addressbook.php index 4edf5a72..43ad6978 100644 --- a/src/addressbook.php +++ b/src/addressbook.php @@ -239,6 +239,7 @@ if (!empty($formerror)) { /* Display the address management part */ $addresses = array(); +// TODO: remove while. list_addr() should be called only for $current_backend while (list($k, $backend) = each ($abook->backends)) { $a = array(); $a['BackendID'] = $backend->bnum; @@ -247,15 +248,18 @@ while (list($k, $backend) = each ($abook->backends)) { $a['Addresses'] = array(); $alist = $abook->list_addr($backend->bnum); - usort($alist,'alistcmp'); - $start = 200; - $count = count($alist); - if ($start >= $count) $start = 0; - $alist = array_slice($alist,$start,15); - - $a['Addresses'] = formatAddressList($alist); + + /* check return (array with data or boolean false) */ + if (is_array($alist)) { + usort($alist,'alistcmp'); + + $a['Addresses'] = formatAddressList($alist); - $addresses[$backend->bnum] = $a; + $addresses[$backend->bnum] = $a; + } else { + // list_addr() returns boolean + plain_error_message(nl2br(htmlspecialchars($abook->error))); + } } -- 2.25.1