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-2020 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: plugin.php 14840 2020-01-07 07:42:38Z pdontthink $
/** 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
$return_value_variable_name =
'hook_return_value_' .
$name;
global $squirrelmail_plugin_hooks, $
$return_value_variable_name;
$
$return_value_variable_name =
NULL;
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. */
$
$return_value_variable_name =
$function($parm, $
$return_value_variable_name);
/* Variable-length argument lists have a slight problem when */
/* passing values by reference. Pity. This is a workaround. */
return $
$return_value_variable_name;
* 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
$return_value_variable_name =
'hook_return_value_' .
$name;
global $squirrelmail_plugin_hooks, $
$return_value_variable_name;
$
$return_value_variable_name =
'';
if (isset
($squirrelmail_plugin_hooks[$name])
&&
is_array($squirrelmail_plugin_hooks[$name])) {
foreach ($squirrelmail_plugin_hooks[$name] as $function) {
/* Concatenate results from hook. */
$
$return_value_variable_name .=
$function($parm, $
$return_value_variable_name);
/* Variable-length argument lists have a slight problem when */
/* passing values by reference. Pity. This is a workaround. */
return $
$return_value_variable_name;
* 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!
* FIXME: The test in this function is outdated - plenty more browsers support JavaScript, newer browser versions (Mozilla at least) exist, and moreover, we shouldn't be doing user-agent testing - should be trusting our $javascript_on global -- REMOVE THIS FUNCTION IF NOT BEING USED ANYWHERE ELSE
* @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.
$plugins needs to be globalized because this file is
sometimes included inside function (non-global) scope,
such as for logout_error. */
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 Mon, 13 Jan 2020 04:25:10 +0100 by phpDocumentor 1.4.3