Allow a different server address for the POP server to be configured when using POP...
[squirrelmail.git] / functions / abook_local_file.php
index 4b2b9a751407b608cab107ec1fa4bbb7dc77dede..22a7932b6b275b574c8e933637aa8e9a9b0b4776 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * abook_local_file.php
  *
- * @copyright © 1999-2006 The SquirrelMail Project Team
+ * @copyright © 1999-2007 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
@@ -97,7 +97,7 @@ class abook_local_file extends addressbook_backend {
      * @return bool
      */
     function abook_local_file($param) {
-        $this->sname = _("Personal address book");
+        $this->sname = _("Personal Address Book");
         $this->umask = Umask();
 
         if(is_array($param)) {
@@ -317,16 +317,29 @@ class abook_local_file extends addressbook_backend {
     }
 
     /**
-     * Lookup alias
-     * @param string $alias alias
-     * @return array search results
+     * Lookup an address by the indicated field.
+     *
+     * @param string  $value The value to look up
+     * @param integer $field The field to look in, should be one
+     *                       of the SM_ABOOK_FIELD_* constants
+     *                       defined in include/constants.php
+     *                       (OPTIONAL; defaults to nickname field)
+     *                       NOTE: uniqueness is only guaranteed
+     *                       when the nickname field is used here;
+     *                       otherwise, the first matching address
+     *                       is returned.
+     *
+     * @return array Array with lookup results when the value
+     *               was found, an empty array if the value was
+     *               not found.
+     *
      */
-    function lookup($alias) {
-        if(empty($alias)) {
+    function lookup($value, $field=SM_ABOOK_FIELD_NICKNAME) {
+        if(empty($value)) {
             return array();
         }
 
-        $alias = strtolower($alias);
+        $value = strtolower($value);
 
         $this->open();
         @rewind($this->filehandle);
@@ -341,7 +354,7 @@ class abook_local_file extends addressbook_backend {
                 $oTemplate->display('footer.tpl');
                 die();
             } else {
-                if(strtolower($row[0]) == $alias) {
+                if(strtolower($row[$field]) == $value) {
                    return array('nickname'  => $row[0],
                       'name'      => $this->fullname($row[1], $row[2]),
                       'firstname' => $row[1],