Code

Added option to setup, to enable compressed output of html stuff
[gosa.git] / setup / class_setupStep_Ldap.inc
index 53ffb364b470eccffb7c3bc97b08ecf8fd68e576..9b5f670eafdfbaf412ef674874fdbb70b750eff5 100644 (file)
@@ -81,6 +81,12 @@ class Step_Ldap extends setup_step
       $smarty->assign("resolved_users_count",count($tmp));
       $smarty->assign("resolve_filter",$this->resolve_filter);
     }
+
+    $base_to_append = $this->base;
+    if(strlen($base_to_append) > 20){
+      $base_to_append = substr($base_to_append,0,17)."...";
+    }
+    $smarty->assign("base_to_append",$base_to_append);
     return($smarty -> fetch (get_template_path("../setup/setup_ldap.tpl")));
   }
 
@@ -130,9 +136,23 @@ class Step_Ldap extends setup_step
 
   function save_object()
   {
+    $reset = FALSE;
     foreach($this->attributes as $attr){
       if(isset($_POST[$attr])){
-        $this->$attr = $_POST[$attr];
+        if(in_array($attr,array("base","connection")) && $this->$attr != get_post($attr)){
+          $reset = TRUE;
+        }
+        $this->$attr = get_post($attr);
+      }
+    }
+
+    if($reset){
+      $this->parent->disable_steps_from(($this->parent->step_name_to_id(get_class($this))) +1);
+      $attr = @LDAP::get_naming_contexts($this->connection);
+      if(is_array($attr) && !in_array(get_post("base"),$attr)){
+        if(isset($attr[0])){
+          $this->base = $attr[0];
+        }
       }
     }
 
@@ -147,24 +167,17 @@ class Step_Ldap extends setup_step
     $this->dialog = $this->resolve_user;
  
     if(isset($_POST['resolve_filter'])){
-      $this->resolve_filter = $_POST['resolve_filter'];
+      $this->resolve_filter = get_post('resolve_filter');
     }
 
     if(isset($_POST['use_selected_user'])){
 
       if(isset($_POST['admin_to_use'])){
-        $this->admin = base64_decode($_POST['admin_to_use']);
+        $this->admin = base64_decode(get_post('admin_to_use'));
         $this->resolve_user = false;
       }
     }
 
-    $this->get_connection_status();
-    if($this->bind_id && !empty($this->admin) && !empty($this->base)){
-      $this->is_completed =TRUE;
-    }else{
-      $this->is_completed =FALSE;
-    }
-
     if(isset($_POST['append_base_to_admin_dn'])){
       $this->append_base_to_admin_dn = TRUE;
     }else{
@@ -180,6 +193,14 @@ class Step_Ldap extends setup_step
     }else{
       $this->admin = $this->admin_given;
     }
+
+    $this->get_connection_status();
+    if($this->bind_id && !empty($this->admin) && !empty($this->base)){
+      $this->is_completed =TRUE;
+    }else{
+      $this->is_completed =FALSE;
+    }
+
   }
 }