Code

Updated object movement.
[gosa.git] / setup / class_setup.inc
index 8400ce15f30be189206815ba6106bdfd39f20eff..f59d5f68bd0f93cdc040017aed37f9b79a63d285 100644 (file)
 
 require_once("class_setupStep.inc");
 
-class setup extends plugin
+class setup 
 {
 
-  var $i_steps  = 5;  // Number of setup steps 
+  var $i_steps  = 7;  // Number of setup steps 
   var $i_current= 1;  // Current step
   var $i_last   = 1;  // Last setup step;
   var $o_steps  = array(); 
@@ -34,7 +34,14 @@ class setup extends plugin
   {
     for($i = 1 ; $i <= $this->i_steps; $i ++ ){
       $class= "setup_step_".$i;
-      $this->o_steps[$i] = new $class();
+    
+      if(class_exists($class)){
+        $this->o_steps[$i] = new $class();
+      }else{
+        $this->o_steps[$i] = new setup_step();
+        trigger_error("Try to create class '".$class."' but it is not available, possibly you have forgotten to add the include in setup.php");
+      }
+      $this->o_steps[$i]->parent = $this;
     }
   }
 
@@ -60,14 +67,9 @@ class setup extends plugin
       $this->captured_values[$name] = $value;
     }
 
-    /* check if current setup step is completed now 
-        and activate the next step if possible */
-    for($i = 1 ; $i <= $this->i_steps ; $i ++ ){
-      if($this->o_steps[$i]->is_completed()){
-        if(isset($this->o_steps[($i+1)])){
-          $this->o_steps[($i+1)]->set_enabled();
-        }
-      }
+    /* Set parent */
+    foreach($this->o_steps as $key => $value){
+      $this->o_steps[$key]->parent = $this;
     }
 
     /* Check if image button requests next page */
@@ -83,6 +85,16 @@ class setup extends plugin
     /* Check if step was selected */
     if(isset($_GET['step']) || isset($_POST['next']) || isset($_POST['last'])){
 
+      /* check if current setup step is completed now 
+          and activate the next step if possible */
+      for($i = 1 ; $i <= $this->i_steps ; $i ++ ){
+        if($this->o_steps[$i]->is_completed()){
+          if(isset($this->o_steps[($i+1)])){
+            $this->o_steps[($i+1)]->set_enabled();
+          }
+        }
+      }
+
       if(isset($_GET['step'])){
         $step = $_GET['step'];
       }elseif(isset($_POST['next'])){
@@ -149,11 +161,11 @@ class setup extends plugin
     }else{
       $str.="   <img class='center' src='images/setup_step_back_gray.png' title='"._("Last step")."'>";
     }
-    if(isset($this->o_steps[$this->i_current +1]) && $this->o_steps[$this->i_current +1]->is_enabled()){
+#   if(isset($this->o_steps[$this->i_current +1]) && $this->o_steps[$this->i_current +1]->is_enabled()){
       $str.="   <input class='center' type='image' name='next' src='images/setup_step_forward.png'  title='"._("Next step")."'>";
-    }else{
-      $str.="   <img class='center' src='images/setup_step_forward_gray.png'  title='"._("Next step")."'>";
-    }
+#   }else{
+#     $str.="   <img class='center' src='images/setup_step_forward_gray.png'  title='"._("Next step")."'>";
+#   }
     $str.= "  </div>";
     $str.= "</div>";
     return ($str);