From 6551a71b41ab26beb825f620012479287803a6d4 Mon Sep 17 00:00:00 2001 From: nathangray Date: Wed, 22 Mar 2017 14:23:05 -0600 Subject: [PATCH] Addressbook - Fix filtering by addressbook in duplicates view. --- api/src/Contacts/Sql.php | 16 ++++++++-------- api/src/Contacts/Storage.php | 7 ++++++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/api/src/Contacts/Sql.php b/api/src/Contacts/Sql.php index 3871a78f43..92c1aad423 100644 --- a/api/src/Contacts/Sql.php +++ b/api/src/Contacts/Sql.php @@ -296,21 +296,21 @@ class Sql extends Api\Storage $join .= 'a2.contact_tid != \'D\' AND '; } // add filter for read ACL in sql, if user is NOT the owner of the addressbook - if ($param['owner'] && $param['owner'] == $GLOBALS['egw_info']['user']['account_id']) + if (array_key_exists('owner',$param) && $param['owner'] == $GLOBALS['egw_info']['user']['account_id']) { - $filter['owner'] = $param['owner']; - $join .= 'a2.contact_owner = ' . $this->db->quote($filter['owner']) . ' AND '; + $filter[$this->table_name.'.contact_owner'] = $param['owner']; + $join .= 'a2.contact_owner = ' . $this->db->quote($param['owner']) . ' AND '; } else { // we have no private grants in addressbook at the moment, they have then to be added here too - if ($param['owner']) + if (array_key_exists('owner', $param)) { - if (!$this->grants[(int) $filter['owner']]) return false; // we have no access to that addressbook + if (!$this->grants[(int) $param['owner']]) return false; // we have no access to that addressbook - $filter['owner'] = $param['owner']; - $filter['private'] = 0; - $join .= 'a2.contact_owner = ' . $this->db->quote($filter['owner']) . ' AND '; + $filter[$this->table_name.'.contact_owner'] = $param['owner']; + $filter[$this->table_name.'.private'] = 0; + $join .= 'a2.contact_owner = ' . $this->db->quote($param['owner']) . ' AND '; $join .= 'a2.contact_private = ' . $this->db->quote($filter['private']) . ' AND '; } else // search all addressbooks, incl. accounts diff --git a/api/src/Contacts/Storage.php b/api/src/Contacts/Storage.php index 0232f720fd..74a0dccc07 100755 --- a/api/src/Contacts/Storage.php +++ b/api/src/Contacts/Storage.php @@ -866,7 +866,12 @@ class Storage // return all entries including deleted unset($param['col_filter']['tid']); } - if($param['col_filter']['owner']) + if(array_key_exists('filter', $param) && $param['filter'] != '') + { + $param['owner'] = $param['filter']; + unset($param['filter']); + } + if(array_key_exists('owner', $param['col_filter']) && $param['col_filter']['owner'] != '') { $param['owner'] = $param['col_filter']['owner']; unset($param['col_filter']['owner']);