From 8c6fc0f4d54910c83edbc278bb5eef9e8b38b4f7 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 14 Mar 2019 18:57:07 +0100 Subject: [PATCH] WIP admin history --- admin/inc/class.admin_cmd.inc.php | 53 +++++++++++++++++++++ admin/inc/class.admin_cmd_config.inc.php | 20 ++++++++ admin/inc/class.admin_cmd_edit_user.inc.php | 12 +++++ admin/inc/class.admin_cmds.inc.php | 10 +++- admin/templates/default/cmds.xet | 5 +- 5 files changed, 95 insertions(+), 5 deletions(-) diff --git a/admin/inc/class.admin_cmd.inc.php b/admin/inc/class.admin_cmd.inc.php index 359dfbc537..6e3f520435 100644 --- a/admin/inc/class.admin_cmd.inc.php +++ b/admin/inc/class.admin_cmd.inc.php @@ -1295,4 +1295,57 @@ abstract class admin_cmd { return Api\Auth::randomstring($len); } + + /** + * Return (human readable) labels for keys of changes + * + * @return array + */ + function get_change_labels() + { + return []; + } + + /** + * Read change labels from descriptions in template: + * - + * - \n + * - + * @param type $name + */ + protected function change_labels_from_template($name) + { + $labels = []; + $matches = null; + if (($path = Api\Etemplate::relPath($name)) && + ($tpl = file_get_contents(Api\Etemplate::rel2path($path)))) + { + if (preg_match_all('/ $name) + { + $id = $matches[3][$key]; + $label= $matches[1][$key]; + if (!empty($id) && !empty($label)) + { + $labels[$id] = $label; + } + } + } + if (preg_match_all('/<(checkbox).*(label|id)="([^"]+)".*(label|id)="([^"]+)"/', $tpl, $matches, PREG_PATTERN_ORDER)) + { + foreach($matches[2] as $key => $name) + { + $id = $name === 'id' ? $matches[3][$key] : $matches[5][$key]; + $label= $name === 'id' ? $matches[5][$key] : $matches[3][$key]; + if (!empty($id) && !empty($label)) + { + $labels[$id] = $label; + } + } + } + } + error_log(__METHOD__."($name) path=$path returning ".json_encode($labels)); + return $labels; + } } diff --git a/admin/inc/class.admin_cmd_config.inc.php b/admin/inc/class.admin_cmd_config.inc.php index f671ba052f..2a78a75c64 100644 --- a/admin/inc/class.admin_cmd_config.inc.php +++ b/admin/inc/class.admin_cmd_config.inc.php @@ -86,4 +86,24 @@ class admin_cmd_config extends admin_cmd return lang('%1 site configuration', lang($this->appname ? $this->appname : $this->app)); } + + /** + * Return (human readable) labels for keys of changes + * + * Reading them from admin.account template + * + * @return array + */ + function get_change_labels() + { + $labels = []; + foreach($this->change_labels_from_template(($this->appname ? $this->appname : $this->app).'.config') as $id => $label) + { + if (strpos($id, 'newsettings[') === 0) + { + $labels[substr($id, 12, -1)] = $label; + } + } + return $labels; + } } diff --git a/admin/inc/class.admin_cmd_edit_user.inc.php b/admin/inc/class.admin_cmd_edit_user.inc.php index c9e0cdf778..0f50c26a7a 100644 --- a/admin/inc/class.admin_cmd_edit_user.inc.php +++ b/admin/inc/class.admin_cmd_edit_user.inc.php @@ -224,6 +224,18 @@ class admin_cmd_edit_user extends admin_cmd_change_pw admin_cmd::display_account($this->account ? $this->account : $this->set['account_lid'])); } + /** + * Return (human readable) labels for keys of changes + * + * Reading them from admin.account template + * + * @return array + */ + function get_change_labels() + { + return $this->change_labels_from_template('admin.account'); + } + /** * parse the expired string and return the expired date as timestamp * diff --git a/admin/inc/class.admin_cmds.inc.php b/admin/inc/class.admin_cmds.inc.php index 4238e05c7f..8dc65e060a 100644 --- a/admin/inc/class.admin_cmds.inc.php +++ b/admin/inc/class.admin_cmds.inc.php @@ -5,7 +5,7 @@ * @link http://www.egroupware.org * @author Ralf Becker * @package admin - * @copyright (c) 2007-18 by Ralf Becker + * @copyright (c) 2007-19 by Ralf Becker * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License */ @@ -34,6 +34,12 @@ class admin_cmds { Api\Cache::setSession('admin', 'cmds', $query); + // show also old api + if ($query['col_filter']['app'] === 'api') + { + $query['col_filter']['app'] = ['api', 'phpgwapi']; + } + return admin_cmd::get_rows($query,$rows,$readonlys); } @@ -60,9 +66,9 @@ class admin_cmds 'sort' => 'DESC', 'row_id' => 'id', 'default_cols' => 'title,created,creator,status', - 'actions' => self::cmd_actions(), ); } + $content['nm']['actions'] = self::cmd_actions(); } elseif ($content['nm']['rows']['delete']) { diff --git a/admin/templates/default/cmds.xet b/admin/templates/default/cmds.xet index d5d8dc4f2d..3b33d51fcf 100644 --- a/admin/templates/default/cmds.xet +++ b/admin/templates/default/cmds.xet @@ -1,6 +1,5 @@ -