work on hooks
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Thu, 23 Dec 2004 17:55:04 +0000 (17:55 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:26:48 +0000 (23:26 +0200)
 * make globals->hook be an instance of XOrgHook
 * make the menu be constructed by hooks:
   - banan is a proof of concept

git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-125

hooks/README
hooks/banana.inc.php
htdocs/inscription/step4.php
include/conf.d/banana.menu.inc.php [deleted file]
include/xorg.globals.inc.php.in
include/xorg/hook.inc.php [moved from include/xorg.hook.inc.php with 100% similarity]

index 2d872d7..10f933b 100644 (file)
@@ -1 +1,2 @@
+function menu()
 function subscribe($forlife, $uid, $promo, $pass)
index 64b62eb..e17c55a 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-// {{{ function banana_subscirbe()
+// {{{ menu HOOK
+
+function &banana_menu(&$result)
+{
+    global $globals;
+    $globals->menu->addPrivateEntry(XOM_SERVICES, 10, 'Forums & PA', 'banana/');
+}
+
+// }}}
+// {{{ subscribe HOOK
 
 function &banana_subscribe($forlife, $uid, $promo, $password, &$result)
 {
index 8ad904a..33ff384 100644 (file)
@@ -149,10 +149,7 @@ $mymail->send();
 
 // s'il est dans la table envoidirect, on le marque comme inscrit
 $globals->db->query("update envoidirect set date_succes=NOW() where matricule = $matricule");
-
-require_once("xorg.hook.inc.php");
-$hook = new XOrgHook();
-$hook->subscribe($forlife, $uid, $promo, $password, true);
+$globals->hook->subscribe($forlife, $uid, $promo, $password, true);
 
 start_connexion($uid,false);
 $page->run();
diff --git a/include/conf.d/banana.menu.inc.php b/include/conf.d/banana.menu.inc.php
deleted file mode 100644 (file)
index 58615ab..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<?php
-$this->addPrivateEntry(XOM_SERVICES, 10, 'Forums & PA',           'banana/');
-?>
index d7d643a..31f2857 100644 (file)
@@ -29,6 +29,7 @@ class XorgGlobals extends DiogenesCoreGlobals
     var $page    = 'XorgPage';
     var $session = 'XorgSession';
     var $menu;
+    var $hook;
 
     /** The x.org version */
     var $version = "@VERSION@";
@@ -57,6 +58,7 @@ class XorgGlobals extends DiogenesCoreGlobals
     function init()
     {
         global $globals;
+        require_once("xorg/hook.inc.php");
         require_once("xorg/menu.inc.php");
 
         $globals = new XorgGlobals;
@@ -83,7 +85,9 @@ class XorgGlobals extends DiogenesCoreGlobals
             }
         }
         
+        $globals->hook = new XOrgHook();
         $globals->menu = new XOrgMenu($globals->root.'/include/conf.d/');
+        $globals->hook->menu(null);
 
         $globals->dbconnect();
         if ($globals->debug) {