6 ** This file provides the framework for a plugin architecture.
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
13 ** Documentation on how to write plugins might show up some time.
18 global $squirrelmail_plugin_hooks;
20 $squirrelmail_plugin_hooks = array();
22 // This function adds a plugin
23 function use_plugin ($name) {
25 if (file_exists('../plugins/'.$name.'/setup.php')) {
26 include_once('../plugins/'.$name.'/setup.php');
27 $function = 'squirrelmail_plugin_init_'.$name;
28 if (function_exists($function)) {
35 // This function executes a hook
36 function do_hook ($name) {
37 global $squirrelmail_plugin_hooks;
38 $Data = func_get_args();
39 if (isset($squirrelmail_plugin_hooks[$name]) &&
40 is_array($squirrelmail_plugin_hooks[$name])) {
41 foreach ($squirrelmail_plugin_hooks[$name] as $function) {
42 // Add something to set correct gettext domain for plugin
43 if (function_exists($function)) {
49 // Variable-length argument lists have a slight problem when
50 // passing values by reference. Pity. This is a workaround.
54 /* -------------------- MAIN --------------------- */
56 // On startup, register all plugins configured for use
57 if (isset($plugins) && is_array($plugins)) {
58 foreach ($plugins as $name) {