new deleting of accounts

This commit is contained in:
Ralf Becker 2014-03-19 13:20:46 +00:00
parent f2e997d445
commit e476a3ed82
8 changed files with 129 additions and 26 deletions

View File

@ -660,6 +660,19 @@ class addressbook_ui extends addressbook_bo
'disableClass' => 'rowNoDelete',
);
}
if ($this->grants[0] & EGW_ACL_DELETE)
{
$actions['delete_account'] = array(
'caption' => 'Delete',
'icon' => 'delete',
'group' => $group,
'enableClass' => 'rowAccount',
'hideOnDisabled' => true,
'popup' => '400x200',
'url' => 'menuaction=admin.admin_account.delete&contact_id=$id',
);
$actions['delete']['hideOnDisabled'] = true;
}
if($tid_filter == 'D')
{
$actions['undelete'] = array(
@ -759,7 +772,7 @@ window.egw_LAB.wait(function() {
$query = $query == null ? egw_session::appsession('index','addressbook') : $query;
$query['num_rows'] = -1; // all
if(!is_array($query['col_filter'])) $query['col_filter'] = array();
if(!is_array($org)) $org = array($org);
foreach($org as $org_name)
{
@ -1030,7 +1043,7 @@ window.egw_LAB.wait(function() {
elseif (count($checked) == 1 && $contact['account_id'])
{
egw::redirect_link('/index.php',array(
'menuaction' => 'admin.uiaccounts.delete_user',
'menuaction' => 'admin.admin_account.delete',
'account_id' => $contact['account_id'],
));
// this does NOT return!
@ -1518,7 +1531,11 @@ window.egw_LAB.wait(function() {
{
$row['tel_prefered'] = $row[$row['tel_prefer']].$prefer_marker;
}
if (!$this->check_perms(EGW_ACL_DELETE,$row) || (!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge' && $query['col_filter']['tid'] == addressbook_so::DELETED_TYPE))
if (!$row['owner'])
{
$row['class'] .= 'rowAccount rowNoDelete';
}
elseif (!$this->check_perms(EGW_ACL_DELETE,$row) || (!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge' && $query['col_filter']['tid'] == addressbook_so::DELETED_TYPE))
{
$row['class'] .= 'rowNoDelete ';
}

View File

@ -15,6 +15,22 @@
*/
class admin_account
{
/**
* Functions callable via menuaction
*
* @var array
*/
public $public_functions = array(
'delete' => true,
);
/**
* Hook to edit account data via "Account" tab in addressbook edit dialog
*
* @param array $content
* @return array
* @throws egw_exception_not_found
*/
public function addressbook_edit(array $content)
{
if ((string)$content['owner'] === '0' && $GLOBALS['egw_info']['user']['apps']['admin'])
@ -144,4 +160,49 @@ class admin_account
$content = array_merge($contact, $content);
}
}
/**
* Delete an account
*
* @param array $content=null
*/
public static function delete(array $content=null)
{
if (!is_array($content))
{
if (isset($_GET['contact_id']) && ($account_id = $GLOBALS['egw']->accounts->name2id((int)$_GET['contact_id'], 'person_id')))
{
$content = array(
'account_id' => $account_id,
'contact_id' => (int)$_GET['contact_id'],
);
}
else
{
$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));
}
if ($GLOBALS['egw']->acl->check('account_access',32,'admin') || !($content['account_id'] > 0) ||
$GLOBALS['egw_info']['user']['account_id'] == $content['account_id'])
{
egw_framework::window_close(lang('Permission denied!!!'));
}
if ($content['delete'])
{
$cmd = new admin_cmd_delete_account(accounts::id2name($content['account_id']), $content['new_owner'], true);
$msg = $cmd->run();
if ($content['contact_id'])
{
egw_framework::refresh_opener($msg, 'addressbook', $content['contact_id'], 'delete');
}
else
{
egw_framework::refresh_opener($msg, 'admin', $content['account_id'], 'delete');
}
egw_framework::window_close();
}
$tpl = new etemplate_new('admin.account.delete');
$tpl->exec('admin_account::delete', $content, array(), array(), $content, 2);
}
}

View File

@ -200,8 +200,8 @@ if ($app == 'felamimail') continue; // disabled fmail for now, as it break whole
$actions['delete'] = array(
'caption' => 'Delete',
'group' => ++$group,
'url' => 'menuaction=admin.uiaccounts.delete_user&account_id=$id',
'onExecute' => 'javaScript:app.admin.iframe_location',
'popup' => '400x200',
'url' => 'menuaction=admin.admin_account.delete&account_id=$id',
);
//error_log(__METHOD__."() actions=".array2string($actions));
return $actions;

View File

@ -0,0 +1,18 @@
<?xml version="1.0"?>
<!DOCTYPE overlay PUBLIC "-//Stylite AG//eTemplate 2//EN" "http://www.egroupware.org/etemplate2.dtd">
<!-- $Id$ -->
<overlay>
<template id="admin.account.delete" template="" lang="" group="0" version="1.9.003">
<vbox class="admin_account_delete">
<box class="dialogHeader">
<select-account id="account_id" readonly="true" label="Delete account %1"/>
</box>
<description value="Who would you like to transfer ALL records owned by the deleted user to?" class="dialogHeader2"/>
<select-account id="new_owner" empty_label="Delete all records" class="dialogHeader3"/>
<hbox class="dialogFooterToolbar">
<button id="delete" label="Delete"/>
<button id="cancel" label="Cancel" onclick="window.close()"/>
</hbox>
</vbox>
</template>
</overlay>

View File

@ -49,4 +49,8 @@ td.admin_userAgent span {
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
}
.admin_account_delete > * {
padding: 8px;
}

View File

@ -1,4 +1,5 @@
<?xml version="1.0"?>
<!DOCTYPE overlay PUBLIC "-//Stylite AG//eTemplate 2//EN" "http://www.egroupware.org/etemplate2.dtd">
<!-- $Id$ -->
<overlay>
<template id="admin.index.rows" template="" lang="" group="0" version="1.9.001">
@ -44,10 +45,9 @@
</template>
<template id="admin.index" template="" lang="" group="0" version="1.9.001">
<tree autoloading="admin_ui::ajax_tree" id="tree" onclick="app.admin.run" parent_node="admin_tree_target" std_images="bullet"/>
<description id="msg" class="message"/>
<split dock_side="topDock" id="splitter" orientation="h">
<nextmatch id="nm" template="admin.index.rows"/>
<iframe frameborder="1" height="500px" id="iframe" scrolling="auto" width="100%"/>
<iframe frameborder="1" height="100%" id="iframe" scrolling="auto" width="100%"/>
</split>
</template>
</overlay>

View File

@ -1,7 +1,7 @@
/**
* EGroupware: CSS with less preprocessor
* ADMIN
* ADMIN
*
* Please do NOT change app.css directly, instead change app.less and compile it!
*
@ -59,6 +59,9 @@ td.admin_userAgent span {
overflow: hidden;
text-overflow: ellipsis;
}
.admin_account_delete > * {
padding: 8px;
}
@media all {
/* #############################################################################
// iframe

View File

@ -1,7 +1,7 @@
/**
* EGroupware: CSS with less preprocessor
* ADMIN
* ADMIN
*
* Please do NOT change app.css directly, instead change app.less and compile it!
*
@ -39,36 +39,36 @@
*/
iframe#admin-index_iframe{
background-color: transparent;
/*.egwGridView_scrollarea { min-height: 500px;}*/
#admin-categories-index{
padding: 10px;
table.et2_grid {
#admin-categories-index_nm {
div.egwGridView_outer{
td.frame {
}
}
}
}
}
table.egwGridView_grid tr td {color: #000;}
} // iframe
@ -99,7 +99,7 @@ iframe#admin-index_iframe{
#admin-categories-index{
padding: 10px;
}