From 2a5845405cd07efe83561b9402690dd6720d27b7 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 21 May 2010 12:43:55 +0000 Subject: [PATCH] Added dummy schema validator git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18613 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_configRegistry.inc | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/gosa-core/include/class_configRegistry.inc b/gosa-core/include/class_configRegistry.inc index 5051d21b6..32b4b61e2 100644 --- a/gosa-core/include/class_configRegistry.inc +++ b/gosa-core/include/class_configRegistry.inc @@ -15,6 +15,10 @@ class configRegistry{ // Contains all classes with plInfo public $classesWithInfo = array(); + public $categoryRequirements = array(); + public $categoryToClass = array(); + + public $objectClasses = array(); function __construct($config) { @@ -40,6 +44,76 @@ class configRegistry{ $this->reload(); } + + function validateSchemata($disableIncompatiblePlugins = FALSE,$displayMessage = FALSE) + { + // We can check the schemata only with a valid LDAP connection + if(empty($this->config->current['CONFIG'])){ + return(TRUE); + } + + // Read objectClasses from ldap + if(!count($this->objectClasses)){ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $this->objectClasses = $ldap->get_objectclasses(); + } + + // Collect required schema infos + $this->categoryRequirements = 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; + } + } + } + } + + // Check schema requirements now + foreach($this->categoryRequirements as $cat => $requirements){ + + if(!is_string($requirements)){ + }else{ + if(!$this->ocAvailable($requirements)){ + + 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)), + ERROR_DIALOG); + } + }else{ + #äprint_a($this->objectClasses[$requirements]); + } + } + } + } + + + // check wheter an objectClass is installed or not. + function ocAvailable($name) + { + return(isset($this->objectClasses[$name])); + } + + function reload($force = FALSE) { // Do not reload the properties everytime, once we have -- 2.30.2