summaryrefslogtreecommitdiff
path: root/src/lib/PluginManager.class.php
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2012-01-07 08:21:00 -0800
committerLuke Shumaker <LukeShu@sbcglobal.net>2012-01-07 10:22:21 -0800
commit83e460cdc3fc09867a3adb48c3d0894579dd3050 (patch)
tree0771bd935b30971bf2c244b6f158ed7496b644e5 /src/lib/PluginManager.class.php
parent3d64793a1ee45857856be1cd71c3a0a040a3e869 (diff)
Refactor to separate the framework from the app; drop message stuff, this app is just user management. Add a json view for individual users
Diffstat (limited to 'src/lib/PluginManager.class.php')
-rw-r--r--src/lib/PluginManager.class.php99
1 files changed, 0 insertions, 99 deletions
diff --git a/src/lib/PluginManager.class.php b/src/lib/PluginManager.class.php
deleted file mode 100644
index ce5a3ef..0000000
--- a/src/lib/PluginManager.class.php
+++ /dev/null
@@ -1,99 +0,0 @@
-<?php
-require_once('Singleton.class.php');
-require_once('Database.class.php');
-
-class PluginManager extends Singleton {
- public $plugins = array();
- private $loaded = false;
-
- /**
- * Return an instance of the plugin with $plugin_name
- */
- public function loadPlugin($plugin_name) {
- $db = Database::getInstance();
-
- require_once("$plugin_name.class.php");
- $obj = new $plugin_name;
- $params = call_user_func("$plugin_name::configList");
- foreach ($params as $param => $type) {
- $value = $db->getPluginConf($plugin_name, $param);
- if ($value!==false) {
- switch ($type) {
- case 'text':
- case 'password':
- $value = "$value";
- break;
- case 'int':
- $value = (int)$value;
- break;
- }
- $obj->configSet($param, $value);
- }
- }
- return $obj;
- }
-
- /**
- * Return an array of available plugin names.
- */
- public function listPlugins() {
- $plugins = array();
-
- $dirs = explode(PATH_SEPARATOR, PLUGINPATH);
- foreach ($dirs as $dir) {
- // Find all files in $dir with the ext `.class.php'
- $files = glob($dir.'/*.class.php');
- foreach ($files as $file) {
- $plugins[] = preg_replace('@\.class\.php$@', '$1', basename($file));
- }
- }
-
- return $plugins;
- }
-
- /**
- * Return an array of enabled plugin names.
- */
- public function getActivePlugins() {
- $db = Database::getInstance();
- $string = $db->getSysConf('plugins');
- return $db->valueToArray($string);
- }
-
- /**
- * Set the enabled plugins.
- */
- public function setActivePlugins($plugins) {
- $db = Database::getInstance();
- $string = $db->arrayToValue($plugins);
- return $db->setSysConf('plugins', $string);
- }
-
- /**
- * Load the enabled plugins.
- */
- public function loadPlugins() {
- if ($this->loaded) return;
- $plugin_names = $this->getActivePlugins();
- foreach ($plugin_names as $name) {
- $this->plugins[$name] = $this->loadPlugin($name);
- }
- $this->loaded = true;
- }
-
- public function callHook($hook, $arg=null) {
- $this->loadPlugins();
- $ret = array();
- foreach ($this->plugins as $name => $plugin) {
- $ret[$name] = call_user_func(array($plugin, $hook),
- &$arg);
- }
- return $ret;
- }
-
- public function staticHook($plugin_name, $hook) {
- require_once("$plugin_name.class.php");
- return call_user_func("$plugin_name::$hook");
- }
-
-}