]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - plugins.php
Logs: show search pane (on desktop)
[irc/unrealircd/unrealircd-webpanel.git] / plugins.php
index 969479ec953e8b4238a8b4ef57e6715e42f38da3..2f433cb57e98a25c952988001061ae03cc335139 100644 (file)
@@ -1,9 +1,5 @@
 <?php
-
-require_once "config.php";
-
-require_once "common.php";
-
+require_once "inc/common.php";
 require_once "Classes/class-message.php";
 
 
@@ -46,6 +42,15 @@ class Plugins
                        self::$list[] = $plugin;
                }
        }
+       static function plugin_exists($name, $version = NULL)
+       {
+               foreach(self::$list as $p)
+                       if (!strcasecmp($p->name,$name) && (!$version || ($version >= $p->version)))
+                               return true;
+
+               return false;
+       }
+
 }
 
 class Plugin
@@ -55,6 +60,7 @@ class Plugin
        public $version;
        public $description;
        public $handle;
+       public $email;
 
        public $error = NULL;
        function __construct($handle)
@@ -84,6 +90,8 @@ class Plugin
                                        $this->error = "Plugin version not defined";
                                elseif (!isset($plugin->description))
                                        $this->error = "Plugin description not defined";
+                               elseif (!isset($plugin->email))
+                                       $this->error = "Plugin email not defined";
                                else
                                {
                                        $this->handle = $handle;
@@ -91,14 +99,33 @@ class Plugin
                                        $this->author = $plugin->author;
                                        $this->version = $plugin->version;
                                        $this->description = $plugin->description;
+                                       $this->email = $plugin->email;
                                }
                        }
                }
        }
 }
 
-if (defined('PLUGINS'))
+if (get_config("plugins"))
 {
-       foreach(PLUGINS as $plugin)
+       foreach(get_config("plugins") as $plugin)
                Plugins::load($plugin);
-}
\ No newline at end of file
+}
+
+/* Requires the plugin */
+function require_plugin($name, $version)
+{
+       if (!Plugins::plugin_exists($name,$version))
+               die("Missing plugin: $name v$version");
+}
+
+/* I'm not a fan of globals */
+class AuthModLoaded
+{
+       public static $status = 0;
+}
+
+function is_auth_provided()
+{
+       return AuthModLoaded::$status;
+}