From 82ea4fe2deacb78a2efbc517ed57c6b1ae6d3fbd Mon Sep 17 00:00:00 2001 From: nathangray Date: Thu, 19 Jul 2018 14:54:05 -0600 Subject: [PATCH] * Addressbook - add filtering by distribution list for organisations --- addressbook/inc/class.addressbook_ui.inc.php | 15 ++++++++++++--- api/src/Contacts/Sql.php | 14 ++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index 04d08ab26a..8cfd99fc14 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -888,8 +888,6 @@ class addressbook_ui extends addressbook_bo // Just switched from contact view, update actions $query['actions'] = $this->get_actions($query['col_filter']['tid']); } - unset($query['col_filter']['list']); // does not work together - $query['no_filter2'] = true; // switch the distribution list selection off $query['template'] = $query['grouped_view'] == 'duplicates' ? 'addressbook.index.duplicate_rows' : 'addressbook.index.org_rows'; @@ -912,9 +910,20 @@ class addressbook_ui extends addressbook_bo $query['order'] = 'org_name'; } $query['org_view'] = $query['grouped_view']; - $rows = parent::organisations($query); + // switch the distribution list selection off for ldap + if($this->contact_repository != 'sql') + { + $query['no_filter2'] = true; + unset($query['col_filter']['list']); // does not work here + } + else + { + $rows = parent::organisations($query); + } break; case 'addressbook.index.duplicate_rows': + $query['no_filter2'] = true; // switch the distribution list selection off + unset($query['col_filter']['list']); // does not work for duplicates $rows = parent::duplicates($query); break; } diff --git a/api/src/Contacts/Sql.php b/api/src/Contacts/Sql.php index 24132adfbc..67aa68b8ff 100644 --- a/api/src/Contacts/Sql.php +++ b/api/src/Contacts/Sql.php @@ -170,6 +170,20 @@ class Sql extends Api\Storage { $filter[] = "org_name != ''";// AND org_name IS NOT NULL"; } + if (isset($filter['list'])) + { + if ($filter['list'] < 0) + { + $join .= " JOIN egw_acl ON $this->table_name.account_id=acl_account AND acl_appname='phpgw_group' AND ". + $this->db->expression('egw_acl', array('acl_location' => $filter['list'])); + } + else + { + $join .= " JOIN $this->ab2list_table ON $this->table_name.contact_id=$this->ab2list_table.contact_id AND ". + $this->db->expression($this->ab2list_table, array('list_id' => $filter['list'])); + } + unset($filter['list']); + } $sort = $param['sort'] == 'DESC' ? 'DESC' : 'ASC'; list(,$by) = explode(',',$param['org_view']);