diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index cff7575461..9ba39a2c10 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -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 '; } diff --git a/admin/inc/class.admin_account.inc.php b/admin/inc/class.admin_account.inc.php index 4f9a0fc1a5..b7017e8baf 100644 --- a/admin/inc/class.admin_account.inc.php +++ b/admin/inc/class.admin_account.inc.php @@ -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); + } } diff --git a/admin/inc/class.admin_ui.inc.php b/admin/inc/class.admin_ui.inc.php index fee593ced2..a797136d29 100644 --- a/admin/inc/class.admin_ui.inc.php +++ b/admin/inc/class.admin_ui.inc.php @@ -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; diff --git a/admin/templates/default/account.delete.xet b/admin/templates/default/account.delete.xet new file mode 100644 index 0000000000..d850ba650a --- /dev/null +++ b/admin/templates/default/account.delete.xet @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/admin/templates/default/app.css b/admin/templates/default/app.css index 10cea9b478..07a5e891cf 100644 --- a/admin/templates/default/app.css +++ b/admin/templates/default/app.css @@ -49,4 +49,8 @@ td.admin_userAgent span { width: 100%; overflow: hidden; text-overflow: ellipsis; +} + +.admin_account_delete > * { + padding: 8px; } \ No newline at end of file diff --git a/admin/templates/default/index.xet b/admin/templates/default/index.xet index 77f6550ff0..1c4029e81c 100644 --- a/admin/templates/default/index.xet +++ b/admin/templates/default/index.xet @@ -1,4 +1,5 @@ +