Code

Made loading of xml file more tolerant
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 16 Jan 2008 16:12:10 +0000 (16:12 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 16 Jan 2008 16:12:10 +0000 (16:12 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8403 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_pluglist.inc
gosa-core/include/functions.inc

index 1bce72412cde395a2f2e62debd017436dc7636dd..87dcd769368812892d2e5496fbea44c3817a496a 100644 (file)
@@ -114,9 +114,11 @@ class pluglist {
                if(count($this->headlines) == 0){
                        foreach($this->config->data['MENU'] as $headline => $plugins){
                                foreach( $plugins as $id => $plug){
-                                       $attrs = (get_class_vars($plug['CLASS']));
-                                       $ret[$id]['HEADLINE'] = $headline;
-                                       $ret[$id]['NAME']         = $attrs['plHeadline'];       
+                                       if (plugin_available($plug['CLASS'])){
+                                               $attrs = (get_class_vars($plug['CLASS']));
+                                               $ret[$id]['HEADLINE'] = $headline;
+                                               $ret[$id]['NAME']         = $attrs['plHeadline'];
+                                       }
                                }
                        }
                        $this->headlines = $ret;
@@ -150,6 +152,9 @@ class pluglist {
                                                msg_dialog::display(_("Configuration error"), _("The configuration format has changed. Please re-run setup!"), ERROR_DIALOG);
                                                display_error_page();
                                        }
+                                       if (!plugin_available($info['CLASS'])){
+                                               continue;
+                                       }
                                        $vars= get_class_vars($info['CLASS']);
                                        $plHeadline= $vars['plHeadline'];
                                        $plDescription= $vars['plDescription'];
@@ -259,6 +264,10 @@ class pluglist {
 
                                foreach ($plug as $info){
 
+                                       if (!plugin_available($info['CLASS'])){
+                                               continue;
+                                       }
+
                                        /* Read information from class variable */
                                        $vars= get_class_vars($info['CLASS']);
                                        $plHeadline= $vars['plHeadline'];
index 3ab7a405346f19d3c70c4ecef361737817333310..b1123007da4c49a16803f2ff4fc2a7910b41ea16 100644 (file)
@@ -96,11 +96,26 @@ function __autoload($class_name) {
     if (isset($class_mapping[$class_name])){
       require_once($BASE_DIR."/".$class_mapping[$class_name]);
     } else {
-      echo _("Fatal: cannot load class \"$class_name\" - execution aborted");
+      echo sprintf(_("Fatal error: cannot load class '%s' - execution aborted"), $class_name);
+      print_a(debug_backtrace());
+      exit;
     }
 }
 
 
+/* Check if plugin is avaliable */
+function plugin_available($plugin)
+{
+       global $class_mapping, $BASE_DIR;
+
+       if (!isset($class_mapping[$plugin])){
+               return false;
+       } else {
+               return file_exists($BASE_DIR."/".$class_mapping[$plugin]);
+       }
+}
+
+
 /* Create seed with microseconds */
 function make_seed() {
   list($usec, $sec) = explode(' ', microtime());