From 7a0e216aca561a1ff8df455402d1d4a96c7d8649 Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 2 Nov 2023 13:08:02 -0600 Subject: [PATCH] Admin: Group action to add / remove application run rights --- admin/inc/class.admin_ui.inc.php | 7 +++ admin/js/app.ts | 60 +++++++++++++++++++- admin/templates/default/group.run_rights.xet | 20 +++++++ 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 admin/templates/default/group.run_rights.xet diff --git a/admin/inc/class.admin_ui.inc.php b/admin/inc/class.admin_ui.inc.php index fe25cadab4..e03d9b3345 100644 --- a/admin/inc/class.admin_ui.inc.php +++ b/admin/inc/class.admin_ui.inc.php @@ -260,6 +260,13 @@ class admin_ui 'group' => 2, 'allowOnMultiple' => false ), + 'run_rights' => array( + 'onExecute' => 'javaScript:app.admin.group_run_rights', + 'caption' => 'Run rights for applications', + 'icon' => 'lock', + 'group' => 2, + 'allowOnMultiple' => true + ) ); if (!$GLOBALS['egw']->acl->check('account_access',64,'admin')) // no rights to set ACL-rights { diff --git a/admin/js/app.ts b/admin/js/app.ts index 7ac741940f..08e530e731 100644 --- a/admin/js/app.ts +++ b/admin/js/app.ts @@ -20,7 +20,10 @@ import {egwAction, egwActionObject} from '../../api/js/egw_action/egw_action'; import {LitElement} from "@lion/core"; import {et2_nextmatch} from "../../api/js/etemplate/et2_extension_nextmatch"; import {et2_DOMWidget} from "../../api/js/etemplate/et2_core_DOMWidget"; -import {Et2SelectAccount} from "../../api/js/etemplate/Et2Select/Et2SelectAccount"; +import {Et2SelectAccount} from "../../api/js/etemplate/Et2Select/Select/Et2SelectAccount"; +import {EgwAction} from "../../api/js/egw_action/EgwAction"; +import {EgwActionObject} from "../../api/js/egw_action/EgwActionObject"; +import type {Et2Button} from "../../api/js/etemplate/Et2Button/Et2Button"; /** * UI for Admin @@ -550,6 +553,61 @@ class AdminApp extends EgwApp } } + /** + * Opens a dialog to add / remove application run rights for one or more groups + * + * @param _action + * @param _senders + */ + group_run_rights(_action : EgwAction, _senders : EgwActionObject[]) + { + let ids = []; + let row_ids = [] + _senders.forEach((sender) => { + row_ids.push(sender.id); + ids.push(sender.id.split("::").pop()); + }) + const dialog = new Et2Dialog(this.egw); + let attrs = { + template: this.egw.webserverUrl + "/admin/templates/default/group.run_rights.xet", + title: "Applications", + hideOnEscape: true, + width: "400", + height: "300px", + value: { + content: {groups: ids} + }, + callback: (button_id, value) => { + if(button_id == "_cancel") return; + + let acl_id = []; + (value.apps ?? []).forEach(app => { + ids.forEach(account => { + acl_id.push(app + ":" + account +":run"); + }) + }); + if(value && value.apps && acl_id.length) + { + const button = dialog.querySelector("[id*='"+button_id+"']"); + if(button) button.disabled=true; + this.egw.request( + 'admin_acl::ajax_change_acl', + [acl_id, button_id == "_add" ? 1 : 0, [], this.et2.getInstanceManager().etemplate_exec_id] + ).then((_data) => { + this.et2.getInstanceManager().refresh(_data.msg, this.appname,row_ids,'update'); + dialog.close(); + }); + return false; + } + } + } + dialog.transformAttributes(attrs); + this.et2.getInstanceManager().DOMContainer.appendChild(dialog); + dialog.updateComplete.then(() => { + dialog.template.widgetContainer.getWidgetById("apps").focus(); + }); + } + /** * Modify an ACL entry * diff --git a/admin/templates/default/group.run_rights.xet b/admin/templates/default/group.run_rights.xet new file mode 100644 index 0000000000..f1e1671f86 --- /dev/null +++ b/admin/templates/default/group.run_rights.xet @@ -0,0 +1,20 @@ + + + + + \ No newline at end of file