Addressbook - fix show/hide account preference bugs

- account filter was missing for show active
- preference changed to match current value
This commit is contained in:
nathangray 2017-11-21 11:07:50 -07:00
parent 57abd48625
commit b04eb80b39
4 changed files with 11 additions and 8 deletions

View File

@ -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.',

View File

@ -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

View File

@ -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)))

View File

@ -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);
}