Replacing HTML "script" element deprecated attribute "language".
[squirrelmail.git] / functions / plugin.php
index 24eb56cb563d61d2a6fed96f150488d9140ffdea..ab8d518464a03a31ca42146c1bdc21c6d977cc9d 100644 (file)
@@ -3,19 +3,19 @@
 /**
  * plugin.php
  *
- * Copyright (c) 1999-2005 The SquirrelMail Project Team
- * Licensed under the GNU GPL. For full terms see the file COPYING.
- *
  * This file provides the framework for a plugin architecture.
  *
  * Documentation on how to write plugins might show up some time.
  *
+ * @copyright © 1999-2006 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
  */
 
 /** 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,7 +199,13 @@ function soupNazi(){
 function is_plugin_enabled($plugin_name) {
   global $plugins;
 
-  if (! isset($plugins) || ! is_array($plugins) || empty($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) ) {
@@ -215,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
+?>