mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-27 18:33:39 +01:00
Addressbook - fix hide accounts preference did not work for duplicate & organisation views
- Added a new preference option to hide only deactivated accounts
This commit is contained in:
parent
f43ddba7bc
commit
cfb34b05bf
@ -141,7 +141,8 @@ class addressbook_hooks
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
$settings['hide_accounts'] = array(
|
$settings['hide_accounts'] = array(
|
||||||
'type' => 'check',
|
'type' => 'select',
|
||||||
|
'values' => array('1' => lang('Hide all accounts'), 'deactivated' => lang('Show active accounts'), '0' => lang('Show all accounts')),
|
||||||
'label' => 'Hide accounts from addressbook',
|
'label' => 'Hide accounts from addressbook',
|
||||||
'name' => 'hide_accounts',
|
'name' => 'hide_accounts',
|
||||||
'help' => 'Hides accounts completly from the adressbook.',
|
'help' => 'Hides accounts completly from the adressbook.',
|
||||||
|
@ -1633,10 +1633,15 @@ window.egw_LAB.wait(function() {
|
|||||||
{
|
{
|
||||||
unset($query['col_filter']['list']);
|
unset($query['col_filter']['list']);
|
||||||
}
|
}
|
||||||
if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'])
|
if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1')
|
||||||
{
|
{
|
||||||
$query['col_filter']['account_id'] = null;
|
$query['col_filter']['account_id'] = null;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unset($query['col_filter']['account_id']);
|
||||||
|
}
|
||||||
|
|
||||||
// all backends allow now at least to use groups as distribution lists
|
// all backends allow now at least to use groups as distribution lists
|
||||||
$query['no_filter2'] = false;
|
$query['no_filter2'] = false;
|
||||||
|
|
||||||
|
@ -274,6 +274,7 @@ grant addressbook access common en Grant address book access
|
|||||||
group %1 addressbook en Group %1
|
group %1 addressbook en Group %1
|
||||||
h addressbook en h
|
h addressbook en h
|
||||||
hide accounts from addressbook addressbook en Hide user accounts
|
hide accounts from addressbook addressbook en Hide user accounts
|
||||||
|
hide all accounts addressbook en Hide all accounts
|
||||||
hides accounts completly from the adressbook. addressbook en Hide user accounts completely from the address book.
|
hides accounts completly from the adressbook. addressbook en Hide user accounts completely from the address book.
|
||||||
history logging admin en History logging
|
history logging admin en History logging
|
||||||
home address addressbook en Home address
|
home address addressbook en Home address
|
||||||
@ -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 en Set only full name
|
set only full name addressbook en Set only full name
|
||||||
should the columns photo and home address always be displayed, even if they are empty. addressbook en Are photo and home address always displayed, even if columns are empty.
|
should the columns photo and home address always be displayed, even if they are empty. addressbook en Are photo and home address always displayed, even if columns are empty.
|
||||||
show addressbook en Show
|
show addressbook en Show
|
||||||
|
show active accounts addressbook en Show active accounts
|
||||||
|
show all accounts addressbook en Show all accounts
|
||||||
show birthday reminders on main screen addressbook en Birthday reminders
|
show birthday reminders on main screen addressbook en Birthday reminders
|
||||||
show infolog entries for this organisation addressbook en Show InfoLog entries for this organisation
|
show infolog entries for this organisation addressbook en Show InfoLog entries for this organisation
|
||||||
show the contacts of this organisation addressbook en Show contacts of this organisation
|
show the contacts of this organisation addressbook en Show contacts of this organisation
|
||||||
|
@ -32,7 +32,7 @@ class Sql extends Api\Storage
|
|||||||
/**
|
/**
|
||||||
* join to show only active account (and not already expired ones)
|
* join to show only active account (and not already expired ones)
|
||||||
*/
|
*/
|
||||||
const ACCOUNT_ACTIVE_JOIN = ' LEFT JOIN egw_accounts ON egw_addressbook.account_id=egw_accounts.account_id';
|
const ACCOUNT_ACTIVE_JOIN = ' LEFT JOIN egw_accounts ON egw_addressbook.account_id=egw_accounts.account_id ';
|
||||||
/**
|
/**
|
||||||
* filter to show only active account (and not already expired or deactived ones)
|
* filter to show only active account (and not already expired or deactived ones)
|
||||||
* UNIX_TIMESTAMP(NOW()) gets replaced with value of time() in the code!
|
* UNIX_TIMESTAMP(NOW()) gets replaced with value of time() in the code!
|
||||||
@ -110,6 +110,7 @@ class Sql extends Api\Storage
|
|||||||
function organisations($param)
|
function organisations($param)
|
||||||
{
|
{
|
||||||
$filter = is_array($param['col_filter']) ? $param['col_filter'] : array();
|
$filter = is_array($param['col_filter']) ? $param['col_filter'] : array();
|
||||||
|
$join = '';
|
||||||
$op = 'OR';
|
$op = 'OR';
|
||||||
if (isset($param['op']) && !empty($param['op'])) $op = $param['op'];
|
if (isset($param['op']) && !empty($param['op'])) $op = $param['op'];
|
||||||
$advanced_search = false;
|
$advanced_search = false;
|
||||||
@ -148,6 +149,18 @@ class Sql extends Api\Storage
|
|||||||
" 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'])
|
||||||
|
{
|
||||||
|
$join .= self::ACCOUNT_ACTIVE_JOIN;
|
||||||
|
if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === 'deactivated')
|
||||||
|
{
|
||||||
|
$filter[] = str_replace('UNIX_TIMESTAMP(NOW())',time(),self::ACOUNT_ACTIVE_FILTER);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$filter[] = 'egw_accounts.account_id IS NULL';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($param['searchletter'])
|
if ($param['searchletter'])
|
||||||
{
|
{
|
||||||
@ -194,7 +207,7 @@ class Sql extends Api\Storage
|
|||||||
$append = "ORDER BY org_name $sort,is_main DESC,$by $sort";
|
$append = "ORDER BY org_name $sort,is_main DESC,$by $sort";
|
||||||
}
|
}
|
||||||
$rows = parent::search($param['search'],array('org_name'),$append,$extra,$wildcard,false,$op/*'OR'*/,
|
$rows = parent::search($param['search'],array('org_name'),$append,$extra,$wildcard,false,$op/*'OR'*/,
|
||||||
array($param['start'],$param['num_rows']),$filter);
|
array($param['start'],$param['num_rows']),$filter,$join);
|
||||||
|
|
||||||
if (!$rows) return false;
|
if (!$rows) return false;
|
||||||
|
|
||||||
@ -216,7 +229,7 @@ class Sql extends Api\Storage
|
|||||||
{
|
{
|
||||||
foreach((array) parent::search(null, array('org_name','org_unit','adr_one_locality'),
|
foreach((array) parent::search(null, array('org_name','org_unit','adr_one_locality'),
|
||||||
'GROUP BY org_name,org_unit,adr_one_locality',
|
'GROUP BY org_name,org_unit,adr_one_locality',
|
||||||
'',$wildcard,false,$op/*'AND'*/,false,$filter) as $row)
|
'',$wildcard,false,$op/*'AND'*/,false,$filter,$join) as $row)
|
||||||
{
|
{
|
||||||
$org_key = $row['org_name'].($by ? '|||'.$row[$by] : '');
|
$org_key = $row['org_name'].($by ? '|||'.$row[$by] : '');
|
||||||
if ($orgs[$org_key]['org_unit_count'] == 1)
|
if ($orgs[$org_key]['org_unit_count'] == 1)
|
||||||
@ -351,7 +364,20 @@ class Sql extends Api\Storage
|
|||||||
implode('+', $extra) . ' AS match_count'
|
implode('+', $extra) . ' AS match_count'
|
||||||
);
|
);
|
||||||
$join .= $this->db->column_data_implode(' OR ',$join_fields) . ')';
|
$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'] === 'deactivated')
|
||||||
|
{
|
||||||
|
$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 ';
|
||||||
|
$filter[] = str_replace(array('UNIX_TIMESTAMP(NOW())', 'account_'),array(time(),'account_1.account_'),self::ACOUNT_ACTIVE_FILTER);
|
||||||
|
$filter[] = str_replace(array('UNIX_TIMESTAMP(NOW())', 'account_'),array(time(),'account_2.account_'),self::ACOUNT_ACTIVE_FILTER);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$filter[] = 'egw_addressbook.account_id IS NULL and a2.account_id IS NULL';
|
||||||
|
}
|
||||||
|
}
|
||||||
$append = " HAVING match_count >= $match_count ORDER BY {$order} $sort, $this->table_name.contact_id";
|
$append = " HAVING match_count >= $match_count ORDER BY {$order} $sort, $this->table_name.contact_id";
|
||||||
$columns[] = $this->table_name.'.contact_id AS contact_id';
|
$columns[] = $this->table_name.'.contact_id AS contact_id';
|
||||||
|
|
||||||
@ -526,10 +552,18 @@ 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)
|
// 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' &&
|
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))
|
strpos($join,$GLOBALS['egw']->accounts->backend->table) === false && !array_key_exists('account_id',$filter) &&
|
||||||
|
$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'])
|
||||||
{
|
{
|
||||||
$join .= self::ACCOUNT_ACTIVE_JOIN;
|
$join .= self::ACCOUNT_ACTIVE_JOIN;
|
||||||
$filter[] = str_replace('UNIX_TIMESTAMP(NOW())',time(),self::ACOUNT_ACTIVE_FILTER);
|
if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === 'deactivated')
|
||||||
|
{
|
||||||
|
$filter[] = str_replace('UNIX_TIMESTAMP(NOW())',time(),self::ACOUNT_ACTIVE_FILTER);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$filter[] = 'egw_accounts.account_id IS NULL';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($join || ($criteria && is_string($criteria)) || ($criteria && is_array($criteria) && $order_by)) // search also adds a join for custom fields!
|
if ($join || ($criteria && is_string($criteria)) || ($criteria && is_array($criteria) && $order_by)) // search also adds a join for custom fields!
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user