Code

Updated property editor.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 6 May 2010 10:26:35 +0000 (10:26 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 6 May 2010 10:26:35 +0000 (10:26 +0000)
-Value are only temporary modified since saved - else we affect the running gosa instance

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18179 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_configRegistry.inc
gosa-core/plugins/addons/configViewer/class_filterProperties.inc

index c60767f109f0c067f8632e6d352bdc6123b09ae7..22e3e16c2264a9a80c937a316c7373f88b925f1b 100644 (file)
@@ -177,6 +177,7 @@ class gosaProperty
     protected $name = "";
     protected $class = "";
     protected $value = "";
+    protected $tmp_value = "";  // Used when modified but not saved 
     protected $type = "string";
     protected $default = "";
     protected $defaults = "";
@@ -275,7 +276,6 @@ class gosaProperty
         }
     }
 
-    function getValue() { return($this->value); }
     function getMigrate() { return($this->migrate); }
     function getCheck() { return($this->check); }
     function getName() { return($this->name); }
@@ -292,7 +292,16 @@ class gosaProperty
     {
         if($this->value != $str){
             $this->setStatus('modified'); 
-            $this->value = $str; 
+            $this->tmp_value = $str; 
+        }
+    }
+
+    function getValue($temporary = FALSE) 
+    { 
+        if($temporary && in_array($this->getStatus(), array('modified'))){
+            return($this->tmp_value); 
+        }else{ 
+            return($this->value); 
         }
     }
 
@@ -308,7 +317,6 @@ class gosaProperty
     function save()
     {
         if($this->getStatus() == 'modified'){
-
             $ldap = $this->parent->config->get_ldap_link();
             $ldap->cd($this->parent->config->current['BASE']);
             $dn = "cn={$this->class},".$this->parent->config->current['CONFIG'];
@@ -318,13 +326,12 @@ class gosaProperty
                 $data = array(
                         'cn' => $this->class, 
                         'objectClass' => array('top','gosaConfig'),
-                        'gosaSetting' => $this->name.":".$this->value);
+                        'gosaSetting' => $this->name.":".$this->tmp_value);
 
                 $ldap->add($data);
                 if(!$ldap->success()){
                     echo $ldap->get_error();
                 }
-                $this->_restoreCurrentValue();
 
             }else{
                 $attrs = $ldap->fetch();
@@ -333,19 +340,19 @@ class gosaProperty
                 for($i = 0;$i<$attrs['gosaSetting']['count']; $i ++){
                     $set = $attrs['gosaSetting'][$i];
                     if(preg_match("/^{$this->name}:/", $set)){
-                        $set = "{$this->name}:{$this->value}";
+                        $set = "{$this->name}:{$this->tmp_value}";
                         $found = true;
                     }
                     $data['gosaSetting'][] = $set;
                 }
-                if(!$found) $data['gosaSetting'][] = "{$this->name}:{$this->value}";
+                if(!$found) $data['gosaSetting'][] = "{$this->name}:{$this->tmp_value}";
                 $ldap->cd($dn);
                 $ldap->modify($data);
                 if(!$ldap->success()){
                     echo $ldap->get_error();
                 }
-                $this->_restoreCurrentValue();
             } 
+            $this->_restoreCurrentValue();
         }elseif($this->getStatus() == 'removed'){
             $ldap = $this->parent->config->get_ldap_link();
             $ldap->cd($this->parent->config->current['BASE']);
index 136eb07a420d043586db2bba5a700dd7f8e8b817..15ac1aa5d4400695628b32feeb4811c250ec54d8 100644 (file)
@@ -15,7 +15,7 @@ class filterCONFIGPROPERTIES {
         $entry = filterCONFIGPROPERTIES::fakeLdapResult($entry, 'objectClass', $property->getStatus());
         $entry = filterCONFIGPROPERTIES::fakeLdapResult($entry, 'status', $property->getStatus());
         $entry = filterCONFIGPROPERTIES::fakeLdapResult($entry, 'description', $property->getDescription());
-        $entry = filterCONFIGPROPERTIES::fakeLdapResult($entry, 'value', $property->getValue());
+        $entry = filterCONFIGPROPERTIES::fakeLdapResult($entry, 'value', $property->getValue($temporary = TRUE));
         $entry = filterCONFIGPROPERTIES::fakeLdapResult($entry, 'default', $property->getDefault());
         $entry = filterCONFIGPROPERTIES::fakeLdapResult($entry, 'defaults', $property->getDefaults());
         $entry = filterCONFIGPROPERTIES::fakeLdapResult($entry, 'check', $property->getCheck());