From 250b56589ccfcfc2a9bae72ba2a1211f1be282c8 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 2 Aug 2018 11:40:02 +0200 Subject: [PATCH] WIP allow to document admin actions, if EPL policy app is installed --- admin/inc/class.admin_account.inc.php | 1 + admin/inc/class.admin_cmd.inc.php | 37 ++++++++++++++++++++++++++- api/js/jsapi/egw_user.js | 23 +++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/admin/inc/class.admin_account.inc.php b/admin/inc/class.admin_account.inc.php index fb69c74ce7..73a4125c18 100644 --- a/admin/inc/class.admin_account.inc.php +++ b/admin/inc/class.admin_account.inc.php @@ -148,6 +148,7 @@ class admin_account 'account_primary_group', 'account_expires', 'homedirectory', 'loginshell', + 'requested', 'requested_email', 'comment', // admin_cmd documentation (EPL) ) as $c_name => $a_name) { if (is_int($c_name)) $c_name = $a_name; diff --git a/admin/inc/class.admin_cmd.inc.php b/admin/inc/class.admin_cmd.inc.php index 9570300b98..80ab1d00d8 100644 --- a/admin/inc/class.admin_cmd.inc.php +++ b/admin/inc/class.admin_cmd.inc.php @@ -13,7 +13,36 @@ use EGroupware\Api; use EGroupware\Api\Acl; /** - * admin comand base class + * Admin comand base class + * + * Admin commands should be used to implement and log (!) all actions admins carry + * out using the administrative rights (regular users cant do). + * + * They are stored in DB table egw_admin_queue which builds a persitent log + * of administrative actions cared out on an EGroupware installation. + * Commands can be marked deleted (canceled for scheduled commands), + * but they are never deleted for the table to implement a persistent log! + * + * All administrative actions are encapsulated in classes derived from this + * abstract base class implementing an exec method to carry out the command. + * + * @property-read int $created Creation timestamp + * @property-read int $creator Creator user-id + * @property-read string $creator_email rfc822 address ("Name ") of creator + * @property-read int $modified Modification timestamp + * @property-read int|NULL $scheduled timestamp if command is not run immediatly, + * but scheduled to run automatic by the system at a later point in time + * @property-read int $modifier Modifier user-id + * @property-read string $modifier_email rfc822 address ("Name ") of modifier + * @property int|NULL $requested User who requested the change (not current user!) + * @property string|NULL $requested_email rfc822 address ("Name ") of requested + * @property string|NULL $comment comment, eg. reasoning why change was requested + * @property-read int|NULL $errno Numerical error-code or NULL on success + * @property-read string|NULL $error Error message or NULL on success + * @property-read int $id $id of command/row in egw_admin_queue table + * @property-read string $uid uuid of command (necessary if command is send to a remote system to execute) + * @property int|NULL $remote_id id of remote system, if command is not meant to run on local system + * foreign key into egw_admin_remote (table of remote systems administrated by this one) */ abstract class admin_cmd { @@ -328,6 +357,12 @@ abstract class admin_cmd $vars['data'] = in_array($this->status, self::$require_pw_stati) ? json_encode($this->data) : self::mask_passwords($this->data); + // skip EGroupware\\ prefix in new class-names, as value gets too long for column otherwise + if (strpos($this->type, 'EGroupware\\') === 0) + { + $vars['type'] = substr($this->type, 11); + } + admin_cmd::$sql->init($vars); if (admin_cmd::$sql->save() != 0) { diff --git a/api/js/jsapi/egw_user.js b/api/js/jsapi/egw_user.js index 45a8f5ab39..e7df87542e 100644 --- a/api/js/jsapi/egw_user.js +++ b/api/js/jsapi/egw_user.js @@ -191,6 +191,29 @@ egw.extend('user', egw.MODULE_GLOBAL, function() } }, + /** + * Set specified account-data of selected user in an other widget + * + * Used eg. in template as: onchange="egw.set_account_data(widget, 'target', 'account_email')" + * + * @param {et2_widget} _src_widget widget to select the user + * @param {string} _target_name name of widget to set the data + * @param {string} _field name of data to set eg. "account_email" + */ + set_account_data: function(_src_widget, _target_name, _field) + { + var user = _src_widget.get_value(); + var target = _src_widget.getRoot().getWidgetById(_target_name); + + if (user && target) + { + egw.accountData(user, _field, false, function(_data) + { + target.set_value(_data[user]); + }); + }; + }, + /** * Invalidate client-side account cache *