X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=functions%2Fabook_local_file.php;h=d29474f6d4cdd8cae463283e6bb53af96d9cc88f;hp=65ae8256f24372c3976c47a07577a4cf65e7d68a;hb=e45a534b519914566980a2ed45bb552faf75255d;hpb=4b5049de2fa934c45599d6e4c74bf2bbee10d34d diff --git a/functions/abook_local_file.php b/functions/abook_local_file.php index 65ae8256..d29474f6 100644 --- a/functions/abook_local_file.php +++ b/functions/abook_local_file.php @@ -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)) { @@ -151,7 +151,7 @@ class abook_local_file extends addressbook_backend { $this->error = ''; $file = $this->filename; $create = $this->create; - $fopenmode = (($this->writeable && is_writable($file)) ? 'a+' : 'r'); + $fopenmode = (($this->writeable && sq_is_writable($file)) ? 'a+' : 'r'); /* Return true is file is open and $new is unset */ if($this->filehandle && !$new) { @@ -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],