summaryrefslogtreecommitdiff
path: root/lib/common.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-07-10 10:06:20 -0700
committerEvan Prodromou <evan@controlyourself.ca>2009-07-10 10:06:20 -0700
commit6a0f0e32d5e837c3f0f2041bc206fc35d69f497c (patch)
treee9ce262b15006927ffc46c71a89ecb1a3ebfadbd /lib/common.php
parent03ccb74052ccec209adedfcd9daf4648905b322b (diff)
parentbafa1ab1c532118e2230df50ed18a1b4573692b7 (diff)
Merge branch '0.8.x' into 0.9.x
Diffstat (limited to 'lib/common.php')
-rw-r--r--lib/common.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/common.php b/lib/common.php
index d3f7f1b2b..764c5a077 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -282,6 +282,39 @@ if (function_exists('date_default_timezone_set')) {
date_default_timezone_set('UTC');
}
+function addPlugin($name, $attrs = null)
+{
+ $name = ucfirst($name);
+ $pluginclass = "{$name}Plugin";
+
+ 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");
+
+ foreach ($files as $file) {
+ $fullpath = INSTALLDIR.'/'.$file;
+ if (@file_exists($fullpath)) {
+ include_once($fullpath);
+ break;
+ }
+ }
+ }
+
+ $inst = new $pluginclass();
+
+ if (!empty($attrs)) {
+ foreach ($attrs as $aname => $avalue) {
+ $inst->$aname = $avalue;
+ }
+ }
+ return $inst;
+}
+
// From most general to most specific:
// server-wide, then vhost-wide, then for a path,
// finally for a dir (usually only need one of the last two).