Code

Udpated property editor
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 4 May 2010 15:50:19 +0000 (15:50 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 4 May 2010 15:50:19 +0000 (15:50 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18051 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_configRegistry.inc
gosa-core/plugins/addons/configViewer/class_configViewer.inc
gosa-core/plugins/addons/configViewer/class_filterProperties.inc
gosa-core/plugins/addons/configViewer/main.inc
gosa-core/plugins/addons/configViewer/property-filter.xml
gosa-core/plugins/addons/configViewer/property-list.tpl
gosa-core/plugins/addons/configViewer/property-list.xml

index 416865203d7a8e2957b7606c9ee563207585c981..3e9cb3b275bbc7873ac2148d4252c1c5eb3634c0 100644 (file)
@@ -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; 
index f209392ec0a69ecb7c7034adc615675e70f289b2..fea8e2e8d18e439cce344b1a49d94bd4a83b6c31 100644 (file)
@@ -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");
index 08a1c2f0182d5cbdd22fc38ef75b920ad75fbf9c..d475c37531a98963e31f76b5e704b66661323632 100644 (file)
@@ -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)){
index fca2fa756818a0bc5c40d78b7e09d0eac4367385..afdbdfc9db652a70f59a2e61c441d92177b2b4a4 100644 (file)
@@ -44,7 +44,6 @@ if ( $cleanup ){
 
     /* Execute formular */
     $display= $configViewer->execute ();
-    $display.= "<input type=\"hidden\" name=\"ignore\">\n";
 
     /* Store changes  in session */
     session::set('configViewer',$configViewer);
index b4bc1e511e5ab5e196d732235e3afb222cce0e0c..2e42280efa04cdd333125c3bc5068564ebe543e9 100644 (file)
@@ -15,7 +15,7 @@
     <label>Used properties</label>
     <query>
       <backend>CONFIGPROPERTIES</backend>
-      <filter>status=(ldap|file|modified)§cn=$</filter>
+      <filter>status=(ldap|file|modified|removed)§cn=$</filter>
     </query>
     <autocomplete>
       <attribute>status</attribute>
index 008ab32be4fb72eac0e6d74d710d160c2cc9a81b..082f5dea62d40943b9ebb55bc36f626d89d4605d 100644 (file)
@@ -15,4 +15,7 @@
   {$LIST}
 </div>
 
-<div class="clear"></div>
+<div class="plugin-actions">
+    <button name='saveProperties'>{msgPool type='okButton'}</button>
+    <button name='cancelProperties'>{msgPool type='cancelButton'}</button>
+</div>
index 15e51d37e896bfb6f334ed2b33e241e1abd09673..eab54b3de980833c616b918e1b6336e7f9f36fc5 100644 (file)
       <image>images/lists/element.png</image>
     </objectType>
 
+    <objectType>
+      <label>Property will be restored</label>
+      <objectClass>removed</objectClass>
+      <category>all</category>
+      <class>all</class>
+      <image>images/lists/trash.png</image>
+    </objectType>
+
     <objectType>
       <label>Modified property</label>
       <objectClass>modified</objectClass>