Code

Added FAIprofile selection for Workstations
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 17 Oct 2005 09:13:01 +0000 (09:13 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 17 Oct 2005 09:13:01 +0000 (09:13 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1580 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_workstationStartup.inc
plugins/admin/systems/workstationStartup.tpl

index 6a0406689a5d95926492710656cb83041688a833..f9548a12c6657a4bb99e2be759f3da5c2ac758c2 100644 (file)
@@ -17,7 +17,10 @@ class workstartup extends plugin
   var $gotoFilesystem= array();
   var $gotoTerminalPath= "";
   var $FAIstatus= "";
-  var $FAIclass= "";
+  var $FAIclass     = array();
+  var $FAIclasses   = array();
+  var $FAIclassInfo = array();
+
 
   /* attribute list for save action */
   var $attributes= array("gotoLdapServer", "gotoBootKernel", "gotoKernelParameters", "FAIclass", "FAIstatus", "gotoShare");
@@ -83,9 +86,82 @@ class workstartup extends plugin
     $this->gotoShareSelections= $config->getShareList(true);
     $this->gotoAvailableShares= $config->getShareList(false);
 
+    $ldap = $this->config->get_ldap_link();
+    $ldap->search("(objectClass=FAIprofile)",array("*"));
+    while($attr = $ldap->fetch()){
+      $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
+      $base =  "ou=fai,".preg_replace("/^.*ou=fai,/","",$attr['dn']);
+      $cn   = $attr['cn'][0];
+      $tmp[$cn] = $base;
+    }
+
+    foreach($tmp as $cn => $base){
+
+      $ldap->cd($base);
+      $ldap->search("(&(objectClass=*)(cn=".$cn."))",array("objectClass","cn"));
+      while($attr = $ldap->fetch()){
+  
+        if(in_array('FAIpackageList',$attr['objectClass'])){
+          $tmp2[$cn]['FAIpackageList']['obj']   = 'FAIpackageList'; 
+          $tmp2[$cn]['FAIpackageList']['kzl']   = 'P'; 
+        }
+        if(in_array('FAItemplate',$attr['objectClass'])){
+          $tmp2[$cn]['FAItemplate']['obj']      = 'FAItemplate'; 
+          $tmp2[$cn]['FAItemplate']['kzl']      = 'T'; 
+        }
+        if(in_array('FAIvariable',$attr['objectClass'])){
+          $tmp2[$cn]['FAIvariable']['obj']      = 'FAIvariable'; 
+          $tmp2[$cn]['FAIvariable']['kzl']      = 'V'; 
+        }
+        if(in_array('FAIscript',$attr['objectClass'])){
+          $tmp2[$cn]['FAIscript']['obj']        = 'FAIscript'; 
+          $tmp2[$cn]['FAIscript']['kzl']        = 'S'; 
+        }
+        if(in_array('FAIhook',$attr['objectClass'])){
+          $tmp2[$cn]['FAIhook']['obj']          = 'FAIhook'; 
+          $tmp2[$cn]['FAIhook']['kzl']          = 'H'; 
+        }
+        if(in_array('FAIpartitionTable',$attr['objectClass'])){
+          $tmp2[$cn]['FAIpartitionTable']['obj']= 'FAIpartitionTable'; 
+          $tmp2[$cn]['FAIpartitionTable']['kzl']= 'Pt'; 
+        }
+      }
+    }
+
+    $this->FAIclassInfo = $tmp2;
+
+    if(isset($this->attrs['FAIclass'])){
+      $tmp = array();
+      $tmp2 = $this->attrs['FAIclass'];
+      unset($tmp2['count']);
+      foreach($tmp2 as $class){
+        $tmp[$class] = $class;
+      }
+      $this->FAIclass = $tmp;
+    }
+
+    if(!is_array($this->FAIclass)){
+      $this->FAIclass = array();
+    }
+
+
     $this->orig_dn= $this->dn;
   }
 
+  function selectFriendlyClasses(){
+    $tmp=array();
+    foreach($this->FAIclasses as $class){
+      $str    = "";
+      if(isset($this->FAIclassInfo[$class])){
+        foreach($this->FAIclassInfo[$class] as $objs){
+          $str .= $objs['kzl']." "; 
+        }
+      }
+    $tmp[$class] = $class."&nbsp; [".$str."]";
+    }
+  return($tmp);
+  }
+
   function execute()
   {
     /* Do we need to flip is_account state? */
@@ -93,6 +169,7 @@ class workstartup extends plugin
       $this->is_account= !$this->is_account;
     }
 
+
     /* Do we represent a valid terminal? */
     if (!$this->is_account && $this->parent == NULL){
       $display= "<img alt=\"\" src=\"images/stop.png\" align=middle>&nbsp;<b>".
@@ -114,6 +191,28 @@ class workstartup extends plugin
       }
     }
 
+    /* FAI class management */
+    
+    if((isset($_POST['AddClass']))&&(isset($_POST['FAIclassesSel']))){
+      $this->FAIclass[$_POST['FAIclassesSel']]=$_POST['FAIclassesSel'];
+    }
+
+
+    if((isset($_POST['DelClass']))&&(isset($_POST['FAIclassSel']))){
+      if(isset($this->FAIclass[$_POST['FAIclassSel']])){
+        unset($this->FAIclass[$_POST['FAIclassSel']]);
+      }
+    }
+
+
+
+
+
+
+
+
+
+
     /* Show main page */
     $smarty= get_smarty();
 
@@ -159,10 +258,15 @@ class workstartup extends plugin
     }
 
     /* Values */
-    foreach(array("gotoBootKernel", "customParameters", "gotoShare") as $val){
+    foreach(array("gotoBootKernel", "customParameters", "gotoShare","FAIclasses","FAIclass") as $val){
       $smarty->assign($val, $this->$val);
       $smarty->assign($val."ACL", chkacl($this->acl, $val));
     }
+   
+    
+    $smarty->assign("FAIclasses",$this->selectFriendlyClasses());
+    $smarty->assign("FAIclassesKeys",array_flip($this->selectFriendlyClasses()));
+    $smarty->assign("FAIclassKeys",$this->FAIclass);
 
     /* Radio button group */
     if (preg_match("/G/", $this->bootmode)) {
@@ -182,7 +286,7 @@ class workstartup extends plugin
     }
 
     /* ACL's */
-    foreach (array("gotoKernelParameters", "gotoModules", "gotoFilesystem") as $value){
+    foreach (array("gotoKernelParameters", "gotoModules", "gotoFilesystem","FAIclass") as $value){
       $smarty->assign($value."ACL", chkacl($this->acl, "$value"));
     }
 
@@ -268,6 +372,12 @@ class workstartup extends plugin
       $this->gotoKernelParameters.= " o ".$this->customParameters;
     }
 
+    $tmp = array();
+    foreach($this->FAIclass as $class){
+      $tmp[] = $class;
+    }
+    $this->FAIclass = $tmp;
+
     plugin::save();
 
     /* Add missing arrays */
@@ -278,13 +388,19 @@ class workstartup extends plugin
       }
       if(!isset($this->attrs["$val"])) $this->attrs["$val"]=array();
     }
-
     /* Strip out 'default' values */
     if ($this->attrs['gotoLdapServer'] == "default"){
       unset ($this->attrs['gotoLdapServer']);
     }
 
+    $tmp = array();
+    foreach($this->FAIclass as $class){
+      $tmp[] = $class;
+    }
+    $this->FAIclass = $tmp;
     /* Write back to ldap */
+    
+
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->dn);
     $ldap->modify($this->attrs);
index 48c75bb36116e71452bc43c18fdf523473d7fb9e..3c0bd3edfbb0be8fd1f0624d352497c9228a206e 100644 (file)
   </td>
   
   <td style="vertical-align:top;">
-    {t}Installation server{/t} [.........]<br>
-    <br>
     {t}Assigned FAI classes{/t}<br>
-    [..........................]<br>
-    [..........................]<br>
-    [..........................]<br>
-    [..........................]<br>
-    [Add] [Remove]
+               <select name="FAIclassSel" {$FAIclassACL} multiple style="width:200px;height:50px;">
+        {html_options values=$FAIclass output=$FAIclassKeys}
+        <option disabled>&nbsp;</option>
+               </select>       
+    <br>
+               <select name="FAIclassesSel" {$FAIclassACL}>
+        {html_options values=$FAIclassesKeys output=$FAIclasses}
+        <option disabled>&nbsp;</option>
+               </select>       
+               <input name="AddClass" value="{t}Add{/t}" type="submit"> 
+               <input name="DelClass" value="{t}Delete{/t}" type="submit"> 
   </td>
  </tr>
 </table>