+ }
+ }
+
+ if ($force_array && is_string($ret)) {
+ $ret = array($ret);
+ }
+
+ $currentHookName = '';
+ return $ret;
+
+}
+
+/**
+ * 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
+ * override any trues.
+ * Priority 0 means majority rules. Ties will be broken with $tie
+ *
+ * If any plugin on this hook wants to modify the $args
+ * plugin parameter, it simply has to use call-by-reference
+ * syntax in the hook function that it has registered for the
+ * current hook. Note that this is in addition to (entirely
+ * independent of) the return value for this hook.
+ *
+ * @param string $name The hook name
+ * @param mixed $args A single value or an array of arguments
+ * that are to be passed to all plugins
+ * operating off the hook being called.
+ * Note that this argument is passed by
+ * reference thus it is liable to be
+ * changed after the hook completes.
+ * @param int $priority See explanation above
+ * @param boolean $tie See explanation above
+ *
+ * @return boolean The result of the function
+ *
+ */
+function boolean_hook_function($name, &$args, $priority=0, $tie=false) {
+
+ global $squirrelmail_plugin_hooks, $currentHookName;
+ $yea = 0;
+ $nay = 0;
+ $ret = $tie;
+
+ if (isset($squirrelmail_plugin_hooks[$name]) &&
+ is_array($squirrelmail_plugin_hooks[$name])) {
+
+ /* Loop over the plugins that registered the hook */
+ $currentHookName = $name;
+ foreach ($squirrelmail_plugin_hooks[$name] as $plugin_name => $function) {
+ use_plugin($plugin_name);
+ if (function_exists($function)) {
+ $ret = $function($args);
+ if ($ret) {
+ $yea++;
+ } else {
+ $nay++;
+ }
+ }
+ }
+ $currentHookName = '';
+
+ /* Examine the aftermath and assign the return value appropriately */
+ if (($priority > 0) && ($yea)) {
+ $ret = true;
+ } elseif (($priority < 0) && ($nay)) {
+ $ret = false;
+ } elseif ($yea > $nay) {
+ $ret = true;
+ } elseif ($nay > $yea) {
+ $ret = false;
+ } else {
+ // There's a tie, no action needed.
+ }
+ return $ret;
+ }
+ // If the code gets here, there was a problem - no hooks, etc.
+ return NULL;
+
+}
+
+/**
+ * Do not use, use checkForJavascript() instead.
+ *
+ * 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
+ * offending browser.
+ * *** THIS IS A TEST FOR JAVASCRIPT SUPPORT ***
+ *
+ * @return bool whether this browser properly supports JavaScript
+ * @deprecated use checkForJavascript() since 1.5.1
+ */
+function soupNazi(){
+ return !checkForJavascript();
+}
+
+/**
+ * Check if plugin is enabled
+ * @param string $plugin_name plugin name
+ * @since 1.5.1
+ * @return boolean
+ */
+function is_plugin_enabled($plugin_name) {
+ global $plugins;
+
+ /**
+ * check if variable is empty. if var is not set, php empty
+ * returns true without error notice.
+ *
+ * then check if it is an array
+ */
+ if (empty($plugins) || ! is_array($plugins))
+ return false;
+
+ if ( in_array($plugin_name,$plugins) ) {
+ return true;
+ } else {
+ return false;