Code

Applied in_array strict patches from trunk
[gosa.git] / gosa-core / include / class_config.inc
index 70bba3876a304e8e73a260726a38424114068750..f3b8907ab2b98387ae6c67760f7bdfdfea61c0df 100644 (file)
@@ -64,7 +64,7 @@ class config  {
     var $filename = "";
     var $last_modified = 0;
 
-    var $gosaUUID = "";
+    var $instanceUUID = "";
 
     private $jsonRPChandle = NULL; 
 
@@ -81,8 +81,6 @@ class config  {
         $this->parser = xml_parser_create();
         $this->basedir= $basedir;
 
-        $this->gosaUUID = uniqid();
-
         xml_set_object($this->parser, $this);
         xml_set_element_handler($this->parser, "tag_open", "tag_close");
 
@@ -93,12 +91,13 @@ class config  {
 
         // Load configuration registry
         $this->configRegistry = new configRegistry($this);
+        $this->registration = new GOsaRegistration($this);
     }
 
 
-    function getGOsaUUID()
+    function getInstanceUUID()
     {
-        return($this->gosaUUID);
+        return($this->instanceUUID);
     }    
 
 
@@ -186,6 +185,9 @@ class config  {
             if(isset($attrs['CONFIGVERSION'])){
                 $this->config_version = $attrs['CONFIGVERSION'];
             }
+            if(isset($attrs['INSTANCEUUID'])){
+                $this->instanceUUID = $attrs['INSTANCEUUID'];
+            }
         }
 
         /* Return if we're not in config section */
@@ -314,13 +316,24 @@ class config  {
     }
 
 
-    function getRpcHandle($url="", $user="", $pwd="", $digest = 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');
+        $username     = ($username !== NULL)     ? $username     : $this->get_cfg_value('core','gosaRpcUser');
+        $userPassword = ($userPassword !== NULL) ? $userPassword : $this->get_cfg_value('core','gosaRpcPassword');
+        $authModeDigest = $authModeDigest;
+    
         // Create jsonRPC handle on demand.
-        if(!isset($this->jsonRPChandle[$url][$user]) || !$this->jsonRPChandle[$url][$user]){
-            $this->jsonRPChandle[$url][$user] = new jsonRPC($this, $url, $user, $pwd, $digest);
+        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[$url][$user]);
     }
 
 
@@ -691,12 +704,15 @@ class config  {
 
         /* If no samba servers are found, look for configured sid/ridbase */
         if (count($this->data['SERVERS']['SAMBA']) == 0){
-            if (!isset($this->current["SAMBASID"]) || !isset($this->current["SAMBARIDBASE"])){
-                msg_dialog::display(_("Configuration error"), _("sambaSID and/or sambaRidBase missing in the configuration!"), ERROR_DIALOG);
+            $sambaSID = $this->get_cfg_value("core","sambaSID"); 
+            $sambaRIDBase = $this->get_cfg_value("core","sambaRidBase"); 
+            if (!isset($sambaSID) || !isset($sambaRIDBase)){ 
+                msg_dialog::display(_("Configuration error"), 
+                        _("sambaSID and/or sambaRidBase missing in the configuration!"), ERROR_DIALOG);
             } else {
                 $this->data['SERVERS']['SAMBA']['DEFAULT']= array(
-                        "SID" => $this->current["SAMBASID"],
-                        "RIDBASE" => $this->current["SAMBARIDBASE"]);
+                        "SID" => $sambaSID ,
+                        "RIDBASE" => $sambaRIDBase);
             }
         }
 
@@ -738,7 +754,7 @@ class config  {
             /* Detect department type */
             $type_data = array();
             foreach($types as $t => $data){
-                if(in_array($data['OC'],$attrs['objectClass'])){
+                if(in_array_strict($data['OC'],$attrs['objectClass'])){
                     $type_data = $data;
                     break;
                 }