From da26d0973eb5c5781304da2ad343c7684ad3a598 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sat, 9 Mar 2019 11:44:55 +0100 Subject: [PATCH] fix invalid SQL during installation (no grants) and a PHP Warning about scalar $filter[owner] --- api/src/Contacts/Sql.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/api/src/Contacts/Sql.php b/api/src/Contacts/Sql.php index 8954b28a38..4a875457f2 100644 --- a/api/src/Contacts/Sql.php +++ b/api/src/Contacts/Sql.php @@ -146,8 +146,9 @@ class Sql extends Api\Storage $filter[] = $this->table_name.'.contact_owner != 0'; // in case there have been accounts in sql previously } $filter[] = "(".$this->table_name.".contact_owner=".(int)$GLOBALS['egw_info']['user']['account_id']. + (!$this->grants ? ')' : " OR contact_private=0 AND ".$this->table_name.".contact_owner IN (". - implode(',',array_keys($this->grants))."))"; + implode(',',array_keys($this->grants))."))"); } if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== 'none') { @@ -527,7 +528,7 @@ class Sql extends Api\Storage unset($filter['owner']); } // for an owner filter, which does NOT include current user, filter out private entries - elseif (!in_array($GLOBALS['egw_info']['user']['account_id'],$filter['owner'])) + elseif (!in_array($GLOBALS['egw_info']['user']['account_id'], (array)$filter['owner'])) { $filter['private'] = 0; } @@ -546,8 +547,9 @@ class Sql extends Api\Storage $filter[] = $this->table_name.'.contact_owner != 0'; // in case there have been accounts in sql previously } $filter[] = "($this->table_name.contact_owner=".(int)$GLOBALS['egw_info']['user']['account_id']. - " OR contact_private=0 AND $this->table_name.contact_owner IN (". - implode(',',array_keys($this->grants)).") $groupmember_sql OR $this->table_name.contact_owner IS NULL)"; + ($this->grants ? " OR contact_private=0 AND $this->table_name.contact_owner IN (". + implode(',',array_keys($this->grants)).")" : ''). + $groupmember_sql." OR $this->table_name.contact_owner IS NULL)"; } } if (isset($filter['list']))