0337d704 |
1 | <?php |
2 | /*************************************************************************** |
50a40a33 |
3 | * Copyright (C) 2003-2006 Polytechnique.org * |
0337d704 |
4 | * http://opensource.polytechnique.org/ * |
5 | * * |
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. * |
10 | * * |
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. * |
15 | * * |
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 * |
18 | * Foundation, Inc., * |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
20 | **************************************************************************/ |
21 | |
0337d704 |
22 | /** |
23 | * XOrg's Hooks API |
24 | * |
25 | * Hooks are used in modules to allow modules that depends upon us to hook |
26 | * themselves in our core functionnalities. |
27 | * |
28 | * Every module will use some hools, and define their names. |
29 | * Pretend « myhook » is one of those names, then : |
30 | * - hooks/myhook/API has to exists, and will explain the API of the hook |
31 | * - every module "mod" may have a file hooks/myhook/mod.inc.php that implements |
32 | * fully or partially the API of the hook. |
33 | * |
34 | * If the hook's API has to change, the functions that change MUST change their |
35 | * name to avoid any compatibility problem. |
36 | * |
37 | * @category XOrgCore |
38 | * @package XOrgCore |
39 | * @author Pierre Habouzit <pierre.habouzit@polytechnique.org> |
40 | * @access public |
41 | * @link http://doc.polytechnique.org/XOrgModule/#hook |
42 | * @since Classe available since 0.9.3 |
43 | */ |
44 | class XOrgHook |
45 | { |
46 | // {{{ properties |
62a66dfc |
47 | |
0337d704 |
48 | /** |
49 | * list of all the modules names that have implemented some reactions to our triggers |
50 | * |
51 | * @var array |
52 | * @access private |
53 | */ |
54 | var $_mods = Array(); |
62a66dfc |
55 | |
0337d704 |
56 | // }}} |
57 | // {{{ constructor XOrgHook() |
58 | |
59 | /** |
60 | * Instanciates our Hook. |
61 | * |
62 | * @param string $name the name of the hook |
63 | */ |
64 | function XOrgHook() |
65 | { |
66 | global $globals; |
67 | |
172ec147 |
68 | foreach (glob($globals->spoolroot."/hooks/*.inc.php") as $file) { |
0337d704 |
69 | require_once("$file"); |
70 | $this->_mods[] = basename($file, '.inc.php'); |
71 | } |
72 | } |
73 | |
74 | // }}} |
0337d704 |
75 | // {{{ function subscribe |
76 | |
77 | function subscribe($forlife, $uid, $promo, $pass) |
78 | { |
79 | foreach ($this->_mods as $mod) { |
80 | if (!function_exists($mod.'_subscribe')) continue; |
81 | call_user_func($mod.'_subscribe', $forlife, $uid, $promo, $pass); |
82 | } |
83 | } |
84 | |
85 | // }}} |
0337d704 |
86 | } |
87 | |
0337d704 |
88 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: |
89 | ?> |