4b86b769824c00d8d8f76abce5745e87025edab4
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.
20 $plugin_general_debug = false;
22 // This function adds a plugin
23 function use_plugin ($name) {
24 global $plugin_general_debug;
26 if (file_exists('../plugins/'.$name.'/setup.php')) {
27 if ($plugin_general_debug)
28 echo "plugin: -- Loading $name/setup.php<br>\n";
29 include ('../plugins/'.$name.'/setup.php');
30 $function = 'squirrelmail_plugin_init_'.$name;
31 if (function_exists($function))
33 if ($plugin_general_debug)
34 echo "plugin: ---- Executing $function to init plugin<br>\n";
37 elseif ($plugin_general_debug)
38 echo "plugin: -- Init function $function doesn't exist.<br>\n";
40 elseif ($plugin_general_debug)
41 echo "plugin: Couldn't find $name/setup.php<br>\n";
44 // This function executes a hook
45 function do_hook ($name) {
46 global $squirrelmail_plugin_hooks;
47 $Data = func_get_args();
48 if (isset($squirrelmail_plugin_hooks[$name]) &&
49 is_array($squirrelmail_plugin_hooks[$name])) {
50 foreach ($squirrelmail_plugin_hooks[$name] as $id => $function) {
51 // Add something to set correct gettext domain for plugin
52 if (function_exists($function)) {
58 // Variable-length argument lists have a slight problem when
59 // passing values by reference. Pity. This is a workaround.
63 // On startup, register all plugins configured for use
64 if (isset($plugins) && is_array($plugins))
65 foreach ($plugins as $id => $name)
67 if ($plugin_general_debug)
68 echo "plugin: Attempting load of plugin $name<br>\n";