Code

Fixed save_object
[gosa.git] / plugins / admin / systems / class_workstationStartup.inc
index ad9077747ed8082abc1b2b88b64c8e4e44e5e396..88e4d38c79874a6407dc76556dfed5729f732056 100644 (file)
@@ -43,7 +43,6 @@ class workstartup extends plugin
 
   
   /* FAI class selection */
-  var $FAIinherit                  = false; 
   var $InheritedFAIclass           = array();
   var $InheritedFAIrelease         = "";
   var $InheritedFAIdebianMirror    = "auto";
@@ -119,8 +118,11 @@ class workstartup extends plugin
       natcasesort($this->FAIclasses);
     }
 
-    $this->FAIclassInfo = $tmp2;
-
+    if(isset($tmp2)){
+      $this->FAIclassInfo = $tmp2;
+    } else {
+      $this->FAIclassInfo = array();
+    }
 
     /* Build up an array like this one :
         [$url]['SERVER'] = 'srv1-002';
@@ -269,7 +271,7 @@ class workstartup extends plugin
     $ldap->cd($this->config->current['BASE']);
     $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".$this->dn."))");
     if ($ldap->count() == 1){
-      $map= array("gotoLdapServer","gotoBootKernel","FAIclass","FAIdebianMirror");
+      $map= array("gotoLdapServer","FAIclass","FAIdebianMirror");
       $attrs= $ldap->fetch();
 
       foreach ($map as $name){
@@ -320,7 +322,7 @@ class workstartup extends plugin
     }
 
     if(count($this->FAIclass)==0 && $this->FAIrelease == ""){
-      $this->FAIinherit =true;
+      $this->FAIdebianMirror = "inherited";
     }
   }
 
@@ -397,6 +399,8 @@ class workstartup extends plugin
   function selectFriendlyClasses(){
     $tmp=array();
 
+    if($this->FAIdebianMirror == "inherited") return($tmp);
+
     /* check if the current release exists,
         else select the first one ..
      */
@@ -608,11 +612,13 @@ class workstartup extends plugin
       if((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){
         print_red(_("You must specify a valid mount point."));
       }else{
-        $a_share = $this->gotoAvailableShares[$_POST['gotoShareSelection']];
-        $s_mount = $_POST['gotoShareMountPoint'];
-        /* Preparing the new assignment */
-        $this->gotoShares[$a_share['name']."|".$a_share['server']]=$a_share;
-        $this->gotoShares[$a_share['name']."|".$a_share['server']]['mountPoint']=$s_mount;
+        if(count($this->gotoAvailableShares)){
+          $a_share = $this->gotoAvailableShares[$_POST['gotoShareSelection']];
+          $s_mount = $_POST['gotoShareMountPoint'];
+          /* Preparing the new assignment */
+          $this->gotoShares[$a_share['name']."|".$a_share['server']]=$a_share;
+          $this->gotoShares[$a_share['name']."|".$a_share['server']]['mountPoint']=$s_mount;
+        }
       }
     }
 
@@ -624,6 +630,7 @@ class workstartup extends plugin
     }
 
     $smarty->assign("gotoShares",$this->printOutAssignedShares());
+    $smarty->assign("gotoSharesCount",count($this->printOutAssignedShares()));
     $smarty->assign("gotoShareKeys",array_flip($this->printOutAssignedShares()));
     $smarty->assign("gotoBootKernels",$this->gotoBootKernels);
 
@@ -658,9 +665,9 @@ class workstartup extends plugin
 
       $SelectBoxLdapServer->AddEntry(
           array(
-            array("string"=>$display),
             array("string"=>"<input type='radio' name='gotoLdapServer' value='".$key."' ".$use.">",
-                  "attach"=>"style='border-right:0px;'")
+                  "attach"=>"style='border-left:0px;'"),
+            array("string"=>$display)
             ));
     }    
 
@@ -677,14 +684,12 @@ class workstartup extends plugin
       $smarty->assign($val."ACL", chkacl($this->acl, $val));
     }
 
-    $smarty->assign("FAIinherit",$this->FAIinherit);
     $smarty->assign("FAIdebianMirrors",$this->getFAIdebianMirrors());
     $smarty->assign("FAIreleases",$this->getFAIreleases());
     $smarty->assign("FAIrelease",$this->FAIrelease);
     $smarty->assign("FAIclasses",$this->selectFriendlyClasses());
     $smarty->assign("FAIclassesKeys",array_flip($this->selectFriendlyClasses()));
     $smarty->assign("FAIclassKeys",$this->FAIclass);
-    $smarty->assign("InheritedFAIdebianMirror",$this->InheritedFAIdebianMirror);
     $smarty->assign("InheritedFAIrelease",$this->InheritedFAIrelease);
     
     $div = new divSelectBox("WSFAIscriptClasses");
@@ -696,7 +701,7 @@ class workstartup extends plugin
 
     $i = 1;
 
-    if($this->FAIinherit){
+    if($this->FAIdebianMirror == "inherited"){
       $tmp = $this->InheritedFAIclass;
     }else{
       $tmp = $this->FAIclass;
@@ -704,7 +709,7 @@ class workstartup extends plugin
 
     foreach($tmp as $class){
 
-      if($this->FAIinherit){
+      if($this->FAIdebianMirror == "inherited"){
         $str = "";
       }else{
         if($i==1){
@@ -780,6 +785,7 @@ class workstartup extends plugin
   function getFAIdebianMirrors()
   {
     $ret = array();
+    $ret['inherited']="["._("inherited")."]";
     $ret['auto']=_("automatic");
     $secs  = array();
 
@@ -816,6 +822,8 @@ class workstartup extends plugin
   {
     $ret = array();
 
+    if($this->FAIdebianMirror == "inherited") return(array());
+
     if(!isset($this->FAIServRepConfig[$this->FAIdebianMirror])){
       $this->FAIdebianMirror = "auto";
     }
@@ -879,13 +887,6 @@ class workstartup extends plugin
       $this->customParameters= $_POST["customParameters"];
     }
 
-    if(isset($_POST['WorkstationStarttabPosted'])){
-      if(isset($_POST['FAIinherit'])){
-        $this->FAIinherit = true;
-      }else{
-        $this->FAIinherit = false;
-      }
-    }
   }
 
 
@@ -961,7 +962,7 @@ class workstartup extends plugin
     
     $str = "";
 
-    if($this->FAIinherit){
+    if($this->FAIdebianMirror == "inherited"){
   
       $this->attrs['FAIclass'] = $this->attrs['FAIrelease'] =  $this->attrs['FAIdebianMirror'] = array(); 
 
@@ -1002,8 +1003,14 @@ class workstartup extends plugin
       $this->FAIdebianMirror = "";
     }
    
+    /* Get FAIstate from object, the generic tab could have changed it during execute */
+    $ldap= $this->config->get_ldap_link();
+    $ldap->cd($this->dn);
+    $ldap->cat($this->dn,array("FAIstate"));
+    $checkFAIstate = $ldap->fetch();
+
     /* Remove FAI objects if no FAI class is selected */ 
-    if(count($this->FAIclass)==0){
+    if((count($this->FAIclass)==0) && (!isset($checkFAIstate['FAIstate']))){
       $tmp = array();
       foreach($this->attrs['objectClass'] as $class){
         if($class != "FAIobject"){
@@ -1024,8 +1031,6 @@ class workstartup extends plugin
     }
     $this->attrs['gotoShare']=$tmp;
 
-    $ldap= $this->config->get_ldap_link();
-    $ldap->cd($this->dn);
     $this->cleanup();
     $ldap->modify ($this->attrs);