From 6fae508097c6da936dcce0189dfe5779de149153 Mon Sep 17 00:00:00 2001 From: "Pierre Habouzit (MadCoder" Date: Thu, 23 Dec 2004 17:14:51 +0000 Subject: [PATCH] make hooks a lot more simple git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-124 --- hooks/{core/API => README} | 0 hooks/{core => }/banana.inc.php | 0 hooks/{core => }/lists.inc.php | 0 hooks/{core => }/newsletter.inc.php | 0 htdocs/inscription/step4.php | 2 +- include/xorg.hook.inc.php | 22 ++++------------------ 6 files changed, 5 insertions(+), 19 deletions(-) rename hooks/{core/API => README} (100%) rename hooks/{core => }/banana.inc.php (100%) rename hooks/{core => }/lists.inc.php (100%) rename hooks/{core => }/newsletter.inc.php (100%) diff --git a/hooks/core/API b/hooks/README similarity index 100% rename from hooks/core/API rename to hooks/README diff --git a/hooks/core/banana.inc.php b/hooks/banana.inc.php similarity index 100% rename from hooks/core/banana.inc.php rename to hooks/banana.inc.php diff --git a/hooks/core/lists.inc.php b/hooks/lists.inc.php similarity index 100% rename from hooks/core/lists.inc.php rename to hooks/lists.inc.php diff --git a/hooks/core/newsletter.inc.php b/hooks/newsletter.inc.php similarity index 100% rename from hooks/core/newsletter.inc.php rename to hooks/newsletter.inc.php diff --git a/htdocs/inscription/step4.php b/htdocs/inscription/step4.php index 4f08d2a..8ad904a 100644 --- a/htdocs/inscription/step4.php +++ b/htdocs/inscription/step4.php @@ -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); diff --git a/include/xorg.hook.inc.php b/include/xorg.hook.inc.php index e3a2243..df358f4 100644 --- a/include/xorg.hook.inc.php +++ b/include/xorg.hook.inc.php @@ -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; -- 2.1.4