Code

Updated JsonRpc and JsonRop class
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 20 Oct 2010 14:03:32 +0000 (14:03 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 20 Oct 2010 14:03:32 +0000 (14:03 +0000)
-Replace all jsonclass results with the json remove class factory object.

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

gosa-core/include/class_jsonROP.inc
gosa-core/include/class_jsonRPC.inc

index 95fee770717064a061fe15f1a2c58a24dfd88070..f7008abcb248302270f359309664cac64cf55e99 100644 (file)
@@ -1,41 +1,34 @@
 <?php
 
-
 class jsonROP
 {
     private $config;
 
-    public static function getObject($objectID)
+    public static function inspectJsonResult($result)
     {
-        global $config;
-
-        // Disable debug output, #FIXME remove this later.
-        $dL = $config->configRegistry->getProperty('core', 'debugLevel');
-        $dL->setValue(2048)   ;
-        $dL->save();
-
-        // Connect to the backend and request the given object.
-        $rpc = $config->getRpcHandle('http://10.3.64.59:8088','','');
-        $res = $rpc->openObject($objectID, 12);
+        // Check for remove objects we've to create
+        if(isset($result['__jsonclass__'])){
 
-        // Get all relevant class informations 
-        $classDef = $res['__jsonclass__'][1];
-        $type = $classDef[0];
-        $ref_id = $classDef[1];
-        $object_id = $classDef[2];
-        $methods = $classDef[3];
-        $properties = $classDef[4];
+            // Get all relevant class informations 
+            $classDef = $result['__jsonclass__'][1];
+            $type = $classDef[0];
+            $ref_id = $classDef[1];
+            $object_id = $classDef[2];
+            $methods = $classDef[3];
+            $properties = $classDef[4];
 
-        // Prepare values
-        $values = array();
-        foreach($properties as $prop){
-            $values[$prop] = NULL;
-            if(isset($res[$prop])) $values[$prop] = $res[$prop]; 
-        }
+            // Prepare values
+            $values = array();
+            foreach($properties as $prop){
+                $values[$prop] = NULL;
+                if(isset($res[$prop])) $values[$prop] = $res[$prop]; 
+            }
 
-        // Build up remote object
-        $object = new remoteObject($rpc, $type, $properties, $values, $methods, $object_id, $ref_id);
-        return($object);
+            // Build up remote object
+            $object = new remoteObject($rpc, $type, $properties, $values, $methods, $object_id, $ref_id);
+            return($object);
+        }        
+        return($result);
     }
 }
 
index 0a67bbf8001dea0ae92ecb148a833d6136441019..dff3870d9e9319f4eb8037975e591f913ae77bdd 100644 (file)
@@ -182,7 +182,14 @@ class jsonRPC {
             print_a(array('CALLED:' => array($method => $params)));
             print_a(array('RESPONSE' => $response));
         }
-        return($response['result']);
+        $return = $response['result'];
+        
+        // Create remote-object handling using the jsonROP class
+        if(class_available('jsonROP')){
+            $return = jsonROP::inspectJsonResult($return);
+        }
+
+        return($return);
     }