+/**
+ * Squelch error output to screen (only) for the given function.
+ * If the SquirrelMail debug mode SM_DEBUG_MODE_ADVANCED is not
+ * enabled, error output will not go to the log, either.
+ *
+ * This provides an alternative to the @ error-suppression
+ * operator where errors will not be shown in the interface
+ * but will show up in the server log file (assuming the
+ * administrator has configured PHP logging).
+ *
+ * @since 1.4.12 and 1.5.2
+ *
+ * @param string $function The function to be executed
+ * @param array $args The arguments to be passed to the function
+ * (OPTIONAL; default no arguments)
+ * NOTE: The caller must take extra action if
+ * the function being called is supposed
+ * to use any of the parameters by
+ * reference. In the following example,
+ * $x is passed by reference and $y is
+ * passed by value to the "my_func"
+ * function.
+ * sq_call_function_suppress_errors('my_func', array(&$x, $y));
+ *
+ * @return mixed The return value, if any, of the function being
+ * executed will be returned.
+ *
+ */
+function sq_call_function_suppress_errors($function, $args=NULL) {
+ global $sm_debug_mode;
+
+ $display_errors = ini_get('display_errors');
+ ini_set('display_errors', '0');
+
+ // if advanced debug mode isn't enabled, don't log the error, either
+ //
+ if (!($sm_debug_mode & SM_DEBUG_MODE_ADVANCED))
+ $error_reporting = error_reporting(0);
+
+ $ret = call_user_func_array($function, $args);
+
+ if (!($sm_debug_mode & SM_DEBUG_MODE_ADVANCED))
+ error_reporting($error_reporting);
+
+ ini_set('display_errors', $display_errors);
+ return $ret;
+}
+