mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 16:03:47 +01:00
change validation of configuration to return existing validation functions, not running arbitrary ones
This commit is contained in:
parent
07a04040e6
commit
035215450f
@ -118,12 +118,12 @@ class uiconfig
|
|||||||
if ($config)
|
if ($config)
|
||||||
{
|
{
|
||||||
$c->config_data[$key] = $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);
|
call_user_func($key,$config);
|
||||||
if($GLOBALS['config_error'])
|
if($GLOBALS['config_error'])
|
||||||
{
|
{
|
||||||
$errors .= lang($GLOBALS['config_error']) . ' ';
|
$errors .= lang($GLOBALS['config_error']) . "\n";
|
||||||
$GLOBALS['config_error'] = False;
|
$GLOBALS['config_error'] = False;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,12 +134,13 @@ class uiconfig
|
|||||||
unset($c->config_data[$key]);
|
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']);
|
final_validation($_POST['newsettings']);
|
||||||
if($GLOBALS['config_error'])
|
if($GLOBALS['config_error'])
|
||||||
{
|
{
|
||||||
$errors .= lang($GLOBALS['config_error']) . ' ';
|
$errors .= lang($GLOBALS['config_error']) . "\n";
|
||||||
$GLOBALS['config_error'] = False;
|
$GLOBALS['config_error'] = False;
|
||||||
}
|
}
|
||||||
unset($GLOBALS['egw_info']['server']['found_validation_hook']);
|
unset($GLOBALS['egw_info']['server']['found_validation_hook']);
|
||||||
|
37
admin/inc/hook_config_validate.inc.php
Normal file
37
admin/inc/hook_config_validate.inc.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* EGroupware administration
|
||||||
|
*
|
||||||
|
* @link http://www.egroupware.org
|
||||||
|
* @package setup
|
||||||
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||||
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Set global flag to indicate for which config settings we have equally named validation methods
|
||||||
|
*/
|
||||||
|
$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
|
||||||
|
*
|
||||||
|
* @param string
|
||||||
|
*/
|
||||||
|
function vfs_image_dir($vfs_image_dir)
|
||||||
|
{
|
||||||
|
//error_log(__FUNCTION__.'() vfs_image_dir='.array2string($vfs_image_dir).' was '.array2string($GLOBALS['egw_info']['server']['vfs_image_dir']));
|
||||||
|
if (!empty($vfs_image_dir))
|
||||||
|
{
|
||||||
|
if (!egw_vfs::file_exists($vfs_image_dir) || !egw_vfs::is_dir($vfs_image_dir))
|
||||||
|
{
|
||||||
|
$GLOBALS['config_error'] = lang('VFS directory "%1" NOT found!',$vfs_image_dir);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($vfs_image_dir != (string)$GLOBALS['egw_info']['server']['vfs_image_dir'])
|
||||||
|
{
|
||||||
|
common::delete_image_map();
|
||||||
|
}
|
||||||
|
}
|
@ -35,6 +35,7 @@ $setup_info['admin']['hooks'] = array(
|
|||||||
'add_def_pref',
|
'add_def_pref',
|
||||||
'after_navbar',
|
'after_navbar',
|
||||||
'config',
|
'config',
|
||||||
|
'config_validate',
|
||||||
'deleteaccount',
|
'deleteaccount',
|
||||||
'view_user' => 'admin.uiaccounts.edit_view_user_hook',
|
'view_user' => 'admin.uiaccounts.edit_view_user_hook',
|
||||||
'edit_user' => 'admin.uiaccounts.edit_view_user_hook',
|
'edit_user' => 'admin.uiaccounts.edit_view_user_hook',
|
||||||
|
@ -707,7 +707,7 @@ class calendar_hooks
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function config_validate() {
|
public static function config_validate() {
|
||||||
$GLOBALS['egw_info']['server']['found_validation_hook'] = True;
|
$GLOBALS['egw_info']['server']['found_validation_hook'] = array('calendar_purge_old');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ if(@get_var('submit',Array('POST')) && @$newsettings)
|
|||||||
$GLOBALS['egw_setup']->db->transaction_begin();
|
$GLOBALS['egw_setup']->db->transaction_begin();
|
||||||
foreach($newsettings as $setting => $value)
|
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);
|
$setting($newsettings);
|
||||||
if($GLOBALS['config_error'])
|
if($GLOBALS['config_error'])
|
||||||
|
@ -11,10 +11,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Set a global flag to indicate this file was found by setup/config.php.
|
Set global flag to indicate for which config settings we have equally named validation methods
|
||||||
config.php will unset it after parsing the form values.
|
|
||||||
*/
|
*/
|
||||||
$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
|
* Set vfs_fstab depending from what the user selected for vfs_storage_mode
|
||||||
|
Loading…
Reference in New Issue
Block a user