X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Faddressbook.php;h=45f586b38b7e0d9da0a5709349c1e5feebe8b429;hb=6b6381715922c24dc8664cc62464096814d6a291;hp=bafa53be7a4e8aeb18e96195a2afe4c1bdb34a56;hpb=1ed2b1e0cfb1d6912360758eec183562c1d86c99;p=squirrelmail.git diff --git a/functions/addressbook.php b/functions/addressbook.php index bafa53be..45f586b3 100644 --- a/functions/addressbook.php +++ b/functions/addressbook.php @@ -116,36 +116,49 @@ // Return a list of addresses matching expression in // all backends of a given type. - function search($expression, $btype = "") { + function search($expression, $bnum = -1) { $ret = array(); $this->error = ""; - $sel = $this->get_backend_list($btype); - $failed = 0; - for($i = 0 ; $i < sizeof($sel) ; $i++) { - $backend = &$sel[$i]; - $backend->error = ""; - $res = $backend->search($expression); - if(is_array($res)) { - $ret = array_merge($ret, $res); - } else { - $this->error = $this->error . "
\n". $backend->error; - $failed++; + // Search all backends + if($bnum == -1) { + $sel = $this->get_backend_list(""); + $failed = 0; + for($i = 0 ; $i < sizeof($sel) ; $i++) { + $backend = &$sel[$i]; + $backend->error = ""; + $res = $backend->search($expression); + if(is_array($res)) { + $ret = array_merge($ret, $res); + } else { + $this->error = $this->error . "
\n". $backend->error; + $failed++; + } } + + // Only fail if all backends failed + if($failed >= sizeof($sel)) + return false; + } - // Only fail if all backends failed - if($failed >= sizeof($sel)) - return false; + // Search only one backend + else { + $ret = $this->backends[$bnum]->search($expression); + if(!is_array($ret)) { + $this->error = $this->error . "
\n". $this->backends[$bnum]->error; + return false; + } + } return $ret; } // Return a sorted search - function s_search($expression, $btype = "") { + function s_search($expression, $bnum = -1) { - $ret = $this->search($expression, $btype); + $ret = $this->search($expression, $bnum); if(!is_array($ret)) return $ret; @@ -198,10 +211,14 @@ // Return all addresses - function list_addr() { + function list_addr($bnum = -1) { $ret = array(); - $sel = $this->get_backend_list("local"); + if($bnum == -1) + $sel = $this->get_backend_list("local"); + else + $sel = array(0 => &$this->backends[$bnum]); + for($i = 0 ; $i < sizeof($sel) ; $i++) { $backend = &$sel[$i]; $backend->error = "";