make hooks a lot more simple
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Thu, 23 Dec 2004 17:14:51 +0000 (17:14 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:26:48 +0000 (23:26 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-124

hooks/README [moved from hooks/core/API with 100% similarity]
hooks/banana.inc.php [moved from hooks/core/banana.inc.php with 100% similarity]
hooks/lists.inc.php [moved from hooks/core/lists.inc.php with 100% similarity]
hooks/newsletter.inc.php [moved from hooks/core/newsletter.inc.php with 100% similarity]
htdocs/inscription/step4.php
include/xorg.hook.inc.php

similarity index 100%
rename from hooks/core/API
rename to hooks/README
similarity index 100%
rename from hooks/core/lists.inc.php
rename to hooks/lists.inc.php
index 4f08d2a..8ad904a 100644 (file)
@@ -151,7 +151,7 @@ $mymail->send();
 $globals->db->query("update envoidirect set date_succes=NOW() where matricule = $matricule");
 
 require_once("xorg.hook.inc.php");
-$hook = new XOrgHook('core');
+$hook = new XOrgHook();
 $hook->subscribe($forlife, $uid, $promo, $password, true);
 
 start_connexion($uid,false);
index e3a2243..df358f4 100644 (file)
@@ -19,8 +19,6 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  **************************************************************************/
 
-require_once("PEAR.php");
-
 // {{{ class XOrgHook
 
 /**
@@ -45,19 +43,11 @@ require_once("PEAR.php");
  * @link     http://doc.polytechnique.org/XOrgModule/#hook
  * @since    Classe available since 0.9.3
  */
-class XOrgHook extends PEAR
+class XOrgHook
 {
     // {{{ properties
     
     /**
-     * holds the name of the hook we want to run.
-     *
-     * @var    string
-     m @access private
-     */
-    var $_name;
-    
-    /**
      * list of all the modules names that have implemented some reactions to our triggers
      *
      * @var    array
@@ -73,15 +63,11 @@ class XOrgHook extends PEAR
      *
      * @param string $name  the name of the hook
      */
-    function XOrgHook($name)
+    function XOrgHook()
     {
         global $globals;
-        $this->PEAR();
 
-        if (!file_exists($globals->root."/hooks/$name/API")) {
-            $this->raiseError("The hook « $name » do not exists, or is undocumented",1,PEAR_ERROR_DIE);
-        }
-        foreach (glob($globals->root."/hooks/$name/*.inc.php") as $file) {
+        foreach (glob($globals->root."/hooks/*.inc.php") as $file) {
             require_once("$file");
             $this->_mods[] = basename($file, '.inc.php');
         }
@@ -103,7 +89,7 @@ class XOrgHook extends PEAR
     function __call($function, $arguments, &$return)
     {
         if ( ($i = count($arguments) - 1) < 0) {
-            $this->raiseError("In the Hook « {$this->_name} » the function « $function » expects at least 1 argument");
+            $this->raiseError("The hook « $function » expects at least 1 argument");
         }
         foreach ($this->_mods as $mod) {
             if (!function_exists($mod.'_'.$function)) continue;