fix invalid SQL during installation (no grants) and a PHP Warning about scalar $filter[owner]

This commit is contained in:
Ralf Becker 2019-03-09 11:44:55 +01:00
parent 16ea4e6e8d
commit da26d0973e

View File

@ -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 != 0'; // in case there have been accounts in sql previously
} }
$filter[] = "(".$this->table_name.".contact_owner=".(int)$GLOBALS['egw_info']['user']['account_id']. $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 (". " 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') if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== 'none')
{ {
@ -527,7 +528,7 @@ class Sql extends Api\Storage
unset($filter['owner']); unset($filter['owner']);
} }
// for an owner filter, which does NOT include current user, filter out private entries // 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; $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 != 0'; // in case there have been accounts in sql previously
} }
$filter[] = "($this->table_name.contact_owner=".(int)$GLOBALS['egw_info']['user']['account_id']. $filter[] = "($this->table_name.contact_owner=".(int)$GLOBALS['egw_info']['user']['account_id'].
" OR contact_private=0 AND $this->table_name.contact_owner IN (". ($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)"; implode(',',array_keys($this->grants)).")" : '').
$groupmember_sql." OR $this->table_name.contact_owner IS NULL)";
} }
} }
if (isset($filter['list'])) if (isset($filter['list']))