Elastic: Fix unintentional layout preference overwrite (#6613)

This is actually skin-independent mechanism that prevents overwriting
of skin-specific preferences by ajax requests (that until now were
not aware of skin config).
pull/6622/head
Aleksander Machniak 6 years ago
parent 77fc589974
commit 641a67fe75

@ -45,6 +45,7 @@ CHANGELOG Roundcube Webmail
- Elastic: Fix too small height of mailvelope mail preview frame (#6600)
- Elastic: Add "status bar" for mobile in mail composer
- Elastic: Add selection options on contacts list (#6595)
- Elastic: Fix unintentional layout preference overwrite (#6613)
- Log errors caused by low pcre.backtrack_limit when sending a mail message (#6433)
- Fix so max_message_size limit is checked also when forwarding messages as attachments (#6580)
- Fix so performance stats are logged to the main console log also when per_user_logging=true

@ -328,18 +328,22 @@ EOF;
$this->skins[$skin_id] = $meta;
// Keep skin config for ajax requests (#6613)
$_SESSION['skin_config'] = array();
if ($meta['extends']) {
$path = RCUBE_INSTALL_PATH . 'skins/';
if (is_dir($path . $meta['extends']) && is_readable($path . $meta['extends'])) {
$this->load_skin('skins/' . $meta['extends']);
$_SESSION['skin_config'] = $this->load_skin('skins/' . $meta['extends']);
}
}
foreach ((array) $meta['config'] as $key => $value) {
$this->config->set($key, $value, true);
}
if (!empty($meta['config'])) {
foreach ($meta['config'] as $key => $value) {
$this->config->set($key, $value, true);
$_SESSION['skin_config'][$key] = $value;
}
$value = array_merge((array) $this->config->get('dont_override'), array_keys($meta['config']));
$this->config->set('dont_override', $value, true);
}
@ -354,6 +358,8 @@ EOF;
// Use array_merge() here to allow for global default and extended skins
$this->meta_tags = array_merge($this->meta_tags, (array) $meta['meta']);
$this->link_tags = array_merge($this->link_tags, (array) $meta['links']);
return $_SESSION['skin_config'];
}
/**

@ -36,6 +36,23 @@ class rcmail_output_json extends rcmail_output
public $ajax_call = true;
/**
* Object constructor
*/
public function __construct($task = null, $framed = false)
{
parent::__construct();
if (!empty($_SESSION['skin_config'])) {
foreach ($_SESSION['skin_config'] as $key => $value) {
$this->config->set($key, $value, true);
}
$value = array_merge((array) $this->config->get('dont_override'), array_keys($_SESSION['skin_config']));
$this->config->set('dont_override', $value, true);
}
}
/**
* Issue command to set page title
*

@ -479,6 +479,18 @@ class rcube_config
return $plugin['result'];
}
/**
* Some options set as immutable that are also listed
* in dont_override should not be stored permanently
* in user preferences. Here's the list of these
*
* @return array List of transient options
*/
public function transient_options()
{
return array_intersect(array_keys($this->immutable), (array) $this->get('dont_override'));
}
/**
* Special getter for user's timezone offset including DST
*

@ -179,6 +179,14 @@ class rcube_user
return false;
}
$config = $this->rc->config;
$transient = $config->transient_options();
$a_user_prefs = array_diff_key($a_user_prefs, array_flip($transient));
if (empty($a_user_prefs)) {
return true;
}
$plugin = $this->rc->plugins->exec_hook('preferences_update', array(
'userid' => $this->ID,
'prefs' => $a_user_prefs,
@ -191,7 +199,6 @@ class rcube_user
$a_user_prefs = $plugin['prefs'];
$old_prefs = $plugin['old'];
$config = $this->rc->config;
$defaults = $config->all();
// merge (partial) prefs array with existing settings

Loading…
Cancel
Save