summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/pluginenable.php5
-rw-r--r--actions/pluginsadminpanel.php2
-rw-r--r--lib/statusnet.php23
-rw-r--r--lib/util.php6
4 files changed, 28 insertions, 8 deletions
diff --git a/actions/pluginenable.php b/actions/pluginenable.php
index 2dbb3e395..826874ae5 100644
--- a/actions/pluginenable.php
+++ b/actions/pluginenable.php
@@ -104,8 +104,8 @@ class PluginEnableAction extends Action
}
$this->plugin = $this->arg('plugin');
- $defaultPlugins = common_config('plugins', 'default');
- if (!array_key_exists($this->plugin, $defaultPlugins)) {
+ $pluginList = StatusNet::getPlugins();
+ if (!array_key_exists($this->plugin, $pluginList)) {
$this->clientError(_('No such plugin.'));
return false;
}
@@ -127,6 +127,7 @@ class PluginEnableAction extends Action
{
$key = 'disable-' . $this->plugin;
Config::save('plugins', $key, $this->overrideValue());
+ Config::save('plugin-list', $this->plugin, 1);
// @fixme this is a pretty common pattern and should be refactored down
if ($this->boolean('ajax')) {
diff --git a/actions/pluginsadminpanel.php b/actions/pluginsadminpanel.php
index bc400bd51..c1f4fe253 100644
--- a/actions/pluginsadminpanel.php
+++ b/actions/pluginsadminpanel.php
@@ -95,7 +95,7 @@ class PluginsadminpanelAction extends AdminPanelAction
*/
protected function showDefaultPlugins()
{
- $plugins = array_keys(common_config('plugins', 'default'));
+ $plugins = array_keys(StatusNet::getPlugins());
natsort($plugins);
if ($plugins) {
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);
}
}
diff --git a/lib/util.php b/lib/util.php
index f187926b5..a9ed91870 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -1650,6 +1650,12 @@ function common_config($main, $sub)
array_key_exists($sub, $config[$main])) ? $config[$main][$sub] : false;
}
+function common_config_section($main)
+{
+ global $config;
+ return array_key_exists($main, $config) ? $config[$main] : false;
+}
+
function common_copy_args($from)
{
$to = array();