mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-21 23:43:17 +01:00
Introduce new hooks boolean param called 'reload' in order to force main framework to refresh after saving preferences
This commit is contained in:
parent
005686b469
commit
0ad326a507
@ -440,7 +440,8 @@ class mail_hooks
|
||||
'expand' => lang('show horizontal, hide if none selected'),
|
||||
'hide' => lang('never show'),
|
||||
),
|
||||
'default' => 'vertical'
|
||||
'default' => 'vertical',
|
||||
'reload' => true
|
||||
),
|
||||
'toggledOnActions' => array(
|
||||
'type' => 'taglist',
|
||||
|
@ -184,6 +184,7 @@ class preferences_hooks
|
||||
'values' => $textsize,
|
||||
'default' => '14',
|
||||
'admin' => False,
|
||||
'reload' => true
|
||||
),
|
||||
'lazy-update' => array(
|
||||
'type' => 'select',
|
||||
@ -205,6 +206,7 @@ class preferences_hooks
|
||||
'xmlrpc' => True,
|
||||
'admin' => False,
|
||||
'forced' => file_exists(EGW_SERVER_ROOT.'/pixelegg') ? 'pixelegg' : 'idots',
|
||||
'reload' => true
|
||||
),
|
||||
'theme' => array(
|
||||
'type' => 'select',
|
||||
@ -215,6 +217,7 @@ class preferences_hooks
|
||||
'xmlrpc' => True,
|
||||
'admin' => False,
|
||||
'forced' => file_exists(EGW_SERVER_ROOT.'/pixelegg') ? 'pixelegg' : 'idots',
|
||||
'reload' => true
|
||||
),
|
||||
'darkmode' => array(
|
||||
'type' => 'select',
|
||||
@ -335,6 +338,7 @@ class preferences_hooks
|
||||
'xmlrpc' => True,
|
||||
'admin' => False,
|
||||
'default'=> $lang,
|
||||
'reload' => true
|
||||
),
|
||||
'country' => array(
|
||||
'type' => 'et2-select-country',
|
||||
|
@ -99,25 +99,25 @@ class preferences_settings
|
||||
$GLOBALS['egw']->preferences->set_account_id($account_id);
|
||||
$GLOBALS['egw']->preferences->read_repository();
|
||||
}
|
||||
// name of common preferences which require reload of framework, if there values change
|
||||
$require_reload = array('template_set', 'theme', 'lang', 'template_color', 'template_custom_color', 'textsize');
|
||||
$old_values = array_intersect_key($GLOBALS['egw_info']['user']['preferences']['common'], array_flip($require_reload));
|
||||
|
||||
$attribute = $type == 'group' ? 'user' : $type;
|
||||
|
||||
$require_reload = self::fetchRequireToReload($appname, $type);
|
||||
$old_values = array_intersect_key($GLOBALS['egw_info']['user']['preferences'][$appname], array_flip($require_reload));
|
||||
|
||||
if (!($msg=$this->process_array($GLOBALS['egw']->preferences->$attribute, $prefs, $content['types'], $appname, $attribute, $content)))
|
||||
{
|
||||
$msg_type = 'success';
|
||||
$msg = lang('Preferences saved.');
|
||||
|
||||
// do we need to reload whole framework
|
||||
if ($appname == 'common')
|
||||
if (!empty($require_reload))
|
||||
{
|
||||
if ($account_id && $GLOBALS['egw']->preferences->get_account_id() != $GLOBALS['egw_info']['user']['account_id'])
|
||||
{
|
||||
$GLOBALS['egw']->preferences->set_account_id($GLOBALS['egw_info']['user']['account_id']);
|
||||
}
|
||||
$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository();
|
||||
$new_values = array_intersect_key($GLOBALS['egw_info']['user']['preferences']['common'], array_flip($require_reload));
|
||||
$new_values = array_intersect_key($GLOBALS['egw_info']['user']['preferences'][$appname], array_flip($require_reload));
|
||||
//error_log(__METHOD__."() ".__LINE__.": old_values=".array2string($old_values).", new_values=".array2string($new_values));
|
||||
if ($old_values != $new_values)
|
||||
{
|
||||
@ -199,6 +199,41 @@ class preferences_settings
|
||||
$tpl->exec('preferences.preferences_settings.index', $data, $sel_options, $readonlys, $preserve, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch preferences of given app where they have reload attribute set to true
|
||||
* @param string $appname app name
|
||||
* @param string $type 'user', 'default', 'forced'
|
||||
* @return array
|
||||
* @throws Api\Exception\AssertionFailed
|
||||
*/
|
||||
static function fetchRequireToReload($appname, $type)
|
||||
{
|
||||
$keys = [];
|
||||
if ($appname == 'common')
|
||||
{
|
||||
// none app pref names here since we can't read them via hooks
|
||||
$keys = ['template_color', 'template_custom_color', 'sidebox_custom_color'];
|
||||
$settings = Api\Hooks::single(array(
|
||||
'account_id'=>$GLOBALS['egw']->preferences->get_account_id(),
|
||||
'location'=>'settings',
|
||||
'type' => $type), 'preferences');
|
||||
}
|
||||
else
|
||||
{
|
||||
$settings = Api\Hooks::single(array(
|
||||
'account_id'=>$GLOBALS['egw']->preferences->get_account_id(),
|
||||
'location'=>'settings',
|
||||
'type' => $type), $appname);
|
||||
}
|
||||
|
||||
|
||||
foreach ($settings as $key => $value)
|
||||
{
|
||||
if ($value['reload']) $keys[]=$key;
|
||||
}
|
||||
return $keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* run admin command instance
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user