Code

Updated setup
[gosa.git] / setup / class_setupStep_Ldap.inc
index 91752060436ee16e59e04680242058cd44e5d213..229941f77ed9648553b9a9e2ef68ecbb3d2c6322 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,16 +136,27 @@ class Step_Ldap extends setup_step
 
   function save_object()
   {
+    $reset = FALSE;
     foreach($this->attributes as $attr){
       if(isset($_POST[$attr])){
-
         if(in_array($attr,array("base","connection")) && $this->$attr != get_post($attr)){
-          $this->parent->disable_steps_from($this->parent->step_name_to_id(get_class($this)) + 1);
+          $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];
+        }
+      }
+    }
+
+
     if(isset($_POST['resolve_user_x'])){
       $this->resolve_user = !$this->resolve_user;
     }