6 * Copyright (c) 1999-2003 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 require_once(SM_PATH
. 'functions/global.php');
18 global $squirrelmail_plugin_hooks;
19 $squirrelmail_plugin_hooks = array();
21 /* This function adds a plugin. */
22 function use_plugin ($name) {
23 if (file_exists(SM_PATH
. "plugins/$name/setup.php")) {
24 include_once(SM_PATH
. "plugins/$name/setup.php");
25 $function = "squirrelmail_plugin_init_$name";
26 if (function_exists($function)) {
32 /* This function executes a hook. */
33 function do_hook ($name) {
34 global $squirrelmail_plugin_hooks;
35 $data = func_get_args();
38 if (isset($squirrelmail_plugin_hooks[$name])
39 && is_array($squirrelmail_plugin_hooks[$name])) {
40 foreach ($squirrelmail_plugin_hooks[$name] as $function) {
41 /* Add something to set correct gettext domain for plugin. */
42 if (function_exists($function)) {
48 /* Variable-length argument lists have a slight problem when */
49 /* passing values by reference. Pity. This is a workaround. */
53 /* This function executes a hook. */
54 function do_hook_function($name,$parm=NULL) {
55 global $squirrelmail_plugin_hooks;
58 if (isset($squirrelmail_plugin_hooks[$name])
59 && is_array($squirrelmail_plugin_hooks[$name])) {
60 foreach ($squirrelmail_plugin_hooks[$name] as $function) {
61 /* Add something to set correct gettext domain for plugin. */
62 if (function_exists($function)) {
63 $ret = $function($parm);
68 /* Variable-length argument lists have a slight problem when */
69 /* passing values by reference. Pity. This is a workaround. */
73 /* This function executes a hook. */
74 function concat_hook_function($name,$parm=NULL) {
75 global $squirrelmail_plugin_hooks;
78 if (isset($squirrelmail_plugin_hooks[$name])
79 && is_array($squirrelmail_plugin_hooks[$name])) {
80 foreach ($squirrelmail_plugin_hooks[$name] as $function) {
81 /* Concatenate results from hook. */
82 if (function_exists($function)) {
83 $ret .= $function($parm);
88 /* Variable-length argument lists have a slight problem when */
89 /* passing values by reference. Pity. This is a workaround. */
94 * This function checks whether the user's USER_AGENT is known to
95 * be broken. If so, returns true and the plugin is invisible to the
100 $soup_menu = array('Mozilla/3','Mozilla/2','Mozilla/1', 'Opera 4',
101 'Opera/4', 'OmniWeb', 'Lynx');
102 sqgetGlobalVar('HTTP_USER_AGENT', $user_agent, SQ_SERVER
);
103 foreach($soup_menu as $browser) {
104 if(stristr($user_agent, $browser)) {
110 /*************************************/
111 /*** MAIN PLUGIN LOADING CODE HERE ***/
112 /*************************************/
114 /* On startup, register all plugins configured for use. */
115 if (isset($plugins) && is_array($plugins)) {
116 foreach ($plugins as $name) {