Code

Updated class config::getRpcHandle
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 9 Nov 2010 15:11:37 +0000 (15:11 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 9 Nov 2010 15:11:37 +0000 (15:11 +0000)
-Allow to disable connection caching.

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

gosa-core/include/class_GOsaRegistration.inc
gosa-core/include/class_config.inc
gosa-core/include/class_jsonRPC.inc

index 2685bcabb311f9eac5b009c38ebb7dd3850163ad..efadc48b380a08f8a6d0fe5f3e906a91aa768cf6 100644 (file)
@@ -1,12 +1,20 @@
 <?php
 
-
 class GOsaRegistration 
 {
-    
+    private $config;
 
-} 
+    function __construct(&$config)
+    {
+        $this->config = $config;
+    }    
 
+    
 
+    function isInstanceRegistered()
+    {
+        return(FALSE);
+    }
+} 
 
 ?>
index a630ab8a98b542655cc284c95024727e3c0fe61a..ad4d2fc7cb21fb67596d168c141053d2477d548d 100644 (file)
@@ -316,7 +316,7 @@ class config  {
     }
 
 
-    function getRpcHandle($connectUrl=NULL, $username=NULL, $userPassword=NULL, $authModeDigest=FALSE)
+    function getRpcHandle($connectUrl=NULL, $username=NULL, $userPassword=NULL, $authModeDigest=FALSE, $cache = TRUE)
     {
         // Get conenct information, if no info was given use the default values from gosa.conf
         $connectUrl   = ($connectUrl !== NULL)   ? $connectUrl   : $this->get_cfg_value('core','gosaRpcServer');
@@ -325,10 +325,15 @@ class config  {
         $authModeDigest = $authModeDigest;
     
         // Create jsonRPC handle on demand.
-        if(!isset($this->jsonRPChandle[$connectUrl][$username]) || !$this->jsonRPChandle[$connectUrl][$username]){
-            $this->jsonRPChandle[$connectUrl][$username] = new jsonRPC($this, $connectUrl, $username, $userPassword, $authModeDigest);
+        if(!$cache){
+            return(new jsonRPC($this, $connectUrl, $username, $userPassword, $authModeDigest));
+        }else{
+
+            if(!isset($this->jsonRPChandle[$connectUrl][$username]) || !$this->jsonRPChandle[$connectUrl][$username]){
+                $this->jsonRPChandle[$connectUrl][$username] = new jsonRPC($this, $connectUrl, $username, $userPassword, $authModeDigest);
+            }
+            return($this->jsonRPChandle[$connectUrl][$username]);
         }
-        return($this->jsonRPChandle[$connectUrl][$username]);
     }
 
 
index e65cfbdc914619b341bc57d0c56c2a5cc49a290c..b9ded4fe3c851def5c1709bc11559c9e70f5df04 100644 (file)
@@ -93,8 +93,10 @@ class jsonRPC {
 
         // Try to login 
         if($this->authModeDigest){
-            if(!empty($this->username)) 
+            if(!empty($this->username)){
                 curl_setopt($this->curlHandler, CURLOPT_USERPWD , "{$this->username}:{$this->userPassword}");
+            }
+        
             curl_setopt($this->curlHandler, CURLOPT_HTTPAUTH , CURLAUTH_ANYSAFE);
         }else{
             curl_setopt($this->curlHandler, CURLOPT_COOKIESESSION , TRUE);
@@ -141,7 +143,8 @@ class jsonRPC {
      */
     public function success()
     {
-        return(curl_errno($this->curlHandler) == 0 && $this->lastStats['http_code'] == 200);
+        return(curl_errno($this->curlHandler) == 0 || 
+             (isset($this->lastStats['http_code']) && $this->lastStats['http_code'] == 200));
     }