Hi Devs,
this is following up of http://lists.roundcube.net/mail-archive/dev/2009-05/0000053.html.
I think it might be a good idea to load plugin configurations from the plugin folder instead of the requirement to edit the main configuration. The main configuration file will get crowdy soon if there will be hopefully lots of plugins.
There was also a request in RoundCubeForum to do so by "corbosman" (http://www.roundcubeforum.net/plug-ins/4699-change-password-hmailserver-5-1-...).
Please see attached suggestion and let me know if you will accept the modifications. I'm just in process to update MyRoundCube to use the new Plugin API and have to know if I can rely on this method.
Regards, Roland
--- 8< --- detachments --- 8< --- The following attachments have been detached and are available for viewing. http://detached.gigo.com/rc/cb/J8Um9KKY/rcube_config.php.patch Only click these links if you trust the sender, as well as this message. --- 8< --- detachments --- 8< ---
List info: http://lists.roundcube.net/dev/
I think it might be a good idea to load plugin configurations from the plugin folder instead of the requirement to edit the main configuration. The main configuration file will get crowdy soon if there will be hopefully lots of plugins.
There was also a request in RoundCubeForum to do so by "corbosman" (http://www.roundcubeforum.net/plug-ins/4699-change-password-hmailserver-5-1-...).
I think another way to do this is by creating an api function that loads the config for the calling plugin. So in a plugin init function you'd say:
$this->load_plugin_config(....);
Or something similar. That way you dont need to loop over all plugin configs, as some may not have any config. Saves a bunch of unnecessary file stats.
My primary concern is that a year from now the main config file is a mess with config lines of lots of plugins making it even harder to maintain it into the future..see point below.
As a second issue, im wondering if it's an idea to allow for a local.inc.php or something similar that overrides main.inc and perhaps even db.inc as well. That way you can just copy the distribution config files to your main/db config files, without having to worry about changes you made to them and additions being introduced in the distribution files.
Regards,
Cor _______________________________________________ List info: http://lists.roundcube.net/dev/
Thanks for reply ... Do you think about a patch for your approach?
Regards, Roland
----- Original Message ----- From: "Cor Bosman" cor@xs4all.nl To: "Roland Liebl" roland@roland-liebl.de Cc: dev@lists.roundcube.net Sent: Sunday, May 17, 2009 11:01 AM Subject: Re: [RCD] Load plugin config from plugin folder
I think it might be a good idea to load plugin configurations from the plugin folder instead of the requirement to edit the main configuration. The main configuration file will get crowdy soon if there will be hopefully lots of plugins.
There was also a request in RoundCubeForum to do so by "corbosman" (http://www.roundcubeforum.net/plug-ins/4699-change-password-hmailserver-5-1-...).
I think another way to do this is by creating an api function that loads the config for the calling plugin. So in a plugin init function you'd say:
$this->load_plugin_config(....);
Or something similar. That way you dont need to loop over all plugin configs, as some may not have any config. Saves a bunch of unnecessary file stats.
My primary concern is that a year from now the main config file is a mess with config lines of lots of plugins making it even harder to maintain it into the future..see point below.
As a second issue, im wondering if it's an idea to allow for a local.inc.php or something similar that overrides main.inc and perhaps even db.inc as well. That way you can just copy the distribution config files to your main/db config files, without having to worry about changes you made to them and additions being introduced in the distribution files.
Regards,
Cor
List info: http://lists.roundcube.net/dev/
Roland Liebl wrote:
I think it might be a good idea to load plugin configurations from the plugin folder instead of the requirement to edit the main configuration. The main configuration file will get crowdy soon if there will be hopefully lots of plugins.
Plugins configuration and localization should be unified in some way. This is needed to solve at least three problems:
properly localized after language change (because plugin::init() is called before)
About config, Maybe it's time to move config into database?
In my plugins I've been calling a function in the plugin init of:
class plugin_name extends rcube_plugin {
public function init() { _load_config(); }
private function _load_config() { include('config.inc.php'); $this->config = (array) $_config; }
}
with the config in plugins/plugin_name/config.inc.php with the content:
$_config = array(); $_config['plugin_var'] = 'plugin_var_value'; ...
Why not extend the rcube_plugin class to do something similar? I'm thinking along the same lines as the localization texts. It keeps the config file localized to the plugins/plugin_name/ directory and would follow the same thought process as plugins/plugin_name/localization/. I think that value added by keeping similar functionality by keeping the learning curve for the api shallow.
Per user customization can be done similar to the example in the subscriptions_option plugin.
On Sun, 17 May 2009 13:03:37 -0230, Robert King robk@mun.ca wrote:
In my plugins I've been calling a function in the plugin init of:
class plugin_name extends rcube_plugin {
public function init() { _load_config(); }
private function _load_config() { include('config.inc.php'); $this->config = (array) $_config; }
}
Forgot this important detail:
class plugin_name extends rcube_plugin { private $config; ... }
OK, very handy, if the config has to be available within the plugin only.
But if to access the config on a global level, we have to include the config file in rcube_config.php.
Could I do ...
global $CONFIG; $CONFIG = array_merge ...
or better
$rcmail->config = array_merge ...
... within a plugin?
Cor Bosman: It would solve the unnecessary file stats and no Core modifications are necessary.
Regards, Roland
----- Original Message ----- From: "Robert King" robk@mun.ca To: "RoundCube Dev" dev@lists.roundcube.net Sent: Sunday, May 17, 2009 5:42 PM Subject: Re: [RCD] Load plugin config from plugin folder
On Sun, 17 May 2009 13:03:37 -0230, Robert King robk@mun.ca wrote:
In my plugins I've been calling a function in the plugin init of:
class plugin_name extends rcube_plugin {
public function init() { _load_config(); }
private function _load_config() { include('config.inc.php'); $this->config = (array) $_config; }
}
Forgot this important detail:
class plugin_name extends rcube_plugin { private $config; ... }
-- Robert King System Administrator Computing & Communications Memorial University _______________________________________________ List info: http://lists.roundcube.net/dev/
List info: http://lists.roundcube.net/dev/
OK, very handy, if the config has to be available within the plugin only.
But if to access the config on a global level, we have to include the config file in rcube_config.php.
Could I do ...
global $CONFIG; $CONFIG = array_merge ...
or better
$rcmail->config = array_merge ...
... within a plugin?
Cor Bosman: It would solve the unnecessary file stats and no Core modifications are necessary.
Regards, Roland
----- Original Message ----- From: "Robert King" robk@mun.ca To: "RoundCube Dev" dev@lists.roundcube.net Sent: Sunday, May 17, 2009 5:42 PM Subject: Re: [RCD] Load plugin config from plugin folder
On Sun, 17 May 2009 13:03:37 -0230, Robert King robk@mun.ca wrote:
In my plugins I've been calling a function in the plugin init of:
class plugin_name extends rcube_plugin {
public function init() { _load_config(); }
private function _load_config() { include('config.inc.php'); $this->config = (array) $_config; }
}
Forgot this important detail:
class plugin_name extends rcube_plugin { private $config; ... }
-- Robert King System Administrator Computing & Communications Memorial University _______________________________________________ List info: http://lists.roundcube.net/dev/
List info: http://lists.roundcube.net/dev/
Resolved like inspired by Robert King. Thanks! Patch is not required anymore.
I would just need your opinion about:
http://lists.roundcube.net/mail-archive/dev/2009-05/0000053.html
Regards, Roland
function _load_config($plugin) { $rcmail = rcmail::get_instance(); $config = $rcmail->config->get('plugins_dir') . "/" . $plugin . "/config/config.inc.php"; if(file_exists($config)) include $config; else if(file_exists($config . ".dist")) include $config . ".dist"; if(is_array($rcmail_config)){ $rcmail->config->merge($rcmail_config); } }
----- Original Message ----- From: "Robert King" robk@mun.ca To: "RoundCube Dev" dev@lists.roundcube.net Sent: Sunday, May 17, 2009 5:42 PM Subject: Re: [RCD] Load plugin config from plugin folder
On Sun, 17 May 2009 13:03:37 -0230, Robert King robk@mun.ca wrote:
In my plugins I've been calling a function in the plugin init of:
class plugin_name extends rcube_plugin {
public function init() { _load_config(); }
private function _load_config() { include('config.inc.php'); $this->config = (array) $_config; }
}
Forgot this important detail:
class plugin_name extends rcube_plugin { private $config; ... }
-- Robert King System Administrator Computing & Communications Memorial University _______________________________________________ List info: http://lists.roundcube.net/dev/
List info: http://lists.roundcube.net/dev/
On Mon, 18 May 2009 09:42:00 +0200, "Roland Liebl" roland@roland-liebl.de wrote:
Resolved like inspired by Robert King. Thanks! Patch is not required anymore.
I would just need your opinion about:
http://lists.roundcube.net/mail-archive/dev/2009-05/0000053.html
Regards, Roland
I can't take credit for that idea. The idea came from Phil Weir's sieverules plugin, I just modified it a small amount.
On Sun, May 17, 2009 at 1:12 PM, A.L.E.C alec@alec.pl wrote:
Roland Liebl wrote:
I think it might be a good idea to load plugin configurations from the plugin folder instead of the requirement to edit the main configuration. The main configuration file will get crowdy soon if there will be hopefully lots of plugins.
Plugins configuration and localization should be unified in some way. This is needed to solve at least three problems:
- described by you, config file size
- plugins configuration in installer
- language change in Settings->Preferences. E.g. password tab isn't
properly localized after language change (because plugin::init() is called before)
About config, Maybe it's time to move config into database?
What about autoloading it? E.g., on first hit:
// find all configs foreach (glob('./roundcube/plugins/*/etc/config.php') as $file)) { include $file; }
Each file would be an ini or maybe an array or straight PHP code.
$RCMAIL->config->setNamespace('plugin_name'); // this needs to be added ;-) $RCMAIL->config->set('foo', 'bar');
etc..
Internally... $this->prop['plugins']['plugin_name']['foo'] = 'bar';
Then cache it for an hour to avoid re-doing it on each request (or for a day) and so on.
Till _______________________________________________ List info: http://lists.roundcube.net/dev/