summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/statusnet.php53
-rw-r--r--lib/util.php6
2 files changed, 48 insertions, 11 deletions
diff --git a/lib/statusnet.php b/lib/statusnet.php
index 4c2aacd8f..099894455 100644
--- a/lib/statusnet.php
+++ b/lib/statusnet.php
@@ -34,6 +34,25 @@ class StatusNet
protected static $plugins = array();
/**
+ * Return a list of possible filenames that plugin $name can be in.
+ *
+ * @param string $name class name & plugin file/subdir name
+ */
+ public static function pluginFiles($name) {
+ $name = ucfirst($name);
+ $pluginclass = "{$name}Plugin";
+
+ $files = array("local/plugins/{$pluginclass}.php",
+ "local/plugins/{$name}/{$pluginclass}.php",
+ "local/{$pluginclass}.php",
+ "local/{$name}/{$pluginclass}.php",
+ "plugins/{$pluginclass}.php",
+ "plugins/{$name}/{$pluginclass}.php");
+
+ return $files;
+ }
+
+ /**
* Configure and instantiate a plugin into the current configuration.
* Class definitions will be loaded from standard paths if necessary.
* Note that initialization events won't be fired until later.
@@ -50,12 +69,7 @@ class StatusNet
if (!class_exists($pluginclass)) {
- $files = array("local/plugins/{$pluginclass}.php",
- "local/plugins/{$name}/{$pluginclass}.php",
- "local/{$pluginclass}.php",
- "local/{$name}/{$pluginclass}.php",
- "plugins/{$pluginclass}.php",
- "plugins/{$name}/{$pluginclass}.php");
+ $files = self::pluginFiles($name);
foreach ($files as $file) {
$fullpath = INSTALLDIR.'/'.$file;
@@ -168,22 +182,37 @@ class StatusNet
}
return $sites;
}
+ /**
+ * Return a list of plugins that are currently in the system.
+ *
+ * This means default plugins, plugins that are explicitly enabled, or
+ * plugins that are explicitly disabled.
+ */
+
+ 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 {
@@ -196,6 +225,8 @@ class StatusNet
}
}
}
+ } else {
+ addPlugin($name);
}
}
diff --git a/lib/util.php b/lib/util.php
index 3d4adcf4b..379516529 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -1857,6 +1857,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;
+}
+
/**
* Pull arguments from a GET/POST/REQUEST array with first-level input checks:
* strips "magic quotes" slashes if necessary, and kills invalid UTF-8 strings.