Commit c5022b4c authored by mku's avatar mku

ZP-609 #comment Warnings when searching and GAL entry doesn't have an email address

git-svn-id: https://z-push.org/svn/z-push/trunk@1954 b7dd7b3b-3a3c-0410-9da9-bee62a6cc5b5
parent 26fa16e6
......@@ -976,9 +976,9 @@ class BackendZarafa implements IBackend, ISearchProvider {
* @throws StatusException
*/
public function GetGALSearchResults($searchquery, $searchrange){
// only return users from who the displayName or the username starts with $name
// only return users whose displayName or the username starts with $name
//TODO: use PR_ANR for this restriction instead of PR_DISPLAY_NAME and PR_ACCOUNT
$addrbook = mapi_openaddressbook($this->session);
$addrbook = $this->getAddressbook();
if ($addrbook)
$ab_entryid = mapi_ab_getdefaultdir($addrbook);
if ($ab_entryid)
......@@ -1011,12 +1011,16 @@ class BackendZarafa implements IBackend, ISearchProvider {
$querycnt = mapi_table_getrowcount($table);
//do not return more results as requested in range
$querylimit = (($rangeend + 1) < $querycnt) ? ($rangeend + 1) : $querycnt;
$items['range'] = ($querylimit > 0) ? $rangestart.'-'.($querylimit - 1) : '0-0';
$items['searchtotal'] = $querycnt;
if ($querycnt > 0)
$abentries = mapi_table_queryrows($table, array(PR_ACCOUNT, PR_DISPLAY_NAME, PR_SMTP_ADDRESS, PR_BUSINESS_TELEPHONE_NUMBER, PR_GIVEN_NAME, PR_SURNAME, PR_MOBILE_TELEPHONE_NUMBER, PR_HOME_TELEPHONE_NUMBER, PR_TITLE, PR_COMPANY_NAME, PR_OFFICE_LOCATION), $rangestart, $querylimit);
for ($i = 0; $i < $querylimit; $i++) {
if (!isset($abentries[$i][PR_SMTP_ADDRESS])) {
ZLog::Write(LOGLEVEL_WARN, sprintf("The GAL entry '%s' does not have an email address and will be ignored.", w2u($abentries[$i][PR_DISPLAY_NAME])));
continue;
}
$items[$i][SYNC_GAL_DISPLAYNAME] = w2u($abentries[$i][PR_DISPLAY_NAME]);
if (strlen(trim($items[$i][SYNC_GAL_DISPLAYNAME])) == 0)
......@@ -1055,6 +1059,9 @@ class BackendZarafa implements IBackend, ISearchProvider {
if (isset($abentries[$i][PR_OFFICE_LOCATION]))
$items[$i][SYNC_GAL_OFFICE] = w2u($abentries[$i][PR_OFFICE_LOCATION]);
}
$nrResults = count($items);
$items['range'] = ($nrResults > 0) ? $rangestart.'-'.($nrResults - 1) : '0-0';
$items['searchtotal'] = $nrResults;
return $items;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment