Code

#Updated remoteObject class
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 7 Apr 2011 14:33:36 +0000 (14:33 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 7 Apr 2011 14:33:36 +0000 (14:33 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20664 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_remoteObject.inc

index 4281d2781b7d95b2185460cf6b1f418c777c640b..af03c423fb4d444ff1bcf68cadafc023ca5b284c 100644 (file)
@@ -165,14 +165,20 @@ class remoteObject
      * @param   Mixed   The new value for the property.
      * @return  Boolean true on success else false.
      */
-    function __setProperty($name, $value)
+    function __setProperty($name, $value, $forceSave = FALSE)
     {
-        $this->rpcHandle->setObjectProperty($this->ref_id, $name,$value);
-        if($this->rpcHandle->success()){
+        if($this->directStorage || $forceSave){
+            $this->rpcHandle->setObjectProperty($this->ref_id, $name,$value);
+            if($this->rpcHandle->success()){
+                $this->__addPropValueToCache($name, $value);
+                return(TRUE);
+            }else{
+                return(FALSE);
+            }
+        }else{
             $this->__addPropValueToCache($name, $value);
             return(TRUE);
         }
-        return(FALSE);
     }
 
 
@@ -191,6 +197,7 @@ class remoteObject
             return(NULL);
         }else{
             $this->__addPropValueToCache($name, $res);
+            $this->values[$name] = $res;
             return($res);
         }
     }
@@ -246,6 +253,29 @@ class remoteObject
         $this->cache = array();
     }
 
+    
+    /* \brief   See commit();
+     */
+    function save()
+    {
+        return($this->commit());
+    }
+
+    
+    /*! \brief  Saves property modifications back to the server.
+     *          This is only necessary in directStorage mode.
+     * @param   Boolean     If set to true all attributes will be saved, even not modified.
+     */
+    function commit($saveUntouchedPropertiesToo = FALSE)
+    {
+        foreach($this->properties as $prop){
+            if($this->__propIsCached($prop)) continue;
+            if($saveUntouchedPropertiesToo || $this->values[$prop] != $this->__getPropFromCache($prop)){
+                $this->__setProperty($prop, $this->__getPropFromCache($prop), TRUE);
+            }
+        }
+    }
+
 
     /*!\brief   Internal method which removes a property from the cache. 
      * @param   String  The name of the property.