From b04eb80b39a07879d0650a8e2b93701c9d0f09a7 Mon Sep 17 00:00:00 2001 From: nathangray Date: Tue, 21 Nov 2017 11:07:50 -0700 Subject: [PATCH] Addressbook - fix show/hide account preference bugs - account filter was missing for show active - preference changed to match current value --- addressbook/inc/class.addressbook_hooks.inc.php | 2 +- addressbook/lang/egw_de.lang | 3 +++ api/src/Contacts.php | 2 +- api/src/Contacts/Sql.php | 12 ++++++------ 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/addressbook/inc/class.addressbook_hooks.inc.php b/addressbook/inc/class.addressbook_hooks.inc.php index 0d0ce68b95..4cba075624 100644 --- a/addressbook/inc/class.addressbook_hooks.inc.php +++ b/addressbook/inc/class.addressbook_hooks.inc.php @@ -142,7 +142,7 @@ class addressbook_hooks } $settings['hide_accounts'] = array( 'type' => 'select', - 'values' => array('1' => lang('Hide all accounts'), 'deactivated' => lang('Show active accounts'), '0' => lang('Show all accounts')), + 'values' => array('1' => lang('Hide all accounts'), '0' => lang('Show active accounts'), 'none' => lang('Show all accounts')), 'label' => 'Hide accounts from addressbook', 'name' => 'hide_accounts', 'help' => 'Hides accounts completly from the adressbook.', diff --git a/addressbook/lang/egw_de.lang b/addressbook/lang/egw_de.lang index 9ae2aafc7e..c30f5cbc49 100644 --- a/addressbook/lang/egw_de.lang +++ b/addressbook/lang/egw_de.lang @@ -274,6 +274,7 @@ grant addressbook access common de Berechtigungen group %1 addressbook de Gruppe %1 h addressbook de h hide accounts from addressbook addressbook de Benutzer im Adressbuch ausblenden +hide all accounts addressbook de Zeigt keine Benutzer an hides accounts completly from the adressbook. addressbook de Entfernt die Benutzer komplett aus dem Adressbuch. history logging admin de Verfolgung der Änderungen home address addressbook de Privatadresse @@ -441,6 +442,8 @@ set full name and file as field in contacts of all users (either all or only emp set only full name addressbook de Nur vollen Namen setzen should the columns photo and home address always be displayed, even if they are empty. addressbook de Sollen die Spalten Foto und Privatadresse immer angezeigt werden, auch wenn sie leer sind? show addressbook de Anzeigen +show active accounts addressbook de Zeigt nur aktive Benutzer an +show all accounts addressbook de Zeigt alle Benutzer an show birthday reminders on main screen addressbook de Geburtstagserinnerungen auf der Startseite anzeigen show infolog entries for this organisation addressbook de InfoLog Einträge dieser Organisation anzeigen show the contacts of this organisation addressbook de Kontakte dieser Organisation anzeigen diff --git a/api/src/Contacts.php b/api/src/Contacts.php index 5093291ac8..333919976c 100755 --- a/api/src/Contacts.php +++ b/api/src/Contacts.php @@ -379,7 +379,7 @@ class Contacts extends Contacts\Storage $addressbooks += $to_sort; } if ($required != Acl::ADD && // do NOT allow to set accounts as default addressbook (AB can add accounts) - !$preferences['addressbook']['hide_accounts'] && ( + $preferences['addressbook']['hide_accounts'] !== '1' && ( ($grants[0] & $required) == $required || $preferences['common']['account_selection'] == 'groupmembers' && $this->account_repository != 'ldap' && ($required & Acl::READ))) diff --git a/api/src/Contacts/Sql.php b/api/src/Contacts/Sql.php index c107e1cd3d..beb60df717 100644 --- a/api/src/Contacts/Sql.php +++ b/api/src/Contacts/Sql.php @@ -149,10 +149,10 @@ class Sql extends Api\Storage " OR contact_private=0 AND ".$this->table_name.".contact_owner IN (". implode(',',array_keys($this->grants))."))"; } - if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) + if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== 'none') { $join .= self::ACCOUNT_ACTIVE_JOIN; - if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === 'deactivated') + if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '0') { $filter[] = str_replace('UNIX_TIMESTAMP(NOW())',time(),self::ACOUNT_ACTIVE_FILTER); } @@ -364,9 +364,9 @@ class Sql extends Api\Storage implode('+', $extra) . ' AS match_count' ); $join .= $this->db->column_data_implode(' OR ',$join_fields) . ')'; - if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) + if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== 'none') { - if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === 'deactivated') + if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '0') { $join .=' LEFT JOIN egw_accounts AS account_1 ON egw_addressbook.account_id=account_1.account_id '; $join .=' LEFT JOIN egw_accounts AS account_2 ON egw_addressbook.account_id=account_2.account_id '; @@ -553,10 +553,10 @@ class Sql extends Api\Storage // add join to show only active accounts (only if accounts are shown and in sql and we not already join the accounts table, eg. used by admin) if ((is_array($owner) ? in_array(0, $owner) : !$owner) && substr($this->account_repository,0,3) == 'sql' && strpos($join,$GLOBALS['egw']->accounts->backend->table) === false && !array_key_exists('account_id',$filter) && - $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) + $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== 'none') { $join .= self::ACCOUNT_ACTIVE_JOIN; - if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === 'deactivated') + if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '0') { $filter[] = str_replace('UNIX_TIMESTAMP(NOW())',time(),self::ACOUNT_ACTIVE_FILTER); }