cb845ea943044c7c17daf3fa9595c7e395cd2baf
[squirrelmail.git] / functions / plugin.php
1 <?php
2
3 /**
4 ** plugin.php
5 **
6 ** This file provides the framework for a plugin architecture.
7 **
8 ** Plugins will eventually be a way to provide added functionality
9 ** without having to patch the SquirrelMail source code. Have some
10 ** patience, though, as the these funtions might change in the near
11 ** future.
12 **
13 ** Documentation on how to write plugins might show up some time.
14 **
15 **/
16
17
18 $plugin_php = true;
19
20 // This function adds a plugin
21 function use_plugin ($name) {
22 if (file_exists('../plugins/'.$name.'/setup.php')) {
23 include ('../plugins/'.$name.'/setup.php');
24 $function = 'squirrelmail_plugin_init_'.$name;
25 $function();
26 }
27 }
28
29 // This function executes a hook
30 function do_hook ($name) {
31 global $squirrelmail_plugin_hooks;
32 if (is_array($squirrelmail_plugin_hooks[$name])) {
33 reset($squirrelmail_plugin_hooks[$name]);
34
35 while (list ($id, $function) =
36 each ($squirrelmail_plugin_hooks[$name])) {
37 // Add something to set correct gettext domain for plugin
38 $function();
39 }
40 }
41 }
42
43 // On startup, register all plugins configured for use
44 if (is_array($plugins))
45 while (list ($id, $name) = each ($plugins))
46 use_plugin($name);
47
48 ?>