]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - Classes/class-hook.php
really fix, thanks Mi_92
[irc/unrealircd/unrealircd-webpanel.git] / Classes / class-hook.php
index 97d06a1f957c2bff2d4a234ba7a88c231df7a62d..1f6878f91e5c3ad2cfe1d13681e9d7e68b41cfa7 100644 (file)
@@ -1,6 +1,163 @@
 <?php
 
-define('HOOKTYPE_NAVBAR', 100); /* The Hook for the navigation bar */
+/* Hook Definitions
+* 
+* Hooks let you do things in your plugin, like add nav items for your
+* own pages, add extra cards to the overview and more (to come)
+*/
+/** HOOKTYPE_NAVBAR
+ * 
+ * @param array $pages
+ * Receives an array of pages. For example:
+ * $pages = ["Overview" => ""];
+ * 
+ * So when you call this hook, you must refer to the
+ * parameter by reference. For example:
+ * Hook::func(HOOKTYPE_NAVBAR, 'add_navbar_item');
+ * 
+ * function add_navbar_item(&$pages) // remember the & to use by reference
+ * { insert_hacks_here(); }
+ */
+define('HOOKTYPE_NAVBAR', 100); 
+
+/** HOOKTYPE_PRE_HEADER
+ * 
+ * This doesn't receive anything, however you must still specify an
+ * parameter for your hook function, because it's referring to memory. Sorry =]
+ * 
+ * Putting HTML in this hook is not a good idea.
+ */
+define('HOOKTYPE_PRE_HEADER', 101);
+
+/** HOOKTYPE_HEADER
+ * 
+ * This is run after/during the header is sent. You can call your global scripts, global css or whatnot from here.
+ */
+define('HOOKTYPE_HEADER', 119);
+
+/** HOOKTYPE_PRE_OVERVIEW_CARD
+ * 
+ * @param object $stats
+ * 
+ * This is called before the initial cards have loaded in the overview.
+ * This lets you add your own HTML or whatever you like on the overview,
+ * new cards, whatever.
+ * 
+ * The parameter is an object containing stats used in the overview.
+ * See "index.php" to see how it's used.
+ * 
+ */
+define('HOOKTYPE_PRE_OVERVIEW_CARD', 102);
+
+/** HOOKTYPE_OVERVIEW_CARD
+ * 
+ * @param object $stats
+ * 
+ * This is called after the initial cards have loaded in the overview.
+ * This lets you add your own HTML or whatever you like on the overview,
+ * new cards, whatever.
+ * 
+ * The parameter is an object containing stats used in the overview.
+ * See "index.php" to see how it's used.
+ * 
+*/
+define('HOOKTYPE_OVERVIEW_CARD', 103);
+
+/** HOOKTYPE_NOTIFICATION
+ * 
+ * @param array $notification
+ * The array should contain:
+ *
+ * "name" - The name of the recipient
+ * "message" - The notification message
+ *
+ * This does not do anything special by itself. It simply allows plugins
+ * to be able to use it with regards to notification sending.
+ * This is not run at any place, but should be run from your plugin.
+ *
+ * This hook is simple in design and only contains two elements in attempt
+ * to make it work cross-plugin. That is, if you have implemented your own
+ * notificiation system, you will be able to do whatever you like such as
+ * display a navbar list of notifications or send important emails by running
+ * this hook.
+ * 
+*/
+define('HOOKTYPE_NOTIFICATION', 104);
+
+
+/** HOOKTYPE_PRE_FOOTER
+ * @param array $empty - Doesn't do anything
+ * 
+ * This runs inside the footer body before anything else.
+ */
+define('HOOKTYPE_PRE_FOOTER', 105);
+
+/** HOOKTYPE_FOOTER
+ * @param array $empty - Doesn't do anything
+ * 
+ * This runs inside the footer body after everything else.
+ */
+define('HOOKTYPE_FOOTER', 106);
+
+/** HOOKTYPE_USER_LOOKUP
+ * @param array $user [name, id]
+ */
+define('HOOKTYPE_USER_LOOKUP', 107);
+
+/** HOOKTYPE_USERMETA_ADD
+ * @param array $meta [[id, key, value], (object)PanelUser]
+ */
+define('HOOKTYPE_USERMETA_ADD', 108);
+
+/** HOOKTYPE_USERMETA_ADD
+ * @param array $meta [id, key, value]
+ */
+define('HOOKTYPE_USERMETA_DEL', 109);
+
+/** HOOKTYPE_USERMETA_ADD
+ * @param array $meta [id, key, value]
+ */
+define('HOOKTYPE_USERMETA_GET', 110);
+
+/** HOOKTYPE_USER_CREATE
+ * @param array $userinfo []
+ */
+define('HOOKTYPE_USER_CREATE', 111);
+
+/** HOOKTYPE_GET_USER_LIST
+ * @param array $userlist []
+ */
+define('HOOKTYPE_GET_USER_LIST', 112);
+
+define('HOOKTYPE_USER_DELETE', 113);
+
+define('HOOKTYPE_USER_LOGIN', 114);
+
+define('HOOKTYPE_USER_LOGIN_FAIL', 115);
+
+define('HOOKTYPE_USER_PERMISSION_LIST', 116);
+
+define('HOOKTYPE_EDIT_USER', 117);
+
+define('HOOKTYPE_RIGHTCLICK_MENU', 118);
+
+/* 119 = HOOKTYPE_HEADER (See under HOOKTYPE_PRE_HEADER) */
+
+define('HOOKTYPE_GENERAL_SETTINGS', 120);
+
+/* Array passed is $_POST[] */
+define('HOOKTYPE_GENERAL_SETTINGS_POST', 121);
+
+
+
+/** Send out a request to ask if there are any plugins which provide authentication */
+define('HOOKTYPE_AUTH_MOD', 200);
+
+/** An upgrade has been detected.
+ * @param array        $versioninfo[]
+ * Array contains: "old_version" and "new_version"
+ */
+define('HOOKTYPE_UPGRADE', 201);
 
 /** 
  *  Class for "Hook"
@@ -39,10 +196,10 @@ class Hook {
         */
        public static function run($Hook, &$args = array())
        {
-        if (!empty(self::$actions[$Hook]))
-            foreach (self::$actions[$Hook] as &$f)
-                $f($args);
-            
+               if (!empty(self::$actions[$Hook]))
+                       foreach (self::$actions[$Hook] as &$f)
+                               $f($args);
+                       
        }
 
        /** Calls a Hook
@@ -51,7 +208,7 @@ class Hook {
         * @return void Does not return anything.
         */
        public static function func($Hook, $function)
-    {
+       {
                self::$actions[$Hook][] = $function;
        }
 
@@ -60,11 +217,10 @@ class Hook {
         * @param string $function The name of the function that we are removing.
         * @return void Does not reuturn anything.
         */
-
        public static function del($Hook, $function)
-    {
+       {
                for ($i = 0; isset(self::$actions[$Hook][$i]); $i++)
-                   if (self::$actions[$Hook][$i] == $function)
-                       array_splice(self::$actions[$Hook],$i);
+                       if (self::$actions[$Hook][$i] == $function)
+                               array_splice(self::$actions[$Hook],$i);
        }
 }