X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fabook_database.php;h=1e69af3a0c3ddcd2bd47289826b6c420073c9a7b;hb=bb63dfd1e580a5e8102f87ae26c62d90f91af3ed;hp=8294cf3eaa141c18fe1f0adeff578be6c586c5d2;hpb=503c7650d1e4178c3c7888d95dcae3777a93861e;p=squirrelmail.git diff --git a/functions/abook_database.php b/functions/abook_database.php index 8294cf3e..1e69af3a 100644 --- a/functions/abook_database.php +++ b/functions/abook_database.php @@ -295,6 +295,10 @@ class abook_database extends addressbook_backend { * 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 @@ -312,8 +316,13 @@ class abook_database extends addressbook_backend { return false; } + $db_field = $this->get_field_name($field); + if ($db_field == 'ERROR') { + return $this->set_error(sprintf(_("Unknown field name: %s"), $field)); + } + $query = sprintf("SELECT * FROM %s WHERE owner = '%s' AND LOWER(%s) = '%s'", - $this->table, $this->owner, $this->get_field_name($field), + $this->table, $this->owner, $db_field, $this->dbh->quoteString($value)); $res = $this->dbh->query($query);