* Admin: New account status filter (Enabled, Disabled, Expired, Expires, Not enabled)

This commit is contained in:
nathangray 2020-05-15 13:20:21 -06:00
parent 52eb5ca8e0
commit 1936849bd7
2 changed files with 64 additions and 2 deletions

View File

@ -55,7 +55,6 @@ class admin_ui
$content['nm'] = array(
'get_rows' => 'admin_ui::get_users',
'no_cat' => true,
'no_filter2' => true,
'filter_no_lang' => true,
'lettersearch' => true,
'order' => 'account_lid',
@ -93,6 +92,14 @@ class admin_ui
$sel_options['account_primary_group'] = $sel_options['filter'];
unset($sel_options['account_primary_group']['']);
$sel_options['filter2'] = array(
'enabled' => 'Enabled',
'disabled' => 'Disabled',
'expired' => 'Expired',
'expires' => 'Expires',
'not_enabled' => 'Not enabled'
);
$tpl->setElementAttribute('tree', 'actions', self::tree_actions());
// switching between iframe and nm/accounts-list depending on load parameter
@ -325,7 +332,22 @@ class admin_ui
'order' => $query['order'],
'sort' => $query['sort'],
'active' => !empty($query['active']) ? $query['active'] : false,
'status' => $query['filter2']
);
// Make sure active filter give status what it needs
switch($query['filter2'])
{
case 'disabled':
case 'expired':
case 'not_enabled':
$params['active'] = false;
break;
case 'enabled':
default:
$params['active'] = true;
break;
}
if ($query['searchletter'])
{
$params['query'] = $query['searchletter'];
@ -340,8 +362,15 @@ class admin_ui
$rows = array_values(self::$accounts->search($params));
//error_log(__METHOD__."() accounts->search(".array2string($params).") total=".self::$accounts->total);
foreach($rows as &$row)
foreach($rows as $key => &$row)
{
// Filter by status
if($params['status'] && !static::filter_status($params['status'], $row))
{
unset($rows[$key]);
self::$accounts->total--;
continue;
}
$row['status'] = self::$accounts->is_expired($row) ?
lang('Expired').' '.Api\DateTime::to($row['account_expires'], true) :
(!self::$accounts->is_active($row) ? lang('Disabled') :
@ -354,6 +383,36 @@ class admin_ui
return self::$accounts->total;
}
/**
* Filter the account based on given status.
*
* Status is one of enabled, disabled, expired, expires, not_enabled
* @param $status
* @param $account
*/
protected static function filter_status($status, &$account)
{
switch($status)
{
case 'enabled':
return $account['account_status'] == 'A';
case 'disabled':
return $account['account_status'] !== 'A';
case 'expired':
return $account['account_expires'] !== '-1' && $account['account_status'] != 'A';
case 'expires':
return $account['account_expires'] != '-1' && $account['account_status'] == 'A';
case 'not_enabled':
return static::filter_status('disabled', $account) || static::filter_status('expired', $account);
}
return false;
}
/**
* Callback for the nextmatch to get groups
*/

View File

@ -324,6 +324,7 @@ disable all admin en Disable all
disable minifying of javascript and css files admin en Disable minifying of javascript and CSS files
disable pgp encryption (mailvelope) admin en Disable PGP encryption (Mailvelope)
disable wysiwyg-editor admin en Disable WYSIWYG-editor
disabled admin en Disabled
disabled (not recomended) admin en Disabled (not recommended)
disabled, do not show on login page admin en disabled, do not show on login page
display admin en Display
@ -379,6 +380,7 @@ enable sieve admin en Enable Sieve
enable spellcheck in rich text editor admin en Enable spellcheck in rich text editor
enable the soap service admin en Enable the soap service.
enable the xmlrpc service admin en Enable the xmlrpc service.
enabled admin en Enabled
enabled - hidden from navbar admin en Enabled - Hidden from navbar
enabled - popup window admin en Enabled - Popup window
encrypted connection admin en Encrypted connection
@ -655,6 +657,7 @@ no profile defined for user %1 admin en No profile defined for user %1
no sieve support detected, either fix configuration manually or leave it switched off. admin en No sieve support detected, either fix configuration manually or leave it switched off.
no supported imap authentication method could be found. admin en No supported IMAP authentication method could be found.
non profit: clubs, associations, ... admin en Non profit: Clubs, Associations, ...
not enabled admin en Not enabled
note: ssl available only if php is compiled with curl support admin en Note: SSL available only if PHP is compiled with curl support.
notification mail admin en Notification mail
notify user by email admin en Notify user by email