Florian Lagg wrote:
So here are my questions:
- How should a plugin-architecture be implemented in RoundCube?
Maybe my approach is completely wrong, just tell me if you think so... I'm thinking of a PluginHooks singleton class which is called from various points in the existing source code. This class reads a config file if there is a plugin registered for the specific event. This config contains a line for each event like this: $rcmail_config['pluginevent_userlogin'] = array('Funambol'); //registers a single plugin called "funambol" for the event "userlogin" $rcmail_config['pluginevent_nextEvent'] = array('Funambol', 'AnotherPlugin); //call two plugins in the given order PluginHooks then initates a class Funambol (located in RC_Home/plugins/Funambol) and calls a method pluginevent_userlogin. Because PluginHooks is a singleton, it could provide methods to the plugins to get or manipulate data from the rest of RC. so anything is handled over this class. I hope I discribed it well. Please bring your own ideas if you have better once.
Hi Florian, first of all thanks for the offer to do a lot of work for the community!
Regarding the config as you outline it above - I don't think this is the way to go as it is not very flexible; ideally a plugin just requires to be downloaded to a certain directory and to be enabled in a single place, that's it. In the above code every time a plugin is added the config has to be changed to adopt the hooks.
Instead I would recommend a well-known location (index.php, config.php) in the plugins directory which calls those hook-registration points itself. This gives full control over to the plugin with minimal impact on configuration.
My 2 cents,
Mike