Code

Added rpc connection settings check to the peroperty editor
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 14 Oct 2010 12:02:04 +0000 (12:02 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 14 Oct 2010 12:02:04 +0000 (12:02 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20043 594d385d-05f5-0310-b6e9-bd551577e9d8

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

index 0b96b077e7459fda323ddb2edc33da3e2b06e3d2..73275f70883ea626994c8e28ff8728e2306b46de 100644 (file)
@@ -701,7 +701,7 @@ DEBUG_SI      = 256"),
                                 "type"          => "string",
                                 "default"       => "",
                                 "description"   => "The server to use for RPC connections! (http://localhost:8080/rpc), Future GOsa-ng service! If this value is set and not empty GOsa will try to establish a connection!",
-                                "check"         => "",
+                                "check"         => "jsonRPC::testConnectionProperties",
                                 "migrate"       => "",
                                 "group"         => "rpc",
                                 "mandatory"     => FALSE),
index f7b7a501f4f4961c3e0a75c7242093e53bc2e7dc..689112171907eb70669e69b963cdfb2c4d1b767c 100644 (file)
@@ -17,6 +17,34 @@ class jsonRPC {
     private $authModeDigest = FALSE; 
 
 
+    /*! \brief  This function is used by the property editor and checks the 
+     *           given rpc connection informations.
+     */
+    public static function testConnectionProperties($message,$class,$name,$value, $type)
+    {
+        global $config;
+
+        // Get currently used connection usernamem and password.
+        // We use the temporary values, due to the fact, that we do not want to test
+        //  the current values, we want to test the modified values.
+        $user = $config->configRegistry->getProperty('core','gosaRpcUser');
+        $username =  $user->getValue($temporaryValue = TRUE);
+        $passwd = $config->configRegistry->getProperty('core','gosaRpcPassword');
+        $passwdString =  $passwd->getValue($temporaryValue = TRUE);
+
+        $connection = new jsonRPC($config, $value, $username, $passwdString);        
+        if(!$connection->success() && $message){
+            msg_dialog::display(_("Warning"),
+                    sprintf(_("The rpc connection (%s) specified for '%s:%s' is invalid! Error was: %s."),
+                        bold($value),bold($class),bold($name), bold($connection->get_error())),
+                    WARNING_DIALOG);
+
+        }
+        
+        return($connection->success());
+    }
+
+
     /*! \brief      Constructs a new jsonRPC handle which is connected to a given URL.
      *              It can either connect using a rpc method or via auth method digest.
      *  @param      object      The gosa configuration object (class_config)