diff --git a/admin/inc/class.admin_cmd.inc.php b/admin/inc/class.admin_cmd.inc.php index dc8b1ce0c6..80107937fc 100644 --- a/admin/inc/class.admin_cmd.inc.php +++ b/admin/inc/class.admin_cmd.inc.php @@ -1378,11 +1378,13 @@ abstract class admin_cmd */ function get_change_widgets() { + static $selectboxes = ['select', 'listbox', 'menupopup', 'taglist']; + $widgets = []; $last_select = null; if (($tpl = $this->get_etemplate())) { - $tpl->run(function($cname, $expand, $widget) use (&$widgets, &$last_select) + $tpl->run(function($cname, $expand, $widget) use (&$widgets, &$last_select, $selectboxes) { switch($widget->type) { @@ -1391,7 +1393,7 @@ abstract class admin_cmd case 'grid': case 'columns': case 'column': case 'rows': case 'row': case 'template': case 'tabbox': case 'tabs': case 'tab': // No need for these - case 'textbox': case 'int': case 'float': case 'select': + case 'textbox': case 'int': case 'float': // ignore widgets that can't go in the historylog case 'button': case 'buttononly': case 'taglist-thumbnail': break; @@ -1414,7 +1416,7 @@ abstract class admin_cmd if (!empty($widget->id)) { $widgets[$widget->id] = $widget->type; - if (in_array($widget->type, ['select'])) + if (in_array($widget->type, $selectboxes)) { $last_select = $widget->id; } @@ -1423,6 +1425,9 @@ abstract class admin_cmd } unset($cname, $expand); }, ['', []]); + + // remove pure selectboxes, as they would show nothing without having options + $widgets = array_diff($widgets, $selectboxes); } return $widgets; } diff --git a/admin/inc/class.admin_cmd_config.inc.php b/admin/inc/class.admin_cmd_config.inc.php index 0f1ac1ec13..d4d22e9ed0 100644 --- a/admin/inc/class.admin_cmd_config.inc.php +++ b/admin/inc/class.admin_cmd_config.inc.php @@ -14,8 +14,8 @@ use EGroupware\Api; /** * setup command: change EGw configuration * - * @property-read string $app app whos config to change (egw_config.config_app) - * @property-read string $appname app name whos config is changed (some apps store their config under app="phpgwapi") + * @property-read string $app app whos config to change + * @property-read boolean $store_as_api some apps store their config under app="phpgwapi" * @property-read array $set config data to set, value of null or "" to remove * @property-read array $old old values to record */ @@ -26,6 +26,11 @@ class admin_cmd_config extends admin_cmd */ //const SETUP_CLI_CALLABLE = true; // need to check how to parse arguments + /** + * Name to use if $this->store_as_api is set + */ + const STORE_AS_API = 'phpgwapi'; + /** * Constructor * @@ -33,8 +38,9 @@ class admin_cmd_config extends admin_cmd * @param array $set =null config data to set, value of null or "" to remove * @param array $old =null old values to record * @param array $other =null values for keys "requested", "requested_email", "comment", etc + * @param boolean $store_as_api =false true: store under "phpgwapi" */ - function __construct($data, array $set=null, array $old=null, $other=null) + function __construct($data, array $set=null, array $old=null, array $other=null, $store_as_api=false) { if (!is_array($data)) { @@ -42,8 +48,18 @@ class admin_cmd_config extends admin_cmd 'app' => $data, 'set' => $set, 'old' => $old, + 'store_as_api' => $store_as_api, )+(array)$other; } + + // fix depreated use of app="phpwapi" or appname!=app + if ($data['app'] === self::STORE_AS_API || !empty($data['appname'])) + { + $data['store_as_api'] = true; + $data['app'] = !empty($data['appname']) ? $data['appname'] : 'setup'; + unset($data['appname']); + } + //echo __CLASS__.'::__construct()'; _debug_array($domain); admin_cmd::__construct($data); } @@ -63,7 +79,7 @@ class admin_cmd_config extends admin_cmd return true; // no specific checks exist } - $config = new Api\Config($this->app); + $config = new Api\Config($this->store_as_api ? self::STORE_AS_API : $this->app); $config->read_repository(); // store the config @@ -83,8 +99,7 @@ class admin_cmd_config extends admin_cmd */ function __tostring() { - return lang('%1 site configuration', - lang($this->appname ? $this->appname : $this->app)); + return lang('site configuration').': '.lang($this->app); } /** @@ -94,7 +109,7 @@ class admin_cmd_config extends admin_cmd */ function get_etemplate_name() { - return ($this->appname ? $this->appname : $this->app).'.config'; + return $this->app.'.config'; } /** @@ -127,11 +142,20 @@ class admin_cmd_config extends admin_cmd function get_change_widgets() { $widgets = []; + + // get selectbox options from "config" hook + $ret = Api\Hooks::single('config', $this->app); + if (is_array($ret) && isset($ret['sel_options'])) + { + $widgets = $ret['sel_options']; + } + + // get widgets from eTemplate (with newsettings namespace!) foreach(parent::get_change_widgets() as $id => $widget) { if (strpos($id, 'newsettings[') === 0) { - $widgets[substr($id, 12, -1)] = $widget; + $widgets[$id=substr($id, 12, -1)] = $widget; } } return $widgets; diff --git a/admin/inc/class.admin_config.inc.php b/admin/inc/class.admin_config.inc.php index 5325822f5f..346f6a0430 100644 --- a/admin/inc/class.admin_config.inc.php +++ b/admin/inc/class.admin_config.inc.php @@ -195,8 +195,8 @@ class admin_config }, ARRAY_FILTER_USE_KEY); if ($set) { - $cmd = new admin_cmd_config($config_appname, $set, $old, - (array)$_content['admin_cmd']+array('appname' => $_appname)); + $cmd = new admin_cmd_config($_appname, $set, $old, + (array)$_content['admin_cmd'], $config_appname === 'phpgwapi'); $msg = $cmd->run(); } else diff --git a/admin/setup/setup.inc.php b/admin/setup/setup.inc.php index 6c8a9c4b24..5325f1d343 100644 --- a/admin/setup/setup.inc.php +++ b/admin/setup/setup.inc.php @@ -9,7 +9,7 @@ */ $setup_info['admin']['name'] = 'admin'; -$setup_info['admin']['version'] = '18.1'; +$setup_info['admin']['version'] = '18.1.001'; $setup_info['admin']['app_order'] = 1; $setup_info['admin']['tables'] = array('egw_admin_queue','egw_admin_remote'); $setup_info['admin']['enable'] = 1; @@ -18,7 +18,7 @@ $setup_info['admin']['index'] = 'admin.admin_ui.index&ajax=true'; $setup_info['admin']['author'] = $setup_info['admin']['maintainer'] = array( 'name' => 'EGroupware GmbH', 'email' => 'info@egroupware.org', - 'url' => 'http://www.egroupware.org' + 'url' => 'https://www.egroupware.org' ); $setup_info['admin']['license'] = 'GPL'; @@ -42,4 +42,3 @@ $setup_info['admin']['depends'][] = array( 'appname' => 'api', 'versions' => Array('17.1') ); - diff --git a/admin/setup/tables_update.inc.php b/admin/setup/tables_update.inc.php index bef08a0b01..15bd645da1 100644 --- a/admin/setup/tables_update.inc.php +++ b/admin/setup/tables_update.inc.php @@ -11,8 +11,6 @@ * @subpackage setup */ -use EGroupware\Api; - function admin_upgrade1_2() { return $GLOBALS['setup_info']['admin']['currentver'] = '1.4'; @@ -243,3 +241,31 @@ function admin_upgrade17_1() return $GLOBALS['setup_info']['admin']['currentver'] = '18.1'; } +/** + * Update admin_cmd_config to use "store_as_api" instead of "app"="phpgwapi" and "appname" + * + * @return string + */ +function admin_upgrade18_1() +{ + // fill cmd_account/app from + foreach($GLOBALS['egw_setup']->db->select('egw_admin_queue', 'cmd_id,cmd_app,cmd_data', array( + 'cmd_app' => 'phpgwapi', + 'cmd_type' => 'admin_cmd_config', + ), __LINE__, __FILE__, false, '', 'admin') as $row) + { + $data = json_php_unserialize($row['cmd_data']); + $data['store_as_api'] = $row['cmd_app'] === 'phpgwapi'; + $row['cmd_app'] = !empty($data['appname']) ? $data['appname'] : 'setup'; + unset($data['appname']); + + $cmd_id = $row['cmd_id']; + unset($row['cmd_id']); + $row['cmd_data'] = json_encode($data); + $GLOBALS['egw_setup']->db->update('egw_admin_queue', $row, + array('cmd_id' => $cmd_id), __LINE__, __FILE__, 'admin'); + } + + return $GLOBALS['setup_info']['admin']['currentver'] = '18.1.001'; +} +