Hi all, im wondering if this is supposed to work or not.
I have a plugin with a config.inc.php, with a setting like:
$rcmail_config['variable'] = array('a', 'b');
My plugin has 3 hooks:
$this->add_hook('login_after', array($this, 'func1'));
$this->add_hook('user_preferences', array($this, 'func2'));
$this->add_hook('save_preferences', array($this, 'func3'));
The plugin allows users to override $rcmail_config['variable'] using
checkboxes. The problem is that in user_preferences hook I always get
the value from load_config, never the user override value.
In login_after I do get the user's value. I know the values are saved
correctly in save_preferences as I can see the right values in the DB
for specific users. Im simply using rcmail::get_instance()->config-
get('variable');
All of this works fine if I add the default values to the main.inc.php
instead of my own config.inc.php
Am i just overseeing something trivial?
Cor
List info: http://lists.roundcube.net/dev/
Cor Bosman wrote:
The plugin allows users to override $rcmail_config['variable'] using
checkboxes. The problem is that in user_preferences hook I always get
the value from load_config, never the user override value. In login_after I do get the user's value. I know the values are saved
correctly in save_preferences as I can see the right values in the DB
for specific users. Im simply using rcmail::get_instance()->config-get('variable');
All of this works fine if I add the default values to the main.inc.php
instead of my own config.inc.phpAm i just overseeing something trivial?
I see the problem: in rcmail::startup() we first call $this->set_user(new rcube_user($_SESSION['user_id'])); which also loads the user prefs into the config object and later on (in index.php) we initialize the plugins which then load their static configuration again over the existing one.
This is certainly something we have to change.
~Thomas _______________________________________________ List info: http://lists.roundcube.net/dev/
Thomas Bruederli wrote:
I see the problem: in rcmail::startup() we first call $this->set_user(new rcube_user($_SESSION['user_id'])); which also loads the user prefs into the config object and later on (in index.php) we initialize the plugins which then load their static configuration again over the existing one.
Here's a quick patch to solve this problem.
This will now prevent existing config options (from user prefs) to be replaced by the default settings of a plugin configuration. I didn't test it well and maybe there might appear some side effects. Please let me know.
Regards, Thomas
--- 8< --- detachments --- 8< --- The following attachments have been detached and are available for viewing. http://detached.gigo.com/rc/gQ/bQCT9Gbm/plugin_config_load.diff Only click these links if you trust the sender, as well as this message. --- 8< --- detachments --- 8< ---
List info: http://lists.roundcube.net/dev/