Clean up references to global vars
[squirrelmail.git] / functions / plugin.php
index 6277906dd92c35838b79cf9b24c7efa90a822507..63a8da17ebf4746f1df22152d9af3964f38819be 100644 (file)
@@ -68,7 +68,25 @@ function do_hook_function($name,$parm=NULL) {
     return $ret;
 }
 
+/* This function executes a hook. */
+function concat_hook_function($name,$parm=NULL) {
+    global $squirrelmail_plugin_hooks;
+    $ret = '';
 
+    if (isset($squirrelmail_plugin_hooks[$name])
+          && is_array($squirrelmail_plugin_hooks[$name])) {
+        foreach ($squirrelmail_plugin_hooks[$name] as $function) {
+            /* Concatenate results from hook. */
+            if (function_exists($function)) {
+                $ret .= $function($parm);
+            }
+        }
+    }
+
+    /* Variable-length argument lists have a slight problem when */
+    /* passing values by reference. Pity. This is a workaround.  */
+    return $ret;
+}
 
 /**
  * This function checks whether the user's USER_AGENT is known to
@@ -79,8 +97,9 @@ function soupNazi(){
 
     $soup_menu = array('Mozilla/3','Mozilla/2','Mozilla/1', 'Opera 4',
                        'Opera/4', 'OmniWeb', 'Lynx');
+    sqgetGlobalVar('HTTP_USER_AGENT', $user_agent, SQ_SERVER);
     foreach($soup_menu as $browser) {
-        if(stristr($_SERVER['HTTP_USER_AGENT'], $browser)) {
+        if(stristr($user_agent, $browser)) {
             return 1;
         }
     }