Skip to content

Commit

Permalink
Fix building search query if some fields are set for strict search (B…
Browse files Browse the repository at this point in the history
…ug #12272).
  • Loading branch information
yunosh committed Jan 19, 2016
1 parent 0bd4b2f commit a8fd4ca
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions turba/lib/Driver.php
Expand Up @@ -601,14 +601,9 @@ public function search(array $search_criteria, $sort_order = null,
array $custom_strict = array(), $match_begin = false,
$count_only = false)
{
/* If we are not using Horde_Share, enforce the requirement that the
* current user must be the owner of the addressbook. */
$search_criteria['__owner'] = $this->getContactOwner();
$strict_fields = array($this->toDriver('__owner') => true);
$custom_strict_fields = array();

/* Add any fields that must match exactly for this source to the
* $strict_fields array. */
$strict_fields = $custom_strict_fields = array();
foreach ($this->strict as $strict_field) {
$strict_fields[$strict_field] = true;
}
Expand All @@ -627,6 +622,19 @@ public function search(array $search_criteria, $sort_order = null,
$fields = $this->makeSearch($search_criteria, $search_type,
$strict_fields, $match_begin, $custom_strict_fields);

/* If we are not using Horde_Share, enforce the requirement that the
* current user must be the owner of the addressbook. */
$fields = array(
'AND' => array(
$fields,
array(
'field' => $this->toDriver('__owner'),
'op' => '=',
'test' => $this->getContactOwner()
)
)
);

if (in_array('email', $return_fields) &&
!in_array('emails', $return_fields)) {
$return_fields[] = 'emails';
Expand Down

0 comments on commit a8fd4ca

Please sign in to comment.