change validation of configuration to return existing validation functions, not running arbitrary ones

This commit is contained in:
Ralf Becker 2014-04-23 14:36:08 +00:00
parent 54e241f468
commit df8f6b9460
5 changed files with 18 additions and 12 deletions

View File

@ -118,12 +118,12 @@ class uiconfig
if ($config)
{
$c->config_data[$key] = $config;
if($GLOBALS['egw_info']['server']['found_validation_hook'] && function_exists($key))
if (in_array($key, (array)$GLOBALS['egw_info']['server']['found_validation_hook'], true) && function_exists($key))
{
call_user_func($key,$config);
if($GLOBALS['config_error'])
{
$errors .= lang($GLOBALS['config_error']) . ' ';
$errors .= lang($GLOBALS['config_error']) . "\n";
$GLOBALS['config_error'] = False;
}
}
@ -134,12 +134,13 @@ class uiconfig
unset($c->config_data[$key]);
}
}
if($GLOBALS['egw_info']['server']['found_validation_hook'] && function_exists('final_validation'))
if(in_array('final_validation', (array)$GLOBALS['egw_info']['server']['found_validation_hook']) &&
function_exists('final_validation'))
{
final_validation($_POST['newsettings']);
if($GLOBALS['config_error'])
{
$errors .= lang($GLOBALS['config_error']) . ' ';
$errors .= lang($GLOBALS['config_error']) . "\n";
$GLOBALS['config_error'] = False;
}
unset($GLOBALS['egw_info']['server']['found_validation_hook']);

View File

@ -10,10 +10,9 @@
*/
/*
Set a global flag to indicate this file was found by setup/config.php.
config.php will unset it after parsing the form values.
Set global flag to indicate for which config settings we have equally named validation methods
*/
$GLOBALS['egw_info']['server']['found_validation_hook'] = True;
$GLOBALS['egw_info']['server']['found_validation_hook'] = array('vfs_image_dir');
/**
* Check VFS dir exists and delete image map to recreate it, if vfs-image-dir changes

View File

@ -698,7 +698,7 @@ class calendar_hooks
public static function config_validate()
{
$GLOBALS['egw_info']['server']['found_validation_hook'] = True;
$GLOBALS['egw_info']['server']['found_validation_hook'] = array('calendar_purge_old');
}
/**

View File

@ -70,7 +70,7 @@ if(@get_var('submit',Array('POST')) && @$newsettings)
$GLOBALS['egw_setup']->db->transaction_begin();
foreach($newsettings as $setting => $value)
{
if($GLOBALS['egw_info']['server']['found_validation_hook'] && @function_exists($setting))
if(in_array($setting, (array)$GLOBALS['egw_info']['server']['found_validation_hook']) && function_exists($setting))
{
$setting($newsettings);
if($GLOBALS['config_error'])

View File

@ -11,10 +11,16 @@
*/
/*
Set a global flag to indicate this file was found by setup/config.php.
config.php will unset it after parsing the form values.
Set global flag to indicate for which config settings we have equally named validation methods
*/
$GLOBALS['egw_info']['server']['found_validation_hook'] = True;
$GLOBALS['egw_info']['server']['found_validation_hook'] = array(
'vfs_storage_mode',
'temp_dir',
'files_dir',
'backup_dir',
'mcrypt_algo',
'ldap_search_filter'
);
/**
* Set vfs_fstab depending from what the user selected for vfs_storage_mode