fixed ldap backend not working for multiple owners

This commit is contained in:
Ralf Becker 2012-02-29 13:36:24 +00:00
parent 7bc098d7c3
commit 4711bc2ac1

View File

@ -590,6 +590,21 @@ class addressbook_ldap
#$limit = $need_full_no_count ? 0 : $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'];
#return parent::read($start,$limit,$fields,$query,$filter,$sort,$order);
if (is_array($filter['owner']))
{
if (count($filter['owner']) == 1)
{
$filter['owner'] = array_shift($filter['owner']);
}
else
{
// multiple addressbooks happens currently only via CardDAV or eSync
// currently we query all contacts and remove not matching ones (not the most efficient way to do it)
$owner_filter = $filter['owner'];
unset($filter['owner']);
}
}
if((int)$filter['owner'])
{
if (!($accountName = $GLOBALS['egw']->accounts->id2name($filter['owner']))) return false;
@ -662,6 +677,18 @@ class addressbook_ldap
{
return $rows;
}
// only return certain owners --> unset not matching ones
if ($owner_filter)
{
foreach($rows as $k => $row)
{
if (!in_array($row['owner'],$owner_filter))
{
unset($rows[$k]);
--$this->total;
}
}
}
if ($order_by)
{
$order = array();