2 /***************************************************************************
3 * Copyright (C) 2003-2006 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 **************************************************************************/
27 * Hooks are used in modules to allow modules that depends upon us to hook
28 * themselves in our core functionnalities.
30 * Every module will use some hools, and define their names.
31 * Pretend « myhook » is one of those names, then :
32 * - hooks/myhook/API has to exists, and will explain the API of the hook
33 * - every module "mod" may have a file hooks/myhook/mod.inc.php that implements
34 * fully or partially the API of the hook.
36 * If the hook's API has to change, the functions that change MUST change their
37 * name to avoid any compatibility problem.
41 * @author Pierre Habouzit <pierre.habouzit@polytechnique.org>
43 * @link http://doc.polytechnique.org/XOrgModule/#hook
44 * @since Classe available since 0.9.3
51 * list of all the modules names that have implemented some reactions to our triggers
59 // {{{ constructor XOrgHook()
62 * Instanciates our Hook.
64 * @param string $name the name of the hook
70 foreach (glob($globals->root
."/hooks/*.inc.php") as $file) {
71 require_once("$file");
72 $this->_mods
[] = basename($file, '.inc.php');
77 // {{{ function config
81 foreach ($this->_mods
as $mod) {
82 if (!function_exists($mod.'_config')) continue;
83 call_user_func($mod.'_config');
92 foreach ($this->_mods
as $mod) {
93 if (!function_exists($mod.'_menu')) continue;
94 call_user_func($mod.'_menu');
99 // {{{ function subscribe
101 function subscribe($forlife, $uid, $promo, $pass)
103 foreach ($this->_mods
as $mod) {
104 if (!function_exists($mod.'_subscribe')) continue;
105 call_user_func($mod.'_subscribe', $forlife, $uid, $promo, $pass);
110 // {{{ function prefs
115 foreach ($this->_mods
as $mod) {
116 if (!function_exists($mod.'_prefs')) continue;
117 $res = array_merge($res, call_user_func($mod.'_prefs'));
119 usort($res, create_function('$a, $b', 'return strcmp($a["weight"], $b["weight"]);'));
128 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: