From f7abe770bd530beab67bdd0a9ff2cb5b67d59386 Mon Sep 17 00:00:00 2001 From: nathangray Date: Thu, 21 Mar 2019 14:29:33 -0600 Subject: [PATCH] Admin - Keep the result of running the command (eg: how many rows affected, etc) --- admin/inc/class.admin_cmd.inc.php | 15 +++++++++++++++ admin/inc/class.admin_cmd_edit_user.inc.php | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/admin/inc/class.admin_cmd.inc.php b/admin/inc/class.admin_cmd.inc.php index 80107937fc..959e512c65 100644 --- a/admin/inc/class.admin_cmd.inc.php +++ b/admin/inc/class.admin_cmd.inc.php @@ -39,6 +39,7 @@ use EGroupware\Api\Acl; * @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 string|NULL $result Result message indicating what happened, or NULL on failure * @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 @@ -248,6 +249,7 @@ abstract class admin_cmd $this->status = admin_cmd::failed; } } + $this->result = $ret; if (!$dont_save && !$dry_run && !$this->save($set_modifier)) { throw new Api\Db\Exception(lang('Error saving the command!')); @@ -1431,4 +1433,17 @@ abstract class admin_cmd } return $widgets; } + + /** + * Get the result of executing the command. + * Should be some kind of success or results message indicating what was done. + */ + public function get_result() + { + if($this->result) + { + return $this->result; + } + return static::$stati[ $this->status ]; + } } diff --git a/admin/inc/class.admin_cmd_edit_user.inc.php b/admin/inc/class.admin_cmd_edit_user.inc.php index feb7d1e3a1..d10325323e 100644 --- a/admin/inc/class.admin_cmd_edit_user.inc.php +++ b/admin/inc/class.admin_cmd_edit_user.inc.php @@ -234,6 +234,21 @@ class admin_cmd_edit_user extends admin_cmd_change_pw return 'admin.account'; } + /** + * Return (human readable) labels for keys of changes + * + * @return array + */ + function get_change_labels() + { + $labels = parent::get_change_labels(); + $labels += array( + 'account_lastname' => 'lastname', + 'account_firstname' => 'firstname' + ); + return $labels; + } + /** * parse the expired string and return the expired date as timestamp *