Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow extending config in custom host config file #9458

Open
CodeShakingSheep opened this issue May 20, 2024 · 4 comments
Open

Allow extending config in custom host config file #9458

CodeShakingSheep opened this issue May 20, 2024 · 4 comments

Comments

@CodeShakingSheep
Copy link

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
Copy link
Contributor

johndoh commented May 21, 2024

Its possible to to do this with the following line:

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

@alecpl
Copy link
Member

alecpl commented May 21, 2024

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();

@alecpl alecpl added this to the later milestone May 21, 2024
@alecpl alecpl changed the title Plugins in custom host config file override plugins in config.inc.php Allow extending config in custom host config file May 21, 2024
@CodeShakingSheep
Copy link
Author

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants