made the code work for triggering imap related errors.
[squirrelmail.git] / functions / plugin.php
index 280e41464548018e5bb648031b10485eff6829c6..ab8d518464a03a31ca42146c1bdc21c6d977cc9d 100644 (file)
@@ -7,7 +7,7 @@
  *
  * Documentation on how to write plugins might show up some time.
  *
- * @copyright © 1999-2005 The SquirrelMail Project Team
+ * @copyright © 1999-2006 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
@@ -15,6 +15,7 @@
 
 /** Everything needs global.. */
 require_once(SM_PATH . 'functions/global.php');
+require_once(SM_PATH . 'config/config.php');
 require_once(SM_PATH . 'functions/prefs.php');
 
 global $squirrelmail_plugin_hooks;
@@ -199,11 +200,12 @@ function is_plugin_enabled($plugin_name) {
   global $plugins;
 
   /**
-   * check if variable is set. can't do is_array(), if variable is not set
-   * check if it is an array
-   * there is no need to call in_array() if $plugins array is empty
+   * 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 (! isset($plugins) || ! is_array($plugins) || empty($plugins))
+  if (empty($plugins) || ! is_array($plugins))
     return false;
 
   if ( in_array($plugin_name,$plugins) ) {
@@ -219,9 +221,18 @@ function is_plugin_enabled($plugin_name) {
 
 /* On startup, register all plugins configured for use. */
 if (isset($plugins) && is_array($plugins)) {
+    // turn on output buffering in order to prevent output of new lines
+    ob_start();
     foreach ($plugins as $name) {
         use_plugin($name);
     }
+    // get output and remove whitespace
+    $output = trim(ob_get_contents());
+    ob_end_clean();
+    // if plugins output more than newlines and spacing, stop script execution.
+    if (!empty($output)) {
+        die($output);
+    }
 }
 
-?>
\ No newline at end of file
+?>