X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=plugins%2Fadmin%2Ffai%2Fclass_faiPackageNew.inc;h=b3330346b43bc76c8d0e4bf050d999836aebfdd2;hb=90cb0cbd940168e234d506e42644e52fc7af5c4d;hp=1d162737066919855643b165267a703e79656b06;hpb=7f41be34724ec4d6ee2c4eba8ef0ef66e1473793;p=gosa.git
diff --git a/plugins/admin/fai/class_faiPackageNew.inc b/plugins/admin/fai/class_faiPackageNew.inc
index 1d1627370..b3330346b 100644
--- a/plugins/admin/fai/class_faiPackageNew.inc
+++ b/plugins/admin/fai/class_faiPackageNew.inc
@@ -12,189 +12,139 @@ class faiPackageNew extends plugin
var $attributes = array();
var $objectclasses = array();
- var $mirrors = array(); // The possible mirror,release and section combinations
- var $servers = array(); // All available server
var $sections = array(); // All sections
var $releases = array(); // Releases
- var $FAIdebianRelease = ""; // The selected release
- var $FAIdebianSection = array(); // selected section
- var $FAIdebianMirror = ""; // selected mirror
-
+ var $FAIdebianRelease = ""; // The selected release
+ var $FAIdebianSection = array(); // selected section
var $obj;
- function faiPackageNew ($config, $dn= NULL,$mirrors,$servers,$sections,$releases)
+ function faiPackageNew ($config, $dn= NULL)
{
plugin::plugin ($config, $dn);
- $this->mirrors = $mirrors;
- $this->servers = $servers;
- $this->sections = $sections;
- $this->releases = $releases;
-
- foreach($this->sections as $sec){
- $this->sections[$sec] =false;
- }
}
function execute()
{
- /* Fill templating stuff */
- $smarty = get_smarty();
+ /* Call parent execute */
+ plugin::execute();
$display = "";
-
- // reset grayout options
- $disableRelease = false;
- $disableMirror = false;
- $disableContinue = false;
- $disableSection = false;
-
- /* Post handling for Section, Release and Mirror Setup */
- if(isset($_POST['SetRepository'])){
- if((isset($_POST['FAIdebianReleaseS']))&&(!empty($_POST['FAIdebianReleaseS']))){
- $this->FAIdebianRelease = $_POST['FAIdebianReleaseS'];
- }
- if((isset($_POST['FAIdebianMirrorS']))&&(!empty($_POST['FAIdebianMirrorS']))){
- $this->FAIdebianMirror = $_POST['FAIdebianMirrorS'];
- }
-
- foreach($this->sections as $sec => $val){
- if(isset($_POST[$sec])){
- $this->sections[$sec]=true;
- $this->FAIdebianSection[$sec]=$sec;
- }else{
- $this->sections[$sec]=false;
- }
- }
-
+ $smarty = get_smarty();
+ $atr = $this->getServerInfos();
+ $releases= array();
+ foreach($atr as $release => $sections){
+ $releases[$release]=$release;
+ }
+ if(!empty($this->FAIdebianRelease)){
+ $sections = $atr[$this->FAIdebianRelease] ;
+ }else{
+ $sections = array();
}
- /* Grayout settings */
- if(empty($this->FAIdebianRelease)){
- $disableSection = $disableMirror = $disableContinue = true;
- }elseif(empty($this->FAIdebianSection)){
- $disableRelease = $disableMirror = $disableContinue = true;
- }elseif(empty($this->FAIdebianMirror)){
- $disableRelease = $disableSection = $disableContinue = true;
+ /* Fill templating stuff */
+ if((empty($this->FAIdebianRelease))||(count($this->FAIdebianSection)==0)){
+ $smarty->assign("goon"," disabled ");
}else{
- $disableRelease = $disableSection = true;
+ $smarty->assign("goon"," ");
}
- /* check servers matching release and section settings */
- $availableServer = array();
- foreach($this->mirrors as $mir){
-
- /* Check if release and section match */
- if($mir['release'] == $this->FAIdebianRelease){
- $pass = true;
-
- foreach($this->FAIdebianSection as $sec){
-
- /* If a mirror match, attach */
- if($sec != $mir['section']){
- $pass = false;
- }
+ $smarty->assign("releases" ,$releases);
+ $smarty->assign("release" ,$this->FAIdebianRelease);
+ $smarty->assign("sections",$this->generateSections($sections));
- /* Save all matching */
- if($pass){
- $availableServer[$mir['mirror']]=$mir['mirror'];
- }
+ $display.= $smarty->fetch(get_template_path('faiPackageNew.tpl', TRUE));
+ return($display);
+ }
+
+ function generateSections($secs)
+ {
+ $str = "";
+ if(is_array($secs)){
+ sort($secs);
+ $secs= array_unique($secs);
+ foreach($secs as $section){
+ if(in_array($section,$this->FAIdebianSection)){
+ $str .= "".$section."
";
+ }else{
+ $str .= "".$section."
";
}
+ $str .="";
}
}
+ return($str);
+ }
- /* If no servers matching the settings, allow setting release and section again */
- if(($disableMirror==false)&&(count($availableServer)==0)){
- $this->FAIdebianRelease = $this->FAIdebianMirror = "";
- $this->FAIdebianSection = array();
- $disableSection = $disableMirror = $disableContinue = true;
- $disableRelease = false;
+ function getServerInfos()
+ {
+ $ret = array();
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(objectClass=FAIrepositoryServer)",array("*"));
+ while($attrs = $ldap->fetch()){
+ if(isset($attrs['FAIrepository'])){
+ for($i =0 ; $i < $attrs['FAIrepository']['count']; $i++){
+ $obj = $attrs['FAIrepository'][$i];
+ $tmp = split("\|",$obj);
+ if(count($tmp)==4){
+ foreach(split(",",$tmp[3]) as $sec){
+ if(!empty($sec)){
+ $ret[$tmp[2]][] = $sec;
+ }
+ }
+ }
+ }
+ }
}
+ return($ret);
+ }
- /* Create checkboxes for the avaliable sections */
- $strsec = "
".$sec." | "; - }else{ - $strsec .= "".$sec." | "; + + foreach($_POST as $name => $value){ + if(preg_match("/wasOnPage_/",$name)){ + $nm = preg_replace("/wasOnPage_/","",$name); + if(isset($_POST['section_'.$nm])){ + $this->FAIdebianSection[$nm] = $nm; + }else{ + if(isset($this->FAIdebianSection[$nm])){ + unset($this->FAIdebianSection[$nm]); + } + } } } } - $strsec .= "