> Craig Andrews wrote:
>> With more (and important) functionality moving into plugins, there needs
>> to be a mechanism to have plugins enabled by default. Have you developed
>> something like that yet?
>>
> Yeah, I've been trying to work out how that would go.
>
> My best idea so far is that there would be a configuration option
> listing default plugins that will be turned on. Something like in
> common.php:
>
> $config['plugins']['default'] = array('OpenID', 'Jabber', 'SMS',
> 'Invite');
>
> Then in your config.php you could get rid of ones you don't want:
>
> unset(array_search('SMS', $config['plugins']['default']));
>
>
> Then back in common.php we'd do something like:
>
> foreach ($config['plugins']['default'] as $plugin) {
>     addPlugin($plugin);
> }
>
> It seems pretty OK, but a) it makes it tempting to /add/ plugins to that
> list b) you can't provide parameters and c) that unset() syntax is
> really squirrelly.
>
> -Evan

In laconica core:
//an array of mixed (elements can be arrays, or strings)
$config['plugins']['default']=array('OpenID',
array('Jabber',"[email protected]","password"), 'SMS','Invite');

In config.php (the user sets these):
//an array of mixed (elements can be arrays, or strings)
$config['plugins']['enabled']=array('OpenID',array('ldap','searchDN','server'));
//an array of strings
$config['plugins']['disabled']=array('SMS');

Then in core during startup:
//user plugins must be first in the list, in case they modify parameters
listed in the default plugins array
$plugins_to_enable=array_merge($config['plugins']['enabled'],$config['plugins']['default']);
foreach ($plugins_to_enable as $plugin) {
    if(is_array($plugin)){
        $plugin_name=array_shift($plugin);
        $plugin_parameters=$plugin;
    }else{
        $plugin_name=$plugin;
        $plugin_parameters=array();
    }
    addPlugin($plugin_name,$plugin_parameters);
}

addPlugin()'s first parameter remains the same. A second parameter should
be added that's an array containing the plugin parameters.

addPlugin() will also need to check to make sure that the plugin being
requested is not already active. If it is, addPlugin should no-op.

Thoughts?
~Craig

_______________________________________________
Laconica-dev mailing list
[email protected]
http://mail.laconi.ca/mailman/listinfo/laconica-dev

Reply via email to