Source for file plugin.php
Documentation is available at plugin.php
* This file provides the framework for a plugin architecture.
* Documentation on how to write plugins might show up some time.
* @copyright © 1999-2006 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: plugin.php,v 1.30.2.7 2006/07/18 07:58:34 tokul Exp $
/** Everything needs global.. */
require_once(SM_PATH .
'functions/global.php');
global $squirrelmail_plugin_hooks;
$squirrelmail_plugin_hooks =
array();
* This function adds a plugin.
* @param string $name Internal plugin name (ie. delete_move_next)
include_once(SM_PATH .
"plugins/$name/setup.php");
$function =
"squirrelmail_plugin_init_$name";
* This function executes a hook.
* @param string $name Name of hook to fire
global $squirrelmail_plugin_hooks;
if (isset
($squirrelmail_plugin_hooks[$name])
&&
is_array($squirrelmail_plugin_hooks[$name])) {
foreach ($squirrelmail_plugin_hooks[$name] as $function) {
/* Add something to set correct gettext domain for plugin. */
/* Variable-length argument lists have a slight problem when */
/* passing values by reference. Pity. This is a workaround. */
* This function executes a hook and allows for parameters to be passed.
* @param string name the name of the hook
* @param mixed param the parameters to pass to the hook function
* @return mixed the return value of the hook function
global $squirrelmail_plugin_hooks;
if (isset
($squirrelmail_plugin_hooks[$name])
&&
is_array($squirrelmail_plugin_hooks[$name])) {
foreach ($squirrelmail_plugin_hooks[$name] as $function) {
/* Add something to set correct gettext domain for plugin. */
/* Variable-length argument lists have a slight problem when */
/* passing values by reference. Pity. This is a workaround. */
* This function executes a hook, concatenating the results of each
* plugin that has the hook defined.
* @param string name the name of the hook
* @param mixed parm optional hook function parameters
* @return string a concatenation of the results of each plugin function
global $squirrelmail_plugin_hooks;
if (isset
($squirrelmail_plugin_hooks[$name])
&&
is_array($squirrelmail_plugin_hooks[$name])) {
foreach ($squirrelmail_plugin_hooks[$name] as $function) {
/* Concatenate results from hook. */
$ret .=
$function($parm);
/* Variable-length argument lists have a slight problem when */
/* passing values by reference. Pity. This is a workaround. */
* This function is used for hooks which are to return true or
* false. If $priority is > 0, any one or more trues will override
* any falses. If $priority < 0, then one or more falses will
* Priority 0 means majority rules. Ties will be broken with $tie
* @param string name the hook name
* @param mixed parm the parameters for the hook function
* @return bool the result of the function
global $squirrelmail_plugin_hooks;
if (isset
($squirrelmail_plugin_hooks[$name]) &&
is_array($squirrelmail_plugin_hooks[$name])) {
/* Loop over the plugins that registered the hook */
foreach ($squirrelmail_plugin_hooks[$name] as $function) {
/* Examine the aftermath and assign the return value appropriately */
if (($priority >
0) &&
($yea)) {
} elseif (($priority <
0) &&
($nay)) {
// There's a tie, no action needed.
// If the code gets here, there was a problem - no hooks, etc.
* This function checks whether the user's USER_AGENT is known to
* be broken. If so, returns true and the plugin is invisible to the
* *** THIS IS A TEST FOR JAVASCRIPT SUPPORT ***
* FIXME: This function needs to have its name changed!
* @return bool whether this browser properly supports JavaScript
$soup_menu =
array('Mozilla/3','Mozilla/2','Mozilla/1', 'Opera 4',
'Opera/4', 'OmniWeb', 'Lynx');
foreach($soup_menu as $browser) {
if(stristr($user_agent, $browser)) {
/*************************************/
/*** MAIN PLUGIN LOADING CODE HERE ***/
/*************************************/
/* On startup, register all plugins configured for use. */
if (isset
($plugins) &&
is_array($plugins)) {
// turn on output buffering in order to prevent output of new lines
foreach ($plugins as $name) {
// if plugins output more than newlines and spacing, stop script execution.
Documentation generated on Sat, 07 Oct 2006 16:33:02 +0300 by phpDocumentor 1.3.0RC6