X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Ffai%2Fclass_faiPackage.inc;h=de42cecfb929b592940532a6697e304d723fe129;hb=cc2de47023584285f289c222e64bd7c6aeb5a927;hp=b65a2b55a0443ad1464f0bcc2f6ce603a5e89aab;hpb=7ea785a2da84ad67ad6b664015a03a4a0cf596f3;p=gosa.git diff --git a/plugins/admin/fai/class_faiPackage.inc b/plugins/admin/fai/class_faiPackage.inc index b65a2b55a..de42cecfb 100644 --- a/plugins/admin/fai/class_faiPackage.inc +++ b/plugins/admin/fai/class_faiPackage.inc @@ -11,7 +11,7 @@ class faiPackage extends plugin var $ignore_account = TRUE; /* Attributes for this Object */ - var $attributes = array("cn","description","FAIpackage","FAIdebianSection","FAIdebianRelease","FAIdebianMirror"); + var $attributes = array("cn","description","FAIpackage","FAIdebianRelease","FAIdebianSection","FAIdebianMirror"); /* ObjectClasses for this Object*/ var $objectclasses = array("top","FAIclass","FAIpackageList","FAIrepository"); @@ -34,19 +34,17 @@ class faiPackage extends plugin var $dialog = NULL; // a dialog, e.g. new disk dialog var $SubObjects = array(); // All leafobjects of this object - var $FAIdebianSection = ""; // The selected section - var $FAIdebianRelease = ""; // selected release + var $FAIdebianRelease = ""; // The selected release + var $FAIdebianSection = ""; // selected section var $FAIdebianMirror = ""; // selected mirror var $servers = array(); // All available servers - var $sections = array(); // All possible sections - var $releases = array(); // All release types + var $releases = array(); // All possible releases + var $sections = array(); // All section types - var $disableRepository = false; - - var $mirrors = array(); // The combination of server/section/release + var $mirrors = array(); // The combination of server/release/section var $confDir = ""; - var $usedPackages = array(); + var $usedPackages = array(); function faiPackage ($config, $dn= NULL) { @@ -61,17 +59,13 @@ class faiPackage extends plugin $this->dn =$dn; } - if(isset($this->attrs['FAIdebianRelease'])){ - $this->disableRepository=true; - } - if(isset($this->attrs['FAIpackage'])){ unset($this->attrs['FAIpackage']['count']); foreach($this->attrs['FAIpackage'] as $pkg){ $this->usedPackages[$pkg] = $pkg; } }else{ - $this->usedPackages = array();; + $this->usedPackages = array(); } $this->confDir = CONFIG_DIR."/fai/"; $this->FAIpackage = array(); @@ -83,22 +77,70 @@ class faiPackage extends plugin $smarty= get_smarty(); $display= ""; + $disableRelease = false; + $disableMirror = false; + $disableOptions = false; + $disableSection = false; + /* Assign variables */ foreach($this->attributes as $attrs){ $smarty->assign($attrs,$this->$attrs); } + /* Post handling for Section, Release and Mirror Setup */ + if(isset($_POST['SetSection'])){ + $this->FAIdebianSection = $_POST['FAIdebianSectionS']; + } + if(isset($_POST['SetRelease'])){ + $this->FAIdebianRelease = $_POST['FAIdebianReleaseS']; + } + if(isset($_POST['SetMirror'])){ + $this->FAIdebianMirror = $_POST['FAIdebianMirrorS']; + } + + if(empty($this->FAIdebianRelease)){ + $disableSection = $disableMirror = $disableOptions = true; + }elseif(empty($this->FAIdebianSection)){ + $disableRelease = $disableMirror = $disableOptions = true; + }elseif(empty($this->FAIdebianMirror)){ + $disableRelease = $disableSection = $disableOptions = true; + }else{ + $disableRelease = $disableSection = true; + } + + $smarty->assign("ReleaseACL" , ""); + $smarty->assign("MirrorACL" , ""); + $smarty->assign("OptionACL" , ""); + $smarty->assign("SectionACL" , ""); + + if($disableOptions){ + $smarty->assign("OptionACL"," disabled "); + } + if($disableRelease){ + $smarty->assign("ReleaseACL"," disabled "); + } + if($disableMirror){ + $smarty->assign("MirrorACL"," disabled "); + } + if($disableSection){ + $smarty->assign("SectionACL"," disabled "); + } + $this->genMirror(); $availableServer = array(); foreach($this->mirrors as $mir){ - if(($mir['section'] == $this->FAIdebianSection)&&($mir['release']==$this->FAIdebianRelease)){ + if(($mir['release'] == $this->FAIdebianRelease)&&($mir['section']==$this->FAIdebianSection)){ $availableServer[$mir['mirror']]=$mir['mirror']; } } + if($disableMirror){ + $availableServer[$mir['mirror']]=array("---"); + } + if(isset($_POST['Addpkg'])){ - $this->dialog = new faiPackageEntry($this->config, $this->dn,$this->confDir.$this->mirror."/".$this->section."/".$this->release,$this->usedPackages); + $this->dialog = new faiPackageEntry($this->config, $this->dn,$this->confDir.$this->FAIdebianMirror."/".$this->FAIdebianRelease."/".$this->FAIdebianSection,$this->usedPackages); $this->is_dialog =true; } @@ -122,29 +164,19 @@ class faiPackage extends plugin $this->usedPackages = $use; $this->dialog = false; $this->is_dialog=false; - $this->disableRepository =true; } } if($this->is_dialog){ return $this->dialog->execute(); } - - if($this->disableRepository == true){ - $smarty->assign("mirrorACL" ," disabled "); - $smarty->assign("sectionACL" ," disabled "); - $smarty->assign("releaseACL" ," disabled "); - }else{ - $smarty->assign("mirrorACL" ,""); - $smarty->assign("sectionACL" ,""); - $smarty->assign("releaseACL" ,""); - } + $smarty->assign("mirrors" ,$availableServer); $smarty->assign("mirror" ,$this->FAIdebianMirror); - $smarty->assign("sections",$this->sections); - $smarty->assign("section" ,$this->FAIdebianSection); $smarty->assign("releases",$this->releases); $smarty->assign("release" ,$this->FAIdebianRelease); + $smarty->assign("sections",$this->sections); + $smarty->assign("section" ,$this->FAIdebianSection); $smarty->assign("usedPackages",$this->printUsedPackages()); $display.= $smarty->fetch(get_template_path('faiPackage.tpl', TRUE)); return($display); @@ -159,6 +191,10 @@ class faiPackage extends plugin /* Try to catch all available mirrors Possibly check if each server is reachable */ + + $this->servers= array(); + $this->releases=array(); + $this->sections=array(); $this->mirrors= array(); $fd = opendir($confDir); while($mirror = readdir($fd)){ @@ -167,33 +203,33 @@ class faiPackage extends plugin $mirrorDir = $confDir.$mirror."/"; $fe = opendir($mirrorDir); - while($section = readdir($fe)){ - if((is_dir($mirrorDir.$section))&&(($section != "." )&&($section!=".."))){ + while($release = readdir($fe)){ + if((is_dir($mirrorDir.$release))&&(($release != "." )&&($release!=".."))){ - $sectionDir = $mirrorDir.$section."/"; + $releaseDir = $mirrorDir.$release."/"; - $ff = opendir($sectionDir); - while($release = readdir($ff)){ - if((is_file($sectionDir.$release))&&(($release != "." )&&($release!="..")&&(!preg_match("/.*\.in$/",$release)))){ + $ff = opendir($releaseDir); + while($section = readdir($ff)){ + if((is_file($releaseDir.$section))&&(($section != "." )&&($section!="..")&&(!preg_match("/.*\.in$/",$section)))){ $this->servers[$mirror]=$mirror; - $this->sections[$section]=$section; $this->releases[$release]=$release; + $this->sections[$section]=$section; - if(empty($this->mirror)){ - $this->mirror= $mirror; + if(empty($this->FAIdebianRelease)){ + $this->servers= array("---"); } - if(empty($this->section)){ - $this->section = $section; + if(empty($this->FAIdebianSection)){ + $this->releases= array("---"); } - if(empty($this->release)){ - $this->release = $release; + if(empty($this->FAIdebianSection)){ + $this->FAIdebianSection = $section; } $arr=array(); $arr['mirror'] = $mirror; - $arr['section']= $section; - $arr['release']= $release; + $arr['release']= $release; + $arr['section']= $section; $this->mirrors[] = $arr ; } @@ -225,6 +261,7 @@ class faiPackage extends plugin */ function save_object() { + plugin::save_object(); foreach($this->attributes as $attrs){ if(isset($_POST[$attrs])){ @@ -238,8 +275,12 @@ class faiPackage extends plugin function check() { $message= array(); - - if((empty($this->FAIdebianSection))||(empty($this->FAIdebianRelease))||(empty($this->FAIdebianMirror))){ + + if(count($this->usedPackages)==0){ + $message[]=_("Please select a least one Package."); + } + + if((empty($this->FAIdebianRelease))||(empty($this->FAIdebianSection))||(empty($this->FAIdebianMirror))){ $message[]=_("Please choose a valid combination for your repository setup."); }