From: hickert Date: Tue, 25 May 2010 13:57:57 +0000 (+0000) Subject: Updated schemaCheck X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2e51351e38ff3071dec4122126e11f4357afde88;p=gosa.git Updated schemaCheck -Keep results in an array -Seperated the code which generates the error message into an extra method. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18693 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/html/main.php b/gosa-core/html/main.php index 83f0a7e3d..710b8c34e 100644 --- a/gosa-core/html/main.php +++ b/gosa-core/html/main.php @@ -65,7 +65,9 @@ if ($_SERVER['REMOTE_ADDR'] != $ui->ip){ $config= session::global_get('config'); $config->check_and_reload(); $config->configRegistry->reload(); -$config->configRegistry->validateSchemata($force=FALSE,$disableIncompatiblePlugins=TRUE,$errorMessages= TRUE); +if(!$config->configRegistry->validateSchemata($force=FALSE,$disableIncompatiblePlugins=TRUE)){ + $config->configRegistry->displayErrors(); +} /* Enable compressed output */ if ($config->get_cfg_value("core","sendCompressedOutput") == "true"){ diff --git a/gosa-core/include/class_configRegistry.inc b/gosa-core/include/class_configRegistry.inc index 7cdd58c40..d64d82872 100644 --- a/gosa-core/include/class_configRegistry.inc +++ b/gosa-core/include/class_configRegistry.inc @@ -20,6 +20,8 @@ class configRegistry{ public $objectClasses = array(); + public $detectedSchemaIssues = array(); + public $schemaCheckFailed = FALSE; public $schemaCheckFinished = FALSE; function __construct($config) @@ -47,7 +49,7 @@ class configRegistry{ } - function validateSchemata($force = FALSE, $disableIncompatiblePlugins = FALSE,$displayMessage = FALSE) + function validateSchemata($force = FALSE, $disableIncompatiblePlugins = FALSE) { // We can check the schemata only with a valid LDAP connection if(empty($this->config->current['CONFIG'])){ @@ -55,7 +57,12 @@ class configRegistry{ } // Don't do things twice unless forced - if($this->schemaCheckFinished && !$force) return; + if($this->schemaCheckFinished && !$force) return($this->schemaCheckFailed); + + // Prepare result array + $this->detectedSchemaIssues = array(); + $this->detectedSchemaIssues['missing'] = array(); + $this->detectedSchemaIssues['versionMismatch'] = array(); // Read objectClasses from ldap if(!count($this->objectClasses)){ @@ -73,40 +80,51 @@ class configRegistry{ } } - // Check schema requirements now - $missing = $invalid = array(); + // Check schema requirements now $missing = $invalid = array(); foreach($this->pluginRequirements['ldapSchema'] as $cname => $requirements){ foreach($requirements as $oc => $version){ - if(!$this->ocAvailable($oc)){ - $missing[] = $oc; + if(1 || !$this->ocAvailable($oc)){ + $this->detectedSchemaIssues['missing'][] = $oc; + $this->schemaCheckFailed = TRUE; }elseif(!empty($version)){ $currentVersion = $this->getObjectClassVersion($oc); if(!empty($currentVersion) && !$this->ocVersionMatch($version, $currentVersion)){ if($currentVersion == -1){ $currentVersion = _("unknown"); } - $invalid[] = sprintf(_("%s has version %s but %s required!"), bold($oc),bold($currentVersion),bold($version)); + $this->detectedSchemaIssues['versionMismatch'] = + sprintf(_("%s has version %s but %s required!"), bold($oc),bold($currentVersion),bold($version)); + $this->schemaCheckFailed = TRUE; } } } } + $this->schemaCheckFinished =TRUE; + return(!$this->schemaCheckFailed); + } - if($displayMessage && count($missing)){ + + function displayErrors() + { + if(count($this->detectedSchemaIssues['missing'])){ msg_dialog::display(_("Schema validation error"), - _("The following objectClasses are missing:"). - "
".msgPool::buildList($missing)."
", + _("The following objectClasses are missing:"). + "
". + msgPool::buildList($this->detectedSchemaIssues['missing']). + "
", ERROR_DIALOG); } - if($displayMessage && count($invalid)){ + if(count($this->detectedSchemaIssues['versionMismatch'])){ msg_dialog::display(_("Schema validation error"), - _("The following objectClasses do not match the version requirements:"). - "
".msgPool::buildList($invalid)."
", + _("The following objectClasses do not match the version requirements:"). + "
". + msgPool::buildList($this->detectedSchemaIssues['versionMismatch']). + "
", ERROR_DIALOG); } - - $this->schemaCheckFinished =TRUE; } + function ocVersionMatch($required, $installed) { $operator = preg_replace('/^([=<>]*).*$/',"\\1",$required);