From 9131c26da07045177a123ff2008dc54f1943a5c2 Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 17 Oct 2005 09:13:01 +0000 Subject: [PATCH] Added FAIprofile selection for Workstations git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1580 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../systems/class_workstationStartup.inc | 124 +++++++++++++++++- plugins/admin/systems/workstationStartup.tpl | 18 ++- 2 files changed, 131 insertions(+), 11 deletions(-) diff --git a/plugins/admin/systems/class_workstationStartup.inc b/plugins/admin/systems/class_workstationStartup.inc index 6a0406689..f9548a12c 100644 --- a/plugins/admin/systems/class_workstationStartup.inc +++ b/plugins/admin/systems/class_workstationStartup.inc @@ -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."  [".$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= "\"\" ". @@ -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); diff --git a/plugins/admin/systems/workstationStartup.tpl b/plugins/admin/systems/workstationStartup.tpl index 48c75bb36..3c0bd3edf 100644 --- a/plugins/admin/systems/workstationStartup.tpl +++ b/plugins/admin/systems/workstationStartup.tpl @@ -32,14 +32,18 @@ - {t}Installation server{/t} [.........]
-
{t}Assigned FAI classes{/t}
- [..........................]
- [..........................]
- [..........................]
- [..........................]
- [Add] [Remove] + +
+ + + -- 2.30.2