fullname layout is controled in gettext string instead of $squirrelmail_language
authortokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 15 Aug 2006 17:01:41 +0000 (17:01 +0000)
committertokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 15 Aug 2006 17:01:41 +0000 (17:01 +0000)
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
src/addressbook.php

index 59256d7d8a1994956dc614343bbc946b88a17f56..14ffb3e8e52c0646d64696d47d34272757c3a298 100644 (file)
@@ -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));
     }
 }
index 4edf5a72436c14c131e87a669d386bf22e2a66ec..43ad69785acd183e18a27bdfc535a2cc6b487df7 100644 (file)
@@ -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)));
+    }
 }