From b4bfc9ef1a49128ae10ede0b52fb9f1fc74f548f Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 4 May 2010 15:50:19 +0000 Subject: [PATCH] Udpated property editor git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18051 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_configRegistry.inc | 47 ++++++++++++++++++- .../configViewer/class_configViewer.inc | 32 +++++++++++++ .../configViewer/class_filterProperties.inc | 2 +- .../plugins/addons/configViewer/main.inc | 1 - .../addons/configViewer/property-filter.xml | 2 +- .../addons/configViewer/property-list.tpl | 5 +- .../addons/configViewer/property-list.xml | 8 ++++ 7 files changed, 92 insertions(+), 5 deletions(-) diff --git a/gosa-core/include/class_configRegistry.inc b/gosa-core/include/class_configRegistry.inc index 416865203..3e9cb3b27 100644 --- a/gosa-core/include/class_configRegistry.inc +++ b/gosa-core/include/class_configRegistry.inc @@ -148,6 +148,13 @@ class configRegistry{ } return(""); } + + function saveChanges() + { + foreach($this->properties as $prop){ + $prop->save(); + } + } } @@ -227,6 +234,11 @@ class gosaProperty $this->value = $str; } + function restoreDefault() + { + $this->setStatus('removed'); + } + function save() { if($this->getStatus() == 'modified'){ @@ -269,12 +281,45 @@ class gosaProperty echo $ldap->get_error(); } } + }elseif($this->getStatus() == 'removed'){ + $ldap = $this->parent->config->get_ldap_link(); + $ldap->cd($this->parent->config->current['BASE']); + $dn = "cn={$this->class},".$this->parent->config->current['CONFIG']; + $ldap->cat($dn); + $attrs = $ldap->fetch(); + $data = array(); + for($i = 0;$i<$attrs['gosaSetting']['count']; $i ++){ + $set = $attrs['gosaSetting'][$i]; + if(preg_match("/^{$this->name}:/", $set)){ + continue; + } + $data['gosaSetting'][] = $set; + } + $ldap->cd($dn); + $ldap->modify($data); + if($ldap->success()){ + $this->status = 'undefined'; + + // Second check for values in the config file. + if(isset($this->parent->fileStoredProperties[$this->class][$this->name])){ + $this->setStatus('file'); + $this->value = $this->parent->fileStoredProperties[$this->class][$this->name]; + } + + // If there still wasn't found anything then fallback to the default. + if($this->getStatus() == 'undefined'){ + $this->value = $this->getDefault(); + } + + }else{ + echo $ldap->get_error(); + } } } private function setStatus($state) { - if(!in_array($state, array('ldap','file','undefined','modified'))) { + if(!in_array($state, array('ldap','file','undefined','modified','removed'))) { trigger_error("Unknown property status given '{$state}' for {$this->class}:{$this->name}!"); }else{ $this->status = $state; diff --git a/gosa-core/plugins/addons/configViewer/class_configViewer.inc b/gosa-core/plugins/addons/configViewer/class_configViewer.inc index f209392ec..fea8e2e8d 100644 --- a/gosa-core/plugins/addons/configViewer/class_configViewer.inc +++ b/gosa-core/plugins/addons/configViewer/class_configViewer.inc @@ -29,8 +29,40 @@ class configViewer extends management $headpage->registerElementFilter("propertyValue", "configViewer::propertyValue"); $headpage->setFilter($filter); parent::__construct($config, $ui, "property", $headpage); + + $this->registerAction("saveProperties","saveProperties"); + $this->registerAction("cancelProperties","cancelProperties"); + } + + function cancelProperties() + { + $this->config->configRegistry->reload($force=TRUE); + } + + function saveProperties() + { + $this->config->configRegistry->saveChanges(); } + function detectPostActions() + { + $action = management::detectPostActions(); + if(isset($_POST['saveProperties'])) $action['action'] = 'saveProperties'; + if(isset($_POST['cancelProperties'])) $action['action'] = 'cancelProperties'; + return($action); + } + + protected function removeEntryRequested($action="",$target=array(),$all=array()) + { + foreach($target as $dn){ + list($class,$name) = preg_split("/:/", $dn); + if($this->config->configRegistry->propertyExists($class,$name)){ + $prop = $this->config->configRegistry->getProperty($class,$name); + $prop->restoreDefault(); + } + } + } + static function propertyGroup($group, $description = array()) { $title = _("No description"); diff --git a/gosa-core/plugins/addons/configViewer/class_filterProperties.inc b/gosa-core/plugins/addons/configViewer/class_filterProperties.inc index 08a1c2f01..d475c3753 100644 --- a/gosa-core/plugins/addons/configViewer/class_filterProperties.inc +++ b/gosa-core/plugins/addons/configViewer/class_filterProperties.inc @@ -22,7 +22,7 @@ class filterCONFIGPROPERTIES { $entry = filterCONFIGPROPERTIES::fakeLdapResult($entry, 'type', $property->getType()); $entry = filterCONFIGPROPERTIES::fakeLdapResult($entry, 'migrate', $property->getMigrate()); $entry = filterCONFIGPROPERTIES::fakeLdapResult($entry, 'group', $property->getGroup()); - $entry['dn'] = $property->getName(); + $entry['dn'] = $property->getClass().":".$property->getName(); $found =TRUE; if(!empty($filter)){ diff --git a/gosa-core/plugins/addons/configViewer/main.inc b/gosa-core/plugins/addons/configViewer/main.inc index fca2fa756..afdbdfc9d 100644 --- a/gosa-core/plugins/addons/configViewer/main.inc +++ b/gosa-core/plugins/addons/configViewer/main.inc @@ -44,7 +44,6 @@ if ( $cleanup ){ /* Execute formular */ $display= $configViewer->execute (); - $display.= "\n"; /* Store changes in session */ session::set('configViewer',$configViewer); diff --git a/gosa-core/plugins/addons/configViewer/property-filter.xml b/gosa-core/plugins/addons/configViewer/property-filter.xml index b4bc1e511..2e42280ef 100644 --- a/gosa-core/plugins/addons/configViewer/property-filter.xml +++ b/gosa-core/plugins/addons/configViewer/property-filter.xml @@ -15,7 +15,7 @@ CONFIGPROPERTIES - status=(ldap|file|modified)§cn=$ + status=(ldap|file|modified|removed)§cn=$ status diff --git a/gosa-core/plugins/addons/configViewer/property-list.tpl b/gosa-core/plugins/addons/configViewer/property-list.tpl index 008ab32be..082f5dea6 100644 --- a/gosa-core/plugins/addons/configViewer/property-list.tpl +++ b/gosa-core/plugins/addons/configViewer/property-list.tpl @@ -15,4 +15,7 @@ {$LIST} -
+
+ + +
diff --git a/gosa-core/plugins/addons/configViewer/property-list.xml b/gosa-core/plugins/addons/configViewer/property-list.xml index 15e51d37e..eab54b3de 100644 --- a/gosa-core/plugins/addons/configViewer/property-list.xml +++ b/gosa-core/plugins/addons/configViewer/property-list.xml @@ -19,6 +19,14 @@ images/lists/element.png + + + removed + all + all + images/lists/trash.png + + modified -- 2.30.2