Code

Updated role listing
[gosa.git] / gosa-core / include / class_config.inc
index abebcb0ada92a95193256e0c1b185c5fc66260d1..d696c19e155bdea925bf73741920c75d64b14462 100644 (file)
@@ -104,7 +104,6 @@ class config  {
 
   function parse($filename)
   {
-
     $this->data = array(
         "TABS"      => array(), 
         "LOCATIONS" => array(), 
@@ -124,6 +123,11 @@ class config  {
       msg_dialog::display(_("Configuration error"), $msg, FATAL_ERROR_DIALOG);
       exit;
     }
+
+    // Default schemacheck to "true"
+    if(!isset($this->data['MAIN']['SCHEMACHECK'])){
+      $this->data['MAIN']['SCHEMACHECK'] = "true";
+    }
   }
 
   function tag_open($parser, $tag, $attrs)
@@ -293,9 +297,6 @@ class config  {
   {
     $this->current= $this->data['LOCATIONS'][$name];
 
-    if (!isset($this->current['SAMBAVERSION'])){
-      $this->current['SAMBAVERSION']= 3;
-    }
     if (!isset($this->current['USERRDN'])){
       $this->current['USERRDN']= "ou=people";
     }
@@ -616,31 +617,30 @@ class config  {
     }
 
     /* Get samba servers from LDAP, in case of samba3 */
-    if ($this->current['SAMBAVERSION'] == 3){
-      $this->data['SERVERS']['SAMBA']= array();
-      $ldap->cd ($this->current['BASE']);
-      $ldap->search ("(objectClass=sambaDomain)");
-      while ($attrs= $ldap->fetch()){
-        $this->data['SERVERS']['SAMBA'][$attrs['sambaDomainName'][0]]= array( "SID" =>"","RIDBASE" =>"");
-        if(isset($attrs["sambaSID"][0])){
-          $this->data['SERVERS']['SAMBA'][$attrs['sambaDomainName'][0]]["SID"]  = $attrs["sambaSID"][0];
-        }
-        if(isset($attrs["sambaAlgorithmicRidBase"][0])){
-          $this->data['SERVERS']['SAMBA'][$attrs['sambaDomainName'][0]]["RIDBASE"] = $attrs["sambaAlgorithmicRidBase"][0];
-        }
+    $this->data['SERVERS']['SAMBA']= array();
+    $ldap->cd ($this->current['BASE']);
+    $ldap->search ("(objectClass=sambaDomain)");
+    while ($attrs= $ldap->fetch()){
+      $this->data['SERVERS']['SAMBA'][$attrs['sambaDomainName'][0]]= array( "SID" =>"","RIDBASE" =>"");
+      if(isset($attrs["sambaSID"][0])){
+        $this->data['SERVERS']['SAMBA'][$attrs['sambaDomainName'][0]]["SID"]  = $attrs["sambaSID"][0];
+      }
+      if(isset($attrs["sambaAlgorithmicRidBase"][0])){
+        $this->data['SERVERS']['SAMBA'][$attrs['sambaDomainName'][0]]["RIDBASE"] = $attrs["sambaAlgorithmicRidBase"][0];
       }
+    }
 
-      /* 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);
-        } else {
-          $this->data['SERVERS']['SAMBA']['DEFAULT']= array(
-              "SID" => $this->current["SAMBASID"],
-              "RIDBASE" => $this->current["SAMBARIDBASE"]);
-        }
+    /* 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);
+      } else {
+        $this->data['SERVERS']['SAMBA']['DEFAULT']= array(
+            "SID" => $this->current["SAMBASID"],
+            "RIDBASE" => $this->current["SAMBARIDBASE"]);
       }
     }
+    
   }
 
 
@@ -1005,6 +1005,63 @@ class config  {
       return(TRUE);
     }
   }
+
+  /* Returns true if snapshots are enabled, and false if it is disalbed
+     There will also be some errors psoted, if the configuration failed */
+  function snapshotEnabled()
+  {
+    if($this->get_cfg_value("enableSnapshots") == "true"){
+
+      /* Check if the snapshot_base is defined */
+      if ($this->get_cfg_value("snapshotBase") == ""){
+
+        /* Send message if not done already */
+        if(!session::is_set("snapshotFailMessageSend")){
+          session::set("snapshotFailMessageSend",TRUE);
+          msg_dialog::display(_("Configuration error"),
+              sprintf(_("The snapshot functionality is enabled, but the required variable '%s' is not set."),
+                      "snapshotBase"), ERROR_DIALOG);
+        }
+        return(FALSE);
+      }
+
+      /* Check if the snapshot_base is defined */
+      if (!is_callable("gzcompress")){
+
+        /* Send message if not done already */
+        if(!session::is_set("snapshotFailMessageSend")){
+          session::set("snapshotFailMessageSend",TRUE);
+          msg_dialog::display(_("Configuration error"),
+              sprintf(_("The snapshot functionality is enabled, but the required compression module is missing. Please install '%s'."),"php5-zip / php5-gzip"), ERROR_DIALOG);
+        }
+        return(FALSE);
+      }
+
+      /* check if there are special server configurations for snapshots */
+      if ($this->get_cfg_value("snapshotURI") != ""){
+
+        /* check if all required vars are available to create a new ldap connection */
+        $missing = "";
+        foreach(array("snapshotURI","snapshotAdminDn","snapshotAdminPassword","snapshotBase") as $var){
+          if($this->get_cfg_value($var) == ""){
+            $missing .= $var." ";
+
+            /* Send message if not done already */
+            if(!session::is_set("snapshotFailMessageSend")){
+              session::set("snapshotFailMessageSend",TRUE);
+              msg_dialog::display(_("Configuration error"),
+                  sprintf(_("The snapshot functionality is enabled, but the required variable '%s' is not set."),
+                    $missing), ERROR_DIALOG);
+            }
+            return(FALSE);
+          }
+                    }
+            }
+            return(TRUE);
+    }
+    return(FALSE);
+  }
+
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: