From: hickert Date: Fri, 9 Dec 2005 12:31:15 +0000 (+0000) Subject: Removed mirror from faiPackage X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8c09ec034d2549a50fd740d285c3b3e5849be1c0;p=gosa.git Removed mirror from faiPackage git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2272 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/fai/class_faiPackage.inc b/plugins/admin/fai/class_faiPackage.inc index 402404c8b..cb9b9f8d8 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","FAIdebianRelease","FAIdebianSection","FAIdebianMirror"); + var $attributes = array("cn","description","FAIpackage","FAIdebianRelease","FAIdebianSection"); /* ObjectClasses for this Object*/ var $objectclasses = array("top","FAIclass","FAIpackageList","FAIrepository"); @@ -38,7 +38,6 @@ class faiPackage extends plugin var $FAIdebianRelease = ""; // The selected release var $FAIdebianSection = ""; // selected section - var $FAIdebianMirror = ""; // selected mirror var $mirror = ""; // selected mirror var $servers = array(); // All available servers @@ -116,9 +115,6 @@ class faiPackage extends plugin } $this->confDir = CONFIG_DIR."/fai/"; $this->FAIpackage = array(); - - /* Extract mirror location */ - $this->mirror= preg_replace("!^[^/]+//([^/]+).*$!", '$1', $this->FAIdebianMirror); } function execute() @@ -131,8 +127,6 @@ class faiPackage extends plugin $smarty= get_smarty(); $display= ""; - $this->genMirror(); - /* Check if we exist already - no need to ask for revisions, etc. then */ if ($this->dn != "new"){ $this->newDialogShown= true; @@ -145,23 +139,16 @@ class faiPackage extends plugin $this->is_dialog =true; } - /* alert possible missconfigurations */ - if((count($this->releases)==0)||(count($this->servers)==0)||(count($this->sections)==0)){ - print_red(_("There is no useable package list defined.")); - } - /* Assign posible changes, for mirror combinations */ $this->dialog->save_object(); - $this->dialog->releases = $this->releases; - $this->dialog->servers = $this->servers; - $this->dialog->sections = $this->sections; - $this->dialog->mirrors = $this->mirrors; /* Assign Repository settings*/ if(isset($_POST['SaveObjectNew'])){ - $this->FAIdebianRelease = $this->dialog->FAIdebianRelease; - $this->FAIdebianSection = $this->dialog->FAIdebianSection; - $this->FAIdebianMirror = $this->dialog->FAIdebianMirror; + $obj = $this->dialog->save(); + + $this->FAIdebianSection = $obj['FAIdebianSection']; + $this->FAIdebianRelease = $obj['FAIdebianRelease']; + unset($this->dialog); $this->dialog = false; $this->is_dialog=false; @@ -180,27 +167,6 @@ class faiPackage extends plugin $smarty->assign($attrs,$this->$attrs); } - /* Set mirror if changed */ - if((isset($_POST['FAIdebianMirrorS']))&&(!empty($_POST['FAIdebianMirrorS']))){ - $this->FAIdebianMirror = $_POST['FAIdebianMirrorS']; - } - - /* check servers matching release and section settings */ - $availableServer = array(); - foreach($this->mirrors as $mir){ - if($mir['release'] == $this->FAIdebianRelease){ - $pass = true; - foreach($this->FAIdebianSection as $sec){ - if($sec != $mir['section']){ - $pass = false; - } - if($pass){ - $availableServer[$mir['mirror']]=$mir['mirror']; - } - } - } - } - /* Generate package list */ $this->list=$this->genPkgs(); @@ -239,7 +205,7 @@ class faiPackage extends plugin /* Configuration dialog open*/ if((isset($_POST['Conpkg']))&&(isset($_POST['usedPackages']))&&(!empty($_POST['usedPackages']))){ - $path = "/etc/gosa/fai/".preg_replace("#^[^/]+//([^/]+).*$#","\\1",$this->FAIdebianMirror)."/".$this->FAIdebianRelease."/debconf.d"; + $path = "/etc/gosa/fai/".$this->FAIdebianRelease."/debconf.d"; $pkg_config = array(); if(isset($this->ConfiguredPackages[$_POST['usedPackages']])){ $pkg_config = $this->ConfiguredPackages[$_POST['usedPackages']]; @@ -274,12 +240,7 @@ class faiPackage extends plugin } $smarty->assign("OptionsACL",""); - if(empty($this->FAIdebianMirror)){ - $smarty->assign("OptionsACL"," disabled "); - } - $smarty->assign("mirrors" ,$availableServer); - $smarty->assign("mirror" ,$this->FAIdebianMirror); $smarty->assign("releases",$this->releases); $smarty->assign("release" ,$this->FAIdebianRelease); $smarty->assign("sections",$this->sections); @@ -289,60 +250,6 @@ class faiPackage extends plugin return($display); } - function genMirror(){ - $confDir = $this->confDir; - if(!is_readable($confDir)){ - print_red(sprintf(_("Can't read configuration folder '%s'."),$confDir)); - }else{ - - /* 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)){ - if((is_dir($confDir.$mirror."/"))&&(($mirror != "." )&&($mirror!=".."))){ - - $mirrorDir = $confDir.$mirror."/"; - - $fe = opendir($mirrorDir); - while($release = readdir($fe)){ - if((is_dir($mirrorDir.$release))&&(($release != "." )&&($release!=".."))){ - - $releaseDir = $mirrorDir.$release."/"; - - $ff = opendir($releaseDir); - while($section = readdir($ff)){ - if((is_file($releaseDir.$section))&&(($section != "." )&&($section!="..")&&(!preg_match("/.*\.in$/",$section)))){ - - $this->servers[$mirror]=$mirror; - $this->releases[$release]=$release; - $this->sections[$section]=$section; - - $arr=array(); - $arr['mirror'] = $mirror; - $arr['release']= $release; - $arr['section']= $section; - - $this->mirrors[] = $arr ; - } - } - fclose($ff); - } - } - fclose($fe); - } - } - fclose($fd); - } - - - } - /* Delete me, and all my subtrees */ function remove_from_parent() @@ -377,7 +284,7 @@ class faiPackage extends plugin $message[]=_("Please select a least one Package."); } - if((empty($this->FAIdebianRelease))||(empty($this->FAIdebianSection))||(empty($this->FAIdebianMirror))){ + if((empty($this->FAIdebianRelease))||(empty($this->FAIdebianSection))){ $message[]=_("Please choose a valid combination for your repository setup."); } @@ -420,11 +327,10 @@ class faiPackage extends plugin $this->buffer=array(); $a_ret = array(); foreach($this->FAIdebianSection as $sec){ - $strID= "/etc/gosa/fai/".preg_replace("#^[^/]+//([^/]+).*$#","\\1",$this->FAIdebianMirror)."/".$this->FAIdebianRelease."/".$sec; + $strID= "/etc/gosa/fai/".$this->FAIdebianRelease."/".$sec; if(!is_file($strID)){ print_red(sprintf(_("Package file '%s' does not exist."),$strID)); - $this->FAIdebianMirror=""; unset($this->buffer); return(array()); } diff --git a/plugins/admin/fai/class_faiPackageNew.inc b/plugins/admin/fai/class_faiPackageNew.inc index 485e561cf..b90107a99 100644 --- a/plugins/admin/fai/class_faiPackageNew.inc +++ b/plugins/admin/fai/class_faiPackageNew.inc @@ -12,183 +12,115 @@ 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() { - /* Call parent execute */ - plugin::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'])){ - 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(); + foreach($atr as $release => $sections){ + $releases[$release]=$release; } - - /* Grayout settings */ - if(empty($this->FAIdebianRelease)){ - $disableSection = $disableMirror = $disableContinue = true; - }elseif(empty($this->FAIdebianSection)){ - $disableRelease = $disableMirror = $disableContinue = true; - }elseif(empty($this->FAIdebianMirror)){ - $disableRelease = $disableSection = true; + if(!empty($this->FAIdebianRelease)){ + $sections = $atr[$this->FAIdebianRelease] ; }else{ - $disableRelease = $disableSection = true; - } - - /* 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; - } - - /* Save all matching */ - if($pass){ - $availableServer[$mir['mirror']]=$mir['mirror']; - } - } - } + $sections = array(); } - /* 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; + /* Fill templating stuff */ + if((empty($this->FAIdebianRelease))||(count($this->FAIdebianSection)==0)){ + $smarty->assign("goon"," disabled "); + }else{ + $smarty->assign("goon"," "); } - /* Create checkboxes for the avaliable sections */ - $strsec = ""; - foreach($this->sections as $sec => $val){ - - /* Only add this section if it is supported by the selected release */ - $goon = false; - foreach($this->mirrors as $mir){ - - /* Is there a release with this section ? */ - if((($mir['release'] == $this->FAIdebianRelease )&&($mir['section'] == $sec))){ - $goon = true; - } - } + $smarty->assign("releases" ,$releases); + $smarty->assign("releaseKeys" ,array_flip($releases)); + $smarty->assign("release" ,$this->FAIdebianRelease); + $smarty->assign("sections",$this->generateSections($sections)); - if($goon){ - if($this->sections[$sec] == true ){ - $chk = " checked "; - }else{ - $chk = ""; - } + $display.= $smarty->fetch(get_template_path('faiPackageNew.tpl', TRUE)); + return($display); + } - /* Add disabled if needed */ - if($disableSection){ - $strsec .= ""; + function generateSections($secs) + { + $str = ""; + if(is_array($secs)){ + $rel = " onClick='document.mainform.submit();' "; + foreach($secs as $section){ + if(in_array($section,$this->FAIdebianSection)){ + $str .= "".$section."
"; }else{ - $strsec .= ""; + $str .= "".$section."
"; } } } - $strsec .= "
".$sec."".$sec."
"; - - /* Add --- to mirror selectbox if it is empty */ - if(count($availableServer)==0){ - $availableServer=array("---"); - } - - /* Tell smarty the grayout settigs */ - $smarty->assign("ReleaseACL" , ""); - $smarty->assign("MirrorACL" , ""); - $smarty->assign("ContinueACL" , ""); - $smarty->assign("SectionACL" , ""); + return($str); + } - if($disableContinue){ - $smarty->assign("ContinueACL"," disabled "); - } - if($disableRelease){ - $smarty->assign("ReleaseACL"," disabled "); - } - if($disableMirror){ - $smarty->assign("MirrorACL"," disabled "); - } - if($disableSection){ - $smarty->assign("SectionACL"," disabled "); + 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; + } + } + } + } + } } - - - $smarty->assign("DisSection",!empty($this->FAIdebianSection)); - $smarty->assign("DisRelease",!empty($this->FAIdebianRelease)); - - $smarty->assign("mirrors" ,$availableServer); - $smarty->assign("mirror" ,$this->FAIdebianMirror); - $smarty->assign("releases",$this->releases); - $smarty->assign("release" ,$this->FAIdebianRelease); - $smarty->assign("sections",$strsec); - $smarty->assign("section" ,$this->FAIdebianSection); - - $display.= $smarty->fetch(get_template_path('faiPackageNew.tpl', TRUE)); - return($display); + return($ret); } + /* Save data to object */ function save_object() { - if(isset($_POST['SetRepository'])){ - /* Post handling for Section, Release and Mirror Setup */ - if((isset($_POST['FAIdebianReleaseS']))&&(!empty($_POST['FAIdebianReleaseS']))){ - $this->FAIdebianRelease = $_POST['FAIdebianReleaseS']; + /* Post handling for Section, Release Setup */ + if((isset($_POST['FAIdebianReleaseS']))&&(!empty($_POST['FAIdebianReleaseS']))){ + $this->FAIdebianRelease = $_POST['FAIdebianReleaseS']; + } + + /* Get Sections */ + foreach($_POST as $name => $value){ + if(preg_match("/^section_/",$name)){ + $this->FAIdebianSection[$value] = $value; } - if((isset($_POST['FAIdebianMirrorS']))&&(!empty($_POST['FAIdebianMirrorS']))){ - $this->FAIdebianMirror = $_POST['FAIdebianMirrorS']; + } + + /* Remove all section that are not available at the currently selected server */ + $atr = $this->getServerInfos(); + foreach($this->FAIdebianSection as $section){ + if(!in_array($section,$atr[$this->FAIdebianRelease])){ + unset($this->FAIdebianSection[$section]); } } + } /* Check supplied data */ @@ -200,6 +132,7 @@ class faiPackageNew extends plugin function save() { + return(array("FAIdebianRelease"=>$this->FAIdebianRelease,"FAIdebianSection"=>$this->FAIdebianSection)); } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: diff --git a/plugins/admin/fai/faiPackage.tpl b/plugins/admin/fai/faiPackage.tpl index 61d76f256..99b946090 100644 --- a/plugins/admin/fai/faiPackage.tpl +++ b/plugins/admin/fai/faiPackage.tpl @@ -44,19 +44,6 @@ {$section} - - - - - - - - - diff --git a/plugins/admin/fai/faiPackageNew.tpl b/plugins/admin/fai/faiPackageNew.tpl index 3e54019e4..2325d3304 100644 --- a/plugins/admin/fai/faiPackageNew.tpl +++ b/plugins/admin/fai/faiPackageNew.tpl @@ -26,12 +26,11 @@ - + {html_options options=$releases values=$releaseKeys selected=$release} -{if $DisRelease neq false}

{t}Sections for this release{/t}:

@@ -39,30 +38,15 @@ {$sections} + -{/if} -{if $DisSection neq false} - - -

:

- - - - - -{/if} -{if $ContinueACL neq ""} - -{/if}

 

- +