fix not stored multiselect / array-values in site-configuration

also added optional appname for apps storing their config under "phpgwapi" like eg. addressbook
This commit is contained in:
Ralf Becker 2018-08-21 17:27:30 +02:00
parent 698e77e0cb
commit 613455a784
2 changed files with 24 additions and 5 deletions

View File

@ -14,7 +14,8 @@ use EGroupware\Api;
/** /**
* setup command: change EGw configuration * setup command: change EGw configuration
* *
* @property-read string $app app whos config to change * @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 array $set config data to set, value of null or "" to remove * @property-read array $set config data to set, value of null or "" to remove
* @property-read array $old old values to record * @property-read array $old old values to record
*/ */
@ -72,6 +73,17 @@ class admin_cmd_config extends admin_cmd
} }
$config->save_repository(); $config->save_repository();
return lang('Configuration changed.'); return lang('Configuration saved.');
}
/**
* Return a title / string representation for a given command, eg. to display it
*
* @return string
*/
function __tostring()
{
return lang('%1 site configuration',
lang($this->appname ? $this->appname : $this->app));
} }
} }

View File

@ -180,8 +180,14 @@ class admin_config
} }
// compute real changes and their old values (null for removals) // compute real changes and their old values (null for removals)
$modifications = array_diff_assoc($c->config_data, $old); $modifications = array_udiff_assoc($c->config_data, $old, function($a, $b)
$removals = array_diff_assoc($old, $c->config_data); {
return (int)($a != $b); // necessary to kope with arrays
});
$removals = array_udiff_assoc($old, $c->config_data, function($a, $b)
{
return (int)($a != $b);
});
$set = array_merge(array_fill_keys(array_keys($removals), null), $modifications); $set = array_merge(array_fill_keys(array_keys($removals), null), $modifications);
$old = array_filter($old, function($key) use ($set) $old = array_filter($old, function($key) use ($set)
{ {
@ -189,7 +195,8 @@ class admin_config
}, ARRAY_FILTER_USE_KEY); }, ARRAY_FILTER_USE_KEY);
if ($set) if ($set)
{ {
$cmd = new admin_cmd_config($config_appname, $set, $old, $_content['admin_cmd']); $cmd = new admin_cmd_config($config_appname, $set, $old,
$_content['admin_cmd']+array('appname' => $_appname));
$msg = $cmd->run(); $msg = $cmd->run();
} }
else else