diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2010-11-20 22:02:31 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2010-11-20 22:02:31 -0500 |
commit | 3a336843e1cdd340dd3630747b3e6265b6effa39 (patch) | |
tree | 77643c2438808bae2ac5f6f6742f548108044c5c /lib/statusnet.php | |
parent | 0d4588e4b62ecd3ec22d2928dce5e036e3322b77 (diff) |
Add more robust (but backward-compatible) plugin config system.
util.php: add common_config_section($main), as a companion to common_config($main,sub)
statusnet.php:
* add public static getPlugins(), which returns array_merge(common_config('plugins','default'),common_config_section('plugin-list'))
* use self::getPlugins(), instead of common_config('plugins,'default')
* handle plugins that have a type other than "array" or "null" for parameters
pluginenable:
* use StatusNet::getPlugins() instead of common_config('plugins,'default')
* set $config['plugin-list'][$plugin_name] = 1
pluginsadminpanel: use StatusNet::getPlugins() instead of common_config('plugins,'default')
Diffstat (limited to 'lib/statusnet.php')
-rw-r--r-- | lib/statusnet.php | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/statusnet.php b/lib/statusnet.php index ff0502915..f8bf87960 100644 --- a/lib/statusnet.php +++ b/lib/statusnet.php @@ -169,22 +169,33 @@ class StatusNet return $sites; } + /** + * Return a list of plugins + */ + public static function getPlugins() { + // Default plugins + $pluginlist = common_config('plugins', 'default'); + // Enabled plugins + $enabled=common_config_section('plugin-list'); + if ($enabled) { + $pluginlist = array_merge($pluginlist,$enabled); + } + return $pluginlist; + } /** * Fire initialization events for all instantiated plugins. */ protected static function initPlugins() { - // Load default plugins - foreach (common_config('plugins', 'default') as $name => $params) { + // Load plugins + foreach (self::getPlugins() as $name => $params) { $key = 'disable-' . $name; if (common_config('plugins', $key)) { continue; } - if (is_null($params)) { - addPlugin($name); - } else if (is_array($params)) { + if (is_array($params)) { if (count($params) == 0) { addPlugin($name); } else { @@ -197,6 +208,8 @@ class StatusNet } } } + } else { + addPlugin($name); } } |