6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * This file provides the framework for a plugin architecture.
11 * Documentation on how to write plugins might show up some time.
16 global $squirrelmail_plugin_hooks;
17 $squirrelmail_plugin_hooks = array();
19 /* This function adds a plugin. */
20 function use_plugin ($name) {
21 if (file_exists("../plugins/$name/setup.php")) {
22 include_once("../plugins/$name/setup.php");
23 $function = "squirrelmail_plugin_init_$name";
24 if (function_exists($function)) {
30 /* This function executes a hook. */
31 function do_hook ($name) {
32 global $squirrelmail_plugin_hooks;
33 $data = func_get_args();
36 if (isset($squirrelmail_plugin_hooks[$name])
37 && is_array($squirrelmail_plugin_hooks[$name])) {
38 foreach ($squirrelmail_plugin_hooks[$name] as $function) {
39 /* Add something to set correct gettext domain for plugin. */
40 if (function_exists($function)) {
46 /* Variable-length argument lists have a slight problem when */
47 /* passing values by reference. Pity. This is a workaround. */
51 /* This function executes a hook. */
52 function do_hook_function($name,$parm=NULL) {
53 global $squirrelmail_plugin_hooks;
56 if (isset($squirrelmail_plugin_hooks[$name])
57 && is_array($squirrelmail_plugin_hooks[$name])) {
58 foreach ($squirrelmail_plugin_hooks[$name] as $function) {
59 /* Add something to set correct gettext domain for plugin. */
60 if (function_exists($function)) {
61 $ret = $function($parm);
66 /* Variable-length argument lists have a slight problem when */
67 /* passing values by reference. Pity. This is a workaround. */
72 /*************************************/
73 /*** MAIN PLUGIN LOADING CODE HERE ***/
74 /*************************************/
76 /* On startup, register all plugins configured for use. */
77 if (isset($plugins) && is_array($plugins)) {
78 foreach ($plugins as $name) {
84 * This function checks whether the user's USER_AGENT is known to
85 * be broken. If so, returns true and the plugin is invisible to the
90 global $HTTP_USER_AGENT, $SQSPELL_SOUP_NAZI;
92 require_once('../plugins/squirrelspell/sqspell_config.php');
94 $soup_menu = explode( ',', $SQSPELL_SOUP_NAZI );
95 return( in_array( trim( $HTTP_USER_AGENT ), $soup_menu ) );