Skip to content

Commit

Permalink
Only ask for a smaller subset of fields when performing a RI search.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Jan 23, 2014
1 parent 726a5a0 commit ec529c6
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions framework/Core/lib/Horde/Core/ActiveSync/Connector.php
Expand Up @@ -324,6 +324,9 @@ public function contacts_getActionTimestamp($uid, $action, $addressbook = null)
* @param array $options Additional options:
* - pictures: (boolean) Include photos in results.
* DEFAULT: false (Do not include photos).
* - recipient_cache_search: (boolean) If true, this is a RI cache search,
* should only search the 'email' field and only return a small subset
* of fields.
*
* @return array The search results.
*/
Expand All @@ -333,17 +336,22 @@ public function contacts_search($query, array $options = array())
return array();
}

$fields = array($gal => array('name', 'alias', 'email', 'firstname', 'lastname',
'company', 'homePhone', 'workPhone', 'cellPhone', 'title',
'office'));
if (!empty($options['recipient_cache_search'])) {
$return_fields = array($gal => array('name', 'alias', 'email'));
} else {
$return_fields = array($gal => array('name', 'alias', 'email', 'firstname', 'lastname',
'company', 'homePhone', 'workPhone', 'cellPhone', 'title',
'office'));
}
if (!empty($options['pictures'])) {
$fields[$gal][] = 'photo';
}
$opts = array(
'matchBegin' => true,
'forceSource' => true,
'sources' => array($gal),
'returnFields' => $fields
'returnFields' => $return_fields,
'fields' => !empty($options['recipient_cache_search']) ? array('email') : array()
);

return $this->_registry->contacts->search($query, $opts);
Expand Down

0 comments on commit ec529c6

Please sign in to comment.