Code

Added dummy scehma check
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 21 May 2010 14:06:39 +0000 (14:06 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 21 May 2010 14:06:39 +0000 (14:06 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18626 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/html/main.php
gosa-core/include/class_configRegistry.inc

index c78b9d841beb596d74d1a8403bd5c713918faf8b..a47271342e85c1b995ebe9dd7336e93b371a9a8d 100644 (file)
@@ -65,6 +65,7 @@ if ($_SERVER['REMOTE_ADDR'] != $ui->ip){
 $config= session::global_get('config');
 $config->check_and_reload();
 $config->configRegistry->reload();
+$config->configRegistry->validateSchemata(TRUE, TRUE);
 
 /* Enable compressed output */
 if ($config->get_cfg_value("core","sendCompressedOutput") == "true"){
index 32b4b61e2e30526714d9a300989ed3e1a9033f0a..a362e525eaca36855dd2bfc3464cd976b36a42ed 100644 (file)
@@ -15,7 +15,7 @@ class configRegistry{
 
     // Contains all classes with plInfo
     public $classesWithInfo = array();
-    public $categoryRequirements  = array();
+    public $pluginRequirements  = array();
     public $categoryToClass  = array();
 
     public $objectClasses = array();
@@ -60,52 +60,60 @@ class configRegistry{
         }
 
         // Collect required schema infos
-        $this->categoryRequirements = array();
+        $this->pluginRequirements = array('ldapSchema' => array());
         $this->categoryToClass = array();
         foreach($this->classesWithInfo as $cname => $defs){
-            if(isset($defs['plCategory'])){
-                foreach($defs['plCategory'] as $name => $data){
-                    if(!is_numeric($name)){
-                        $this->categoryToClass[$name]['BASE'] = $cname;
-                        if(isset($data['objectClass'])){
-                            $this->categoryRequirements[$name] = $data['objectClass'];
-                        }
-                    }else{
-                        $this->categoryToClass[$data]['SUB'][] = $cname;
-                    }
-                }
+            if(isset($defs['plRequirements']['ldapSchema'])){
+                $this->pluginRequirements['ldapSchema'][$cname] = $defs['plRequirements']['ldapSchema'];
             }
         }
 
         // Check schema requirements now
-        foreach($this->categoryRequirements as $cat => $requirements){
-
-            if(!is_string($requirements)){
-            }else{
-                if(!$this->ocAvailable($requirements)){
-
+        foreach($this->pluginRequirements['ldapSchema'] as $cname => $requirements){
+            foreach($requirements as $oc => $version){
+                if(!$this->ocAvailable($oc)){
                     if($displayMessage){
-                        $classes = "<ul>";
-                        $name = $this->categoryToClass[$cat]['BASE'];
-                        $classes.= "<li>".$this->classToName[$name]."</li>";
-                        if(isset($this->categoryToClass[$cat]['SUB'])){
-                            foreach($this->categoryToClass[$cat]['SUB'] as $name){
-                                $classes.= "<li>".$this->classToName[$name]."</li>";
-                            }
-                        }
-                        $classes.= "</ul>";
                         msg_dialog::display(_("Schema validation error"), 
                                 sprintf(_("The objectClass '%s' which is required for plugin '%s' is not availabe!"),
-                                    bold($requirements),bold($cat)), 
+                                    bold($oc),bold($cname)), 
                                 ERROR_DIALOG);
                     }
-                }else{
-                     #äprint_a($this->objectClasses[$requirements]);   
+                }elseif(!empty($version)){
+
+                    $currentVersion = $this->getObjectClassVersion($oc);
+                    if(!empty($currentVersion) && !$this->ocVersionMatch($version, $currentVersion)){
+                        if($displayMessage){
+                            msg_dialog::display(_("Schema validation error"), 
+                                    sprintf(_("The objectClass '%s' which is required for plugin '%s' has version %s but %s is required!"),bold($oc),bold($cname),bold($currentVersion),bold($version)), 
+                                    ERROR_DIALOG);
+                        }
+                    }
                 }
             }
         }
     }
 
+    function ocVersionMatch($required, $installed)
+    {
+        $operator = preg_replace('/^([=<>]*).*$/',"\\1",$required);
+        $required = preg_replace('/^[=<>]*(.*)$/',"\\1",$required);
+        return(version_compare($installed,$required, $operator)); 
+    }
+
+    
+    function getObjectClassVersion($oc)
+    {
+        if(!isset($this->objectClasses[$oc])){
+            return(NULL);
+        }else{
+            $version = -1; // unknown
+            if(preg_match("/(v[^)]*)/", $this->objectClasses[$oc]['DESC'])){
+                $version = preg_replace('/^.*\(v([^)]*)\).*$/',"\\1", $this->objectClasses[$oc]['DESC']);
+            }
+        }
+        return($version);
+    }
+    
 
     // check wheter an objectClass is installed or not.
     function ocAvailable($name)