diff --git a/admin/inc/class.admin_hooks.inc.php b/admin/inc/class.admin_hooks.inc.php index 720a04a874..b0bf047497 100644 --- a/admin/inc/class.admin_hooks.inc.php +++ b/admin/inc/class.admin_hooks.inc.php @@ -196,6 +196,15 @@ class admin_hooks 'icon' => 'lock', ); + // Clear Credentials + $actions[] = array( + 'id' => 'clear_credentials', + 'caption' => 'Clear credentials', + 'icon' => 'password', + 'onExecute' => 'javaScript:app.admin.clear_credentials_handler', + 'confirm' => 'Clear credentials' + ); + if (!$GLOBALS['egw']->acl->check('current_sessions',1,'admin')) // no rights to view { $actions[] = array( diff --git a/admin/inc/class.admin_passwordreset.inc.php b/admin/inc/class.admin_passwordreset.inc.php index 56858d74cf..f12cb932d0 100644 --- a/admin/inc/class.admin_passwordreset.inc.php +++ b/admin/inc/class.admin_passwordreset.inc.php @@ -13,6 +13,7 @@ include_once(EGW_INCLUDE_ROOT.'/setup/inc/hook_config.inc.php'); // functions to return password hashes use EGroupware\Api; +use EGroupware\Api\Framework; /** * Reset passwords @@ -26,6 +27,7 @@ class admin_passwordreset */ public $public_functions = array( 'index' => true, + 'ajax_clear_credentials' => true ); /** @@ -284,4 +286,41 @@ class admin_passwordreset 'changed' => $changed, )); } + + public function ajax_clear_credentials($account_ids) + { + $msg = []; + + if($count = Api\Mail\Credentials::delete(0,$account_ids)) + { + $msg[] = lang("%1 mail credentials deleted", $count); + } + + $action['action'] = 'delete'; + $action['selected'] = $account_ids; + + $hook_data = Api\Hooks::process(array('location' => 'preferences_security'), ['openid'], true); + foreach($hook_data as $extra_tab) + { + if($extra_tab['delete']) + { + $msg[] = call_user_func_array($extra_tab['delete'], [$account_ids]); + } + else + { + // Each credential / security option can have its nm as a different ID + $content['tabs'] = $extra_tab['name']; + foreach($extra_tab['data'] as $id => $datum) + { + if($datum['get_rows']) + { + $content[$id] = $action; + } + } + $msg[] = call_user_func_array($extra_tab['save_callback'], [$content]); + } + } + Framework::message(implode("\n",$msg), 'success'); + Framework::redirect_link('/index.php', 'menuaction=admin.admin_ui.index','admin'); + } } diff --git a/admin/js/app.js b/admin/js/app.js index 83771601b5..4747eae6fa 100644 --- a/admin/js/app.js +++ b/admin/js/app.js @@ -1142,6 +1142,21 @@ var AdminApp = /** @class */ (function (_super) { this.egw.json('admin.admin_hooks.ajax_clear_cache&errored=1', null, success).sendRequest(true); }, this)); }; + /** + * Action handler for clear credentials action + * + * @param action + * @param selected + */ + AdminApp.prototype.clear_credentials_handler = function (action, selected) { + var ids = []; + debugger; + for (var _i = 0, selected_1 = selected; _i < selected_1.length; _i++) { + var row = selected_1[_i]; + ids.push(row.id.split("::").pop()); + } + this.egw.request("admin.admin_passwordreset.ajax_clear_credentials", [ids]); + }; /** * Export content of given field into relevant file */ diff --git a/admin/js/app.ts b/admin/js/app.ts index faebfc1659..2c4ef08179 100644 --- a/admin/js/app.ts +++ b/admin/js/app.ts @@ -1382,6 +1382,23 @@ class AdminApp extends EgwApp }, this)); } + /** + * Action handler for clear credentials action + * + * @param action + * @param selected + */ + clear_credentials_handler(action : egwAction, selected: egwActionObject[]) + { + let ids = []; + debugger; + for(let row of selected) + { + ids.push(row.id.split("::").pop()); + } + this.egw.request("admin.admin_passwordreset.ajax_clear_credentials", [ids]); + } + /** * Export content of given field into relevant file */