Code

display schema problems in a single dialog
[gosa.git] / gosa-core / include / class_configRegistry.inc
index a362e525eaca36855dd2bfc3464cd976b36a42ed..8f882a58eb469f8276fa745214e7694f4e4320bd 100644 (file)
@@ -20,6 +20,8 @@ class configRegistry{
 
     public $objectClasses = array();
 
+    public $schemaCheckFinished = FALSE;
+
     function __construct($config)
     {
         $this->config = &$config;
@@ -45,13 +47,16 @@ class configRegistry{
     }
 
 
-    function validateSchemata($disableIncompatiblePlugins = FALSE,$displayMessage = FALSE)
+    function validateSchemata($force = FALSE, $disableIncompatiblePlugins = FALSE,$displayMessage = FALSE)
     {
         // We can check the schemata only with a valid LDAP connection
         if(empty($this->config->current['CONFIG'])){
             return(TRUE); 
         }
 
+        // Don't do things twice unless forced
+        if($this->schemaCheckFinished && !$force) return; 
+
         // Read objectClasses from ldap
         if(!count($this->objectClasses)){
             $ldap = $this->config->get_ldap_link();
@@ -69,28 +74,35 @@ class configRegistry{
         }
 
         // Check schema requirements now
+        $missing = $invalid = array();
         foreach($this->pluginRequirements['ldapSchema'] as $cname => $requirements){
             foreach($requirements as $oc => $version){
                 if(!$this->ocAvailable($oc)){
-                    if($displayMessage){
-                        msg_dialog::display(_("Schema validation error"), 
-                                sprintf(_("The objectClass '%s' which is required for plugin '%s' is not availabe!"),
-                                    bold($oc),bold($cname)), 
-                                ERROR_DIALOG);
-                    }
+                    $missing[] = $oc;
                 }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);
+                        if($currentVersion == -1){
+                            $currentVersion = _("unknown");
                         }
+                        $invalid[] = sprintf(_("%s has version %s but %s required!"), bold($oc),bold($currentVersion),bold($version));
                     }
                 }
             }
         }
+
+        if($displayMessage && count($missing)){
+            msg_dialog::display(_("Schema validation error"), 
+                    sprintf(_("The following objectClasses are missing! %s"), msgPool::buildList($missing)),
+                    ERROR_DIALOG);
+        }    
+        if($displayMessage && count($invalid)){
+            msg_dialog::display(_("Schema validation error"), 
+                    sprintf(_("The following objectClasses do not match the version requirements! %s"), msgPool::buildList($invalid)),
+                    ERROR_DIALOG);
+        }    
+
+        $this->schemaCheckFinished =TRUE;
     }
 
     function ocVersionMatch($required, $installed)