mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 16:44:07 +01:00
Admin - Ask which apps to transfer (others are discarded) when deleting account
This commit is contained in:
parent
4d858234ab
commit
aefa8258a1
@ -264,24 +264,6 @@ class admin_account
|
||||
{
|
||||
$content = array('account_id' => (int)$_GET['account_id']);
|
||||
}
|
||||
|
||||
// Get a count of entries owned by the user
|
||||
$counts = $GLOBALS['egw']->accounts->get_account_entry_counts($content['account_id']);
|
||||
foreach($counts as $app => $counts)
|
||||
{
|
||||
$entry = Api\Link::get_registry($app, 'entries');
|
||||
if(!$entry)
|
||||
{
|
||||
$entry = lang('Entries');
|
||||
}
|
||||
if($counts['total'])
|
||||
{
|
||||
$content['counts'][] = array(
|
||||
'app' => $app,
|
||||
'count' => $counts['total'] . ' '.$entry
|
||||
);
|
||||
}
|
||||
}
|
||||
//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') ||
|
||||
@ -291,7 +273,12 @@ class admin_account
|
||||
}
|
||||
if ($content['delete'])
|
||||
{
|
||||
$cmd = new admin_cmd_delete_account($content['account_id'], $content['new_owner'], $content['account_id'] > 0, (array)$content['admin_cmd']);
|
||||
$cmd = new admin_cmd_delete_account(array(
|
||||
'account' => $content['account_id'],
|
||||
'new_user' => $content['new_owner'],
|
||||
'is_user' => $content['account_id'] > 0,
|
||||
'change_apps' => $content['delete_apps']
|
||||
) + (array)$content['admin_cmd']);
|
||||
$msg = $cmd->run();
|
||||
if ($content['contact_id'])
|
||||
{
|
||||
@ -303,8 +290,30 @@ class admin_account
|
||||
}
|
||||
Framework::window_close();
|
||||
}
|
||||
|
||||
$sel_options = array();
|
||||
$preserve = $content;
|
||||
|
||||
// Get a count of entries owned by the user
|
||||
$counts = $GLOBALS['egw']->accounts->get_account_entry_counts($content['account_id']);
|
||||
foreach($counts as $app => $counts)
|
||||
{
|
||||
$entry = Api\Link::get_registry($app, 'entries');
|
||||
if(!$entry)
|
||||
{
|
||||
$entry = lang('Entries');
|
||||
}
|
||||
if($counts['total'])
|
||||
{
|
||||
$content['delete_apps'][] = $app;
|
||||
$sel_options['delete_apps'][] = array(
|
||||
'value' => $app,
|
||||
'label' => lang($app) . ': ' . $counts['total'] . ' '.$entry
|
||||
);
|
||||
}
|
||||
}
|
||||
$tpl = new Etemplate('admin.account.delete');
|
||||
$tpl->exec('admin_account::delete', $content, array(), array(), $content, 2);
|
||||
$tpl->exec('admin_account::delete', $content, $sel_options, array(), $preserve, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -198,8 +198,19 @@ class admin_cmd_delete_account extends admin_cmd
|
||||
'new_owner' => (int)$new_user, // deleteaccount only
|
||||
'location' => $is_user ? 'deleteaccount' : 'deletegroup',
|
||||
);
|
||||
// First do apps that were not selected
|
||||
$skip_apps = array();
|
||||
$do_last = array('preferences','admin');
|
||||
if($this->change_apps)
|
||||
{
|
||||
foreach(array_diff(array_keys($GLOBALS['egw_info']['apps']), array_merge($this->change_apps,$do_last)) as $app)
|
||||
{
|
||||
$skip_apps[] = $app;
|
||||
Api\Hooks::single(array_merge($GLOBALS['hook_values'], array('new_owner' => 0)), $app, true);
|
||||
}
|
||||
}
|
||||
// first all other apps, then preferences and admin
|
||||
foreach(array_merge(array_diff(array_keys($GLOBALS['egw_info']['apps']),array('preferences','admin')),array('preferences','admin')) as $app)
|
||||
foreach(array_merge($this->change_apps,$do_last) as $app)
|
||||
{
|
||||
Api\Hooks::single($GLOBALS['hook_values'], $app, true);
|
||||
}
|
||||
|
@ -2,40 +2,12 @@
|
||||
<!DOCTYPE overlay PUBLIC "-//EGroupware GmbH//eTemplate 2//EN" "http://www.egroupware.org/etemplate2.dtd">
|
||||
<!-- $Id$ -->
|
||||
<overlay>
|
||||
<template id="admin.account.delete" template="" lang="" group="0" version="18.1.001">
|
||||
<box class="dialogHeader">
|
||||
<select-account id="account_id" readonly="true" label="Delete"/>
|
||||
</box>
|
||||
<tabbox id="tabs" width="99%">
|
||||
<tabs>
|
||||
<tab id="main" label="Delete"/>
|
||||
</tabs>
|
||||
<tabpanels>
|
||||
<template template="admin.account.delete.delete" width="99%"/>
|
||||
</tabpanels>
|
||||
</tabbox>
|
||||
<hbox class="dialogFooterToolbar">
|
||||
<button id="delete" label="Delete"/>
|
||||
<button id="cancel" label="Cancel" onclick="window.close()"/>
|
||||
</hbox>
|
||||
</template>
|
||||
<template id="admin.account.delete.delete" template="" lang="" group="0" version="18.1.001">
|
||||
<vbox class="admin_account_delete">
|
||||
<description value="Who would you like to transfer ALL records owned by the deleted user to?" class="dialogHeader2"/>
|
||||
<description value="Who would you like to transfer records owned by the deleted user to?" class="dialogHeader2"/>
|
||||
<select-account id="new_owner" empty_label="Delete all records" class="dialogHeader3"/>
|
||||
<description value="Entries owned by the user:"/>
|
||||
<grid id="counts">
|
||||
<columns>
|
||||
<column width="150"/>
|
||||
<column/>
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<select-app id="${row}[app]" readonly="true"/>
|
||||
<description id="${row}[count]"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
<description value="Transfer entries owned by the user:"/>
|
||||
<select id="delete_apps" rows="8" multiple="true" span="2"/>
|
||||
<grid>
|
||||
<columns>
|
||||
<column width="150"/>
|
||||
@ -55,4 +27,21 @@
|
||||
<description value="If you delete the user without selecting an account to move the data to, all entries get deleted!" font_style="b"/>
|
||||
</vbox>
|
||||
</template>
|
||||
<template id="admin.account.delete" template="" lang="" group="0" version="18.1.001">
|
||||
<box class="dialogHeader">
|
||||
<select-account id="account_id" readonly="true" label="Delete" onchange="var apps = widget.getRoot().getWidgetById('delete_apps'); apps.set_enabled(widget.getValue());"/>
|
||||
</box>
|
||||
<tabbox id="tabs" width="99%">
|
||||
<tabs>
|
||||
<tab id="main" label="Delete"/>
|
||||
</tabs>
|
||||
<tabpanels>
|
||||
<template template="admin.account.delete.delete" width="99%"/>
|
||||
</tabpanels>
|
||||
</tabbox>
|
||||
<hbox class="dialogFooterToolbar">
|
||||
<button id="delete" label="Delete"/>
|
||||
<button id="cancel" label="Cancel" onclick="window.close()"/>
|
||||
</hbox>
|
||||
</template>
|
||||
</overlay>
|
||||
|
Loading…
Reference in New Issue
Block a user