mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-18 11:58:24 +01:00
* Admin: Allow deleting multiple accounts at once
This commit is contained in:
parent
8dedc3392f
commit
1e15a6efc7
@ -307,25 +307,38 @@ class admin_account
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (strpos($_GET['account_id'],','))
|
||||||
|
{
|
||||||
|
$content = array('account_id' => array_map(function ($c) { return (int)$c; }, explode(',',$_GET['account_id'])));
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
$content = array('account_id' => (int)$_GET['account_id']);
|
$content = array('account_id' => (int)$_GET['account_id']);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//error_log(__METHOD__."() \$_GET[account_id]=$_GET[account_id], \$_GET[contact_id]=$_GET[contact_id] content=".array2string($content));
|
//error_log(__METHOD__."() \$_GET[account_id]=$_GET[account_id], \$_GET[contact_id]=$_GET[contact_id] content=".array2string($content));
|
||||||
}
|
}
|
||||||
if ($GLOBALS['egw']->acl->check('account_access',32,'admin') ||
|
if ($GLOBALS['egw']->acl->check('account_access',32,'admin') ||
|
||||||
$GLOBALS['egw_info']['user']['account_id'] == $content['account_id'])
|
$GLOBALS['egw_info']['user']['account_id'] == $content['account_id'] ||
|
||||||
|
(is_array($content['account_id']) && in_array($GLOBALS['egw_info']['user']['account_id'], $content['account_id']) )
|
||||||
|
)
|
||||||
{
|
{
|
||||||
Framework::window_close(lang('Permission denied!!!'));
|
Framework::window_close(lang('Permission denied!!!'));
|
||||||
}
|
}
|
||||||
if ($content['delete'])
|
if ($content['delete'])
|
||||||
|
{
|
||||||
|
$msg = '';
|
||||||
|
foreach($content['account_id'] as $account_id)
|
||||||
{
|
{
|
||||||
$cmd = new admin_cmd_delete_account(array(
|
$cmd = new admin_cmd_delete_account(array(
|
||||||
'account' => $content['account_id'],
|
'account' => $account_id,
|
||||||
'new_user' => $content['new_owner'],
|
'new_user' => $content['new_owner'],
|
||||||
'is_user' => $content['account_id'] > 0,
|
'is_user' => $account_id > 0,
|
||||||
'change_apps' => $content['delete_apps']
|
'change_apps' => $content['delete_apps']
|
||||||
) + (array)$content['admin_cmd']);
|
) + (array)$content['admin_cmd']);
|
||||||
$msg = $cmd->run();
|
$msg = $cmd->run() . "\n";
|
||||||
|
}
|
||||||
if ($content['contact_id'])
|
if ($content['contact_id'])
|
||||||
{
|
{
|
||||||
Framework::refresh_opener($msg, 'addressbook', $content['contact_id'], 'delete');
|
Framework::refresh_opener($msg, 'addressbook', $content['contact_id'], 'delete');
|
||||||
@ -341,33 +354,40 @@ class admin_account
|
|||||||
$preserve = $content;
|
$preserve = $content;
|
||||||
|
|
||||||
// Get a count of entries owned by the user
|
// Get a count of entries owned by the user
|
||||||
|
if(!is_array($content['account_id']))
|
||||||
|
{
|
||||||
$counts = $GLOBALS['egw']->accounts->get_account_entry_counts($content['account_id']);
|
$counts = $GLOBALS['egw']->accounts->get_account_entry_counts($content['account_id']);
|
||||||
foreach($counts as $app => $counts)
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$counts = array_fill_keys(array_keys($GLOBALS['egw_info']['apps']),'-');
|
||||||
|
}
|
||||||
|
foreach ($counts as $app => $counts)
|
||||||
{
|
{
|
||||||
$entry = Api\Link::get_registry($app, 'entries');
|
$entry = Api\Link::get_registry($app, 'entries');
|
||||||
if(!$entry)
|
if (!$entry)
|
||||||
{
|
{
|
||||||
$entry = lang('Entries');
|
$entry = lang('Entries');
|
||||||
}
|
}
|
||||||
if($counts['total'] && Api\Hooks::exists('deleteaccount', $app))
|
if ($counts['total'] && Api\Hooks::exists('deleteaccount', $app))
|
||||||
{
|
{
|
||||||
$content['delete_apps'][] = $app;
|
$content['delete_apps'][] = $app;
|
||||||
$sel_options['delete_apps'][] = array(
|
$sel_options['delete_apps'][] = array(
|
||||||
'value' => $app,
|
'value' => $app,
|
||||||
'label' => lang($app) . ': ' . $counts['total'] . ' '.$entry
|
'label' => lang($app) . (is_array($counts) ? (': ' . $counts['total'] . ' ' . $entry) : '')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if ($counts['total'])
|
else if (is_array($counts) && $counts['total'])
|
||||||
{
|
{
|
||||||
// These ones don't support the needed hook
|
// These ones don't support the needed hook
|
||||||
$content['counts'][] = array(
|
$content['counts'][] = array(
|
||||||
'app' => $app,
|
'app' => $app,
|
||||||
'count' => $counts['total'] . ' '.$entry
|
'count' => $counts['total'] . ' ' . $entry
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add filemanager home directory in as special case, hook is in the API
|
// Add filemanager home directory in as special case, hook is in the API
|
||||||
if(Api\Vfs::file_exists('/home/'.$GLOBALS['egw']->accounts->id2name($content['account_id'])))
|
if (Api\Vfs::file_exists('/home/' . $GLOBALS['egw']->accounts->id2name($content['account_id'])))
|
||||||
{
|
{
|
||||||
$app = 'filemanager';
|
$app = 'filemanager';
|
||||||
$sel_options['delete_apps'][] = array(
|
$sel_options['delete_apps'][] = array(
|
||||||
@ -377,6 +397,8 @@ class admin_account
|
|||||||
$content['delete_apps'][] = $app;
|
$content['delete_apps'][] = $app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$content['account_id'] = (array)$content['account_id'];
|
||||||
|
|
||||||
$tpl = new Etemplate('admin.account.delete');
|
$tpl = new Etemplate('admin.account.delete');
|
||||||
$tpl->exec('admin_account::delete', $content, $sel_options, array(), $preserve, 2);
|
$tpl->exec('admin_account::delete', $content, $sel_options, array(), $preserve, 2);
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ class admin_ui
|
|||||||
'group' => ++$group,
|
'group' => ++$group,
|
||||||
'popup' => '615x600',
|
'popup' => '615x600',
|
||||||
'url' => 'menuaction=admin.admin_account.delete&account_id=$id',
|
'url' => 'menuaction=admin.admin_account.delete&account_id=$id',
|
||||||
'allowOnMultiple' => false,
|
'allowOnMultiple' => true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
//error_log(__METHOD__."() actions=".array2string($actions));
|
//error_log(__METHOD__."() actions=".array2string($actions));
|
||||||
|
Loading…
Reference in New Issue
Block a user