From e900d242c297d00e54d8f8ca4a333100709b27a1 Mon Sep 17 00:00:00 2001 From: pdontthink Date: Thu, 28 Sep 2006 14:30:45 +0000 Subject: [PATCH] New hook type that I am very excited about; should address a kind of plugin stacking that we should have had long ago git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11755 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/plugin.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/functions/plugin.php b/functions/plugin.php index a891ac93..2bc6bff0 100644 --- a/functions/plugin.php +++ b/functions/plugin.php @@ -55,6 +55,39 @@ function do_hook ($name) { return $data; } +/** + * This function executes a hook and allows for parameters to be + * passed, wherein each plugin can modify the parameters before + * they are passed to the next funciton. Whether or not the + * parameters are modified, plugins on this hook should always + * return the given parameters. + * + * @param string name the name of the hook + * @param mixed param the parameters to pass to the hook function + * @return mixed the possibly modified hook parameters + */ +function filter_hook_function($name,$parm=NULL) { + global $squirrelmail_plugin_hooks, $currentHookName; + $ret = ''; + $currentHookName = $name; + + 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. */ + if (function_exists($function)) { + $parm = $function($parm); + } + } + } + + $currentHookName = ''; + + /* Variable-length argument lists have a slight problem when */ + /* passing values by reference. Pity. This is a workaround. */ + return $parm; +} + /** * This function executes a hook and allows for parameters to be passed. * -- 2.25.1