roundcube / roundcubemail

The Roundcube Webmail suite
https://roundcube.net
GNU General Public License v3.0
5.89k stars 1.64k forks source link

Allow extending config in custom host config file #9458

Open CodeShakingSheep opened 5 months ago

CodeShakingSheep commented 5 months ago

In my config.inc.php file I have defined a default set of plugins, see https://github.com/YunoHost-Apps/roundcube_ynh/blob/master/conf/config.inc.php#L128 . To be able to use further plugins I added $config['include_host_config'] = true; at the end of it.

I created a file called <MY_ROUNDCUBE_DOMAIN>.inc.php in config folder with the following content where my intention was to add 2 more plugins.

<?php
$config['plugins'][] = 'emoticons';
$config['plugins'][] = 'twofactor_gauthenticator';

The file gets read. However, this disables all the other plugins from config.inc.php file. That means only the two defined plugins are active. Why is that? I just want to add more plugins, not entirely override all plugins. Thanks for any hint on this.

johndoh commented 5 months ago

Its possible to to do this with the following line:

array_push($this->prop['plugins'], 'emoticons', 'twofactor_gauthenticator');
alecpl commented 5 months ago

Indeed this is not supported and using $this would be a hack. Maybe we could implement what you need. I suppose the change in rcube_config::load_from_file() would be needed.

Something like this might work, but I'm not sure I like it:

--- a/program/lib/Roundcube/rcube_config.php
+++ b/program/lib/Roundcube/rcube_config.php
@@ -302,6 +302,8 @@ class rcube_config
             if ($fpath && is_file($fpath) && is_readable($fpath)) {
                 // use output buffering, we don't need any output here
                 ob_start();
+                global $config;
+                $config = $this->prop;
                 require $fpath;
                 ob_end_clean();
CodeShakingSheep commented 5 months ago

Its possible to to do this with the following line:

array_push($this->prop['plugins'], 'emoticons', 'twofactor_gauthenticator');

Thanks, this workaround works on my server.

CodeShakingSheep commented 5 months ago

Indeed this is not supported and using $this would be a hack. Maybe we could implement what you need. I suppose the change in rcube_config::load_from_file() would be needed.

Something like this might work, but I'm not sure I like it:

--- a/program/lib/Roundcube/rcube_config.php
+++ b/program/lib/Roundcube/rcube_config.php
@@ -302,6 +302,8 @@ class rcube_config
             if ($fpath && is_file($fpath) && is_readable($fpath)) {
                 // use output buffering, we don't need any output here
                 ob_start();
+                global $config;
+                $config = $this->prop;
                 require $fpath;
                 ob_end_clean();

Thanks for considering this issue @alecpl . Despite of the workaround, I would prefer a cleaner solution, like the one that you suggested. So, I'd appreciate if this gets implemented. Until then, I'll use the workaround.