From 0b5894a23ae1fc3e91166e8614d28be65f429080 Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 10 Oct 2005 08:25:03 +0000 Subject: [PATCH] reworked faiPackage package management, better reading, new repository setup dialog git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1540 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/fai/class_askClassName.inc | 19 ++- plugins/admin/fai/class_faiPackage.inc | 171 ++++++++++++-------- plugins/admin/fai/class_faiPackageEntry.inc | 46 +----- plugins/admin/fai/faiPackage.tpl | 24 +-- 4 files changed, 123 insertions(+), 137 deletions(-) diff --git a/plugins/admin/fai/class_askClassName.inc b/plugins/admin/fai/class_askClassName.inc index edb9d277d..d7cb25485 100644 --- a/plugins/admin/fai/class_askClassName.inc +++ b/plugins/admin/fai/class_askClassName.inc @@ -3,17 +3,17 @@ class askClassName extends plugin { /* CLI vars */ - var $cli_summary= "Manage server basic objects"; - var $cli_description= "Some longer text\nfor help"; - var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser"); + var $cli_summary = "Manage server basic objects"; + var $cli_description = "Some longer text\nfor help"; + var $cli_parameters = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser"); /* attribute list for save action */ - var $ignore_account = TRUE; - var $attributes = array(); - var $objectclasses = array("whatever"); + var $ignore_account = TRUE; + var $attributes = array(); + var $objectclasses = array("whatever"); - var $objectClass = false; - var $forbidden =array(); + var $objectClass = false; + var $forbidden = array(); var $ClassName = ""; var $ClassAlreadyExists = false; @@ -31,7 +31,7 @@ class askClassName extends plugin $display= ""; /* The faifilter contais - The base for all fai objects + * The base for all fai objects */ $faifilter = $_SESSION['faifilter']; @@ -49,7 +49,6 @@ class askClassName extends plugin FALSE, $objecttypes['dn'], array("cn","description","objectClass","FAIclass"),TRUE); foreach($res2 as $object){ - /* skip class names with this name */ if(in_array($this->objectClass,$object['objectClass'])){ $delete[] = $object['cn'][0]; diff --git a/plugins/admin/fai/class_faiPackage.inc b/plugins/admin/fai/class_faiPackage.inc index c48e29ec3..918dab1d8 100644 --- a/plugins/admin/fai/class_faiPackage.inc +++ b/plugins/admin/fai/class_faiPackage.inc @@ -42,13 +42,14 @@ class faiPackage extends plugin var $releases = array(); // All possible releases var $sections = array(); // All section types - var $list = array(); + var $list = NULL; var $mirrors = array(); // The combination of server/release/section var $confDir = ""; var $usedPackages = array(); - + var $buffer = NULL; var $strID =""; + var $newDialogShown =false; function faiPackage ($config, $dn= NULL) { @@ -71,6 +72,18 @@ class faiPackage extends plugin }else{ $this->usedPackages = array(); } + + unset($this->attrs['FAIdebianSection']['count']); + if((isset($this->attrs['FAIdebianSection']))&&(is_array($this->attrs['FAIdebianSection']))){ + $this->FAIdebianSection = array(); + foreach($this->attrs['FAIdebianSection'] as $sec){ + $this->FAIdebianSection[$sec]=$sec; + } + } + + if((isset($this->attrs['FAIdebianSection']))&&(is_string($this->attrs['FAIdebianSection']))){ + $this->FAIdebianSection=array($this->attrs['FAIdebianSection']=>$this->attrs['FAIdebianSection']) ; + } $this->confDir = CONFIG_DIR."/fai/"; $this->FAIpackage = array(); } @@ -81,6 +94,29 @@ class faiPackage extends plugin $smarty= get_smarty(); $display= ""; + if((!$this->is_account)&&(!$this->newDialogShown)){ + + if($this->dialog==NULL){ + $this->genMirror(); + $this->dialog = new faiPackageNew($this->config, $this->dn,$this->mirrors,$this->servers,$this->sections,$this->releases); + $this->is_dialog =true; + } + + if(isset($_POST['SaveObjectNew'])){ + $this->FAIdebianRelease = $this->dialog->FAIdebianRelease; + $this->FAIdebianSection = $this->dialog->FAIdebianSection; + $this->FAIdebianMirror = $this->dialog->FAIdebianMirror; + unset($this->dialog); + $this->dialog = false; + $this->is_dialog=false; + $this->newDialogShown = true; + } + + if($this->dialog){ + $display=$this->dialog->execute(); + return($display); + } + } $disableRelease = false; $disableMirror = false; $disableOptions = false; @@ -91,76 +127,29 @@ class faiPackage extends plugin $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; - $this->sections=array("---"); - }elseif(empty($this->FAIdebianSection)){ - $disableRelease = $disableMirror = $disableOptions = true; - }elseif(empty($this->FAIdebianMirror)){ - $disableRelease = $disableSection = $disableOptions = true; - }else{ - $disableRelease = $disableSection = true; - } - $this->genMirror(); + /* check servers matching release and section settings */ $availableServer = array(); foreach($this->mirrors as $mir){ - if(($mir['release'] == $this->FAIdebianRelease)&&($mir['section']==$this->FAIdebianSection)){ - $availableServer[$mir['mirror']]=$mir['mirror']; + 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']; + } + } } } - - if(($disableMirror==false)&&(count($availableServer)==0)){ - $this->FAIdebianRelease = $this->FAIdebianSection = $this->FAIdebianMirror = ""; - $disableSection = $disableMirror = $disableOptions = true; - $disableRelease = false; - } - - if(count($availableServer)==0){ - $availableServer=array("---"); - } - - $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->strID = $this->confDir.$this->FAIdebianMirror."/".$this->FAIdebianRelease."/".$this->FAIdebianSection; - if(!$disableOptions){ - if(!isset($this->list[$this->strID])){ - $tmp = new faiPackageEntry($this->config, $this->dn,$this->strID,$this->usedPackages); - $this->list[$this->strID]=$tmp->genPkgs(); - } + if($this->list==NULL){ + $this->list=$this->genPkgs(); } if(isset($_POST['Addpkg'])){ - $this->dialog = new faiPackageEntry($this->config, $this->dn,$this->strID,$this->usedPackages); - $this->dialog->buffer[$this->strID]= $this->list[$this->strID]; + $this->dialog = new faiPackageEntry($this->config, $this->dn,$this->list,$this->usedPackages); $this->is_dialog =true; } @@ -206,12 +195,17 @@ class faiPackage extends plugin return $this->dialog->execute(); } + $strsec = ""; + foreach($this->FAIdebianSection as $sec){ + $strsec .= $sec." "; + } + $smarty->assign("mirrors" ,$availableServer); $smarty->assign("mirror" ,$this->FAIdebianMirror); $smarty->assign("releases",$this->releases); $smarty->assign("release" ,$this->FAIdebianRelease); $smarty->assign("sections",$this->sections); - $smarty->assign("section" ,$this->FAIdebianSection); + $smarty->assign("section" ,$strsec); $smarty->assign("usedPackages",$this->printUsedPackages()); $display.= $smarty->fetch(get_template_path('faiPackage.tpl', TRUE)); return($display); @@ -251,10 +245,6 @@ class faiPackage extends plugin $this->releases[$release]=$release; $this->sections[$section]=$section; - if(empty($this->FAIdebianRelease)){ - $this->sections= array("---"); - } - $arr=array(); $arr['mirror'] = $mirror; $arr['release']= $release; @@ -320,8 +310,8 @@ class faiPackage extends plugin $a_ret=array(); if(is_array($this->usedPackages)) { foreach($this->usedPackages as $usedName){ - if(isset($this->list[$this->strID][$usedName][1])){ - $a_ret[$usedName] = $usedName." [".$this->list[$this->strID][$usedName][1]."]"; + if(isset($this->list[$usedName][1])){ + $a_ret[$usedName] = $usedName." [".$this->list[$usedName][1]."]"; }else{ $a_ret[$usedName] = $usedName; } @@ -330,6 +320,42 @@ class faiPackage extends plugin return($a_ret); } + function genPkgs(){ + /* Generate a list off available packages for this mirror, section and release + */ + /* Only read this file if it wasn't read before */ + if($this->buffer==NULL){ + $this->buffer=array(); + $a_ret = array(); + foreach($this->FAIdebianSection as $sec){ + $strID= "/etc/gosa/fai/".$this->FAIdebianMirror."/".$this->FAIdebianRelease."/".$sec; + + if(!is_file($strID)){ + print_red(sprintf(_("Package file don't exists '%s'."),$strID)); + return(array()); + } + $fp = fopen($strID,"r"); + + /* Parse every line and create an array */ + while(!feof($fp)){ + $str= fgets($fp,512); + $stra= split("\|",$str); + if(count($stra)==4){ + $a_ret[$stra[0]] = $stra; + } + } + fclose($fp); + /* Save our Data, to avoid reading it again */ + } + $this->buffer = $a_ret; + ksort($a_ret); + return($a_ret); + }else{ + return $this->buffer[$strID]; + } + } + + /* Save to LDAP */ function save() { @@ -341,6 +367,11 @@ class faiPackage extends plugin foreach($this->usedPackages as $pkg => $obj){ $this->attrs['FAIpackage'][] = $pkg; } + + $this->attrs['FAIdebianSection'] = array(); + foreach($this->FAIdebianSection as $sec){ + $this->attrs['FAIdebianSection'][] = $sec; + } $ldap->cat($this->dn); if($ldap->count()!=0){ diff --git a/plugins/admin/fai/class_faiPackageEntry.inc b/plugins/admin/fai/class_faiPackageEntry.inc index c5c53d20d..f57ec2e14 100644 --- a/plugins/admin/fai/class_faiPackageEntry.inc +++ b/plugins/admin/fai/class_faiPackageEntry.inc @@ -11,7 +11,7 @@ class faiPackageEntry extends plugin var $ignore_account= TRUE; var $attributes = array(); var $objectclasses= array(); - var $strID = ""; + var $pkgs = array(); var $buffer = array(); var $categories = array(); @@ -21,15 +21,15 @@ class faiPackageEntry extends plugin /* Array with available class names */ var $FAIAllclasses = array(); - function faiPackageEntry ($config, $dn= NULL,$strID=false,$selected=array()) + function faiPackageEntry ($config, $dn= NULL,$pkgs,$selected=array()) { plugin::plugin ($config, $dn); - $this->strID = $strID; + + $this->pkgs=$pkgs; if(isset($_SESSION['searchStrPKG'])){ $this->searchStrPKG=$_SESSION['searchStrPKG']; } - $this->selected=$selected; } @@ -50,8 +50,9 @@ class faiPackageEntry extends plugin if(isset($_GET['search'])){ $this->searchStrPKG= $_GET['search']."*"; } + + $pkgs= $this->pkgs; - $pkgs = $this->genPkgs(); unset($this->categories); foreach($pkgs as $name => $entry){ $cat = $entry[2]; @@ -169,41 +170,6 @@ class faiPackageEntry extends plugin { return($this->selected); } - - /* Generate listbox friendly SubObject list - */ - function genPkgs(){ - /* Generate a list off available packages for this mirror, section and release - */ - $strID = $this->strID; // This var contains the path to the parsed package file - - /* Open the packelist */ - $fp = fopen($strID,"r"); - $a_ret = array(); - $this->buffer = array(); - /* Only read this file if it wasn't read before */ - if(!isset($this->buffer[$strID])){ - $str = ""; - /* Parse every line and create an array */ - while(!feof($fp)){ - $str= fgets($fp,512); - $stra= split("\|",$str); - if(count($stra)==4){ - $a_ret[$stra[0]] = $stra; - } - } - /* Save our Data, to avoid reading it again */ - $this->buffer[$strID]=$a_ret; - - ksort($a_ret); - - return($a_ret); - }else{ - return $this->buffer[$strID]; - } - } - - } // 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 60e2f15c9..0521f5997 100644 --- a/plugins/admin/fai/faiPackage.tpl +++ b/plugins/admin/fai/faiPackage.tpl @@ -30,28 +30,18 @@ @@ -61,10 +51,10 @@
- - - + {$release}
- - - + {$section}
- {html_options options=$mirrors selected=$mirror} - +
@@ -80,9 +70,9 @@ {html_options options=$usedPackages}
- - - + + + -- 2.30.2