From 2593b8c385c1587447b071e104da562bcc3c5be8 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 21 May 2010 14:06:39 +0000 Subject: [PATCH] Added dummy scehma check git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18626 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/html/main.php | 1 + gosa-core/include/class_configRegistry.inc | 70 ++++++++++++---------- 2 files changed, 40 insertions(+), 31 deletions(-) diff --git a/gosa-core/html/main.php b/gosa-core/html/main.php index c78b9d841..a47271342 100644 --- a/gosa-core/html/main.php +++ b/gosa-core/html/main.php @@ -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"){ diff --git a/gosa-core/include/class_configRegistry.inc b/gosa-core/include/class_configRegistry.inc index 32b4b61e2..a362e525e 100644 --- a/gosa-core/include/class_configRegistry.inc +++ b/gosa-core/include/class_configRegistry.inc @@ -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 = ""; 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) -- 2.30.2