From: hickert Date: Thu, 14 Oct 2010 12:02:04 +0000 (+0000) Subject: Added rpc connection settings check to the peroperty editor X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5dfc748bde5b2fe59c9cf9a6353802fa07e6d4cc;p=gosa.git Added rpc connection settings check to the peroperty editor git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20043 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/class_core.inc b/gosa-core/include/class_core.inc index 0b96b077e..73275f708 100644 --- a/gosa-core/include/class_core.inc +++ b/gosa-core/include/class_core.inc @@ -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), diff --git a/gosa-core/include/class_jsonRPC.inc b/gosa-core/include/class_jsonRPC.inc index f7b7a501f..689112171 100644 --- a/gosa-core/include/class_jsonRPC.inc +++ b/gosa-core/include/class_jsonRPC.inc @@ -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)