From: hickert Date: Fri, 11 Apr 2008 13:09:02 +0000 (+0000) Subject: Updated FAI package handling X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3a5b5df5228aa8af3cd61b3311720879799f9f3b;p=gosa.git Updated FAI package handling -Fixed package selection git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10359 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/fai/admin/fai/class_faiPackage.inc b/gosa-plugins/fai/admin/fai/class_faiPackage.inc index a44ffd345..b299e7c40 100644 --- a/gosa-plugins/fai/admin/fai/class_faiPackage.inc +++ b/gosa-plugins/fai/admin/fai/class_faiPackage.inc @@ -215,7 +215,7 @@ class faiPackage extends plugin /* + was pressed to open the package dialog */ if(isset($_POST['Addpkg']) && $this->acl_is_writeable("FAIpackage")){ - $this->dialog = new faiPackageEntry($this->config, $this->dn,$this->list,$this->usedPackages); + $this->dialog = new faiPackageEntry($this->config, $this->FAIdebianRelease,$this->usedPackages); $this->is_dialog =true; } @@ -302,6 +302,7 @@ class faiPackage extends plugin /* Display dialog */ if($this->is_dialog){ + $this->dialog->save_object(); return $this->dialog->execute(); } @@ -441,7 +442,7 @@ class faiPackage extends plugin if($this->buffer === NULL || !count($this->buffer)){ $this->buffer = array(); $q = new gosaSupportDaemon(); - $attrs = array("distribution", "package","version", "section", "description", "timestamp","template=''"); + $attrs = array("distribution", "package","version", "section", "description", "timestamp"); $ret = $q->FAI_get_packages($this->FAIdebianRelease,$attrs); if($q->is_error()){ msg_dialog::display(_("Service infrastructure"),msgPool::siError($q->get_error()),ERROR_DIALOG); diff --git a/gosa-plugins/fai/admin/fai/class_faiPackageEntry.inc b/gosa-plugins/fai/admin/fai/class_faiPackageEntry.inc index 15ba4cfce..4d4dd3b35 100644 --- a/gosa-plugins/fai/admin/fai/class_faiPackageEntry.inc +++ b/gosa-plugins/fai/admin/fai/class_faiPackageEntry.inc @@ -6,30 +6,52 @@ class faiPackageEntry extends plugin var $ignore_account= TRUE; var $attributes = array(); var $objectclasses= array(); - var $pkgs = array(); + var $pkgs = array(); - var $buffer = array(); - var $categories = array(); - var $searchStrPKG = ""; - var $selected = array(); + var $package_sections = array(); + var $searchStrPKG = "*"; + var $selected = array(); /* Array with available class names */ var $FAIAllclasses = array(); + var $FAIdebianRelease =""; - function faiPackageEntry (&$config, $dn= NULL,$pkgs,$selected=array()) + function faiPackageEntry (&$config,$release, $used_packages=array()) { - plugin::plugin ($config, $dn); - - $this->pkgs=$pkgs; + plugin::plugin ($config, NULL); - if(session::is_set('searchStrPKG')){ - $this->searchStrPKG = session::get('searchStrPKG'); - } - $this->selected=$selected; + $this->FAIdebianRelease = $release; + $this->selected = $used_packages; + $this->initializeSections(); + + /* Get old search filter, if there is one*/ + $this->searchStrPKG = _("Please enter your search string here"); + if(session::is_set("searchStrPKG")){ + $this->searchStrPKG = session::get("searchStrPKG"); + } + } - $this->searchStrPKG= _("Please enter your search string here"); + + /*! \brief Load all release seactions from GOsa support daemon + */ + function initializeSections() + { + $this->package_sections = array(); + $q = new gosaSupportDaemon(); + $ret = $q->FAI_get_packages($this->FAIdebianRelease,array("distinct section")); + if($q->is_error()){ + msg_dialog::display(_("Service infrastructure"),msgPool::siError($q->get_error()),ERROR_DIALOG); + }else{ + foreach($ret as $entry){ + $this->package_sections[array_pop($entry)] = TRUE; + } + } } + + /*! \brief Create HTML for this plugin. + @return String The html code for this plugin. + */ function execute() { /* Call parent execute */ @@ -39,111 +61,56 @@ class faiPackageEntry extends plugin $smarty = get_smarty(); $display = ""; - $divlist = new divlist("PackageEntry"); - $divlist->SetPluginMode(); - $divlist->SetSummary(_("This list displays all assigned package names for this repository settings.")); - $divlist->SetEntriesPerPage(0); - $divlist->SetHeight("650px;"); - $divlist->SetHeader(array(array("string" => " ", "attach" => "style='text-align:center;width:20px;'"), - array("string" => "Name", "attach" => "style='width:180px;'"), - array("string" => "Version", "attach" ), - array("string" => "Description", "attach" => "style='width:240px;border-right:0px;text-align:left;'"))); - if(isset($_GET['search'])){ - $this->searchStrPKG= $_GET['search']."*"; - } - - $pkgs= $this->pkgs; - - unset($this->categories); - foreach($pkgs as $name => $entry){ - $cat = $entry[2]; - if(!empty($cat)){ - if(!isset($this->categories[$cat])){ - $this->categories[$cat] = true; - } - if(isset($_POST['chkchange'])){ - $this->searchStrPKG = $_POST['searchStrPKG']; - if(isset($_POST['CAT'.$cat])){ - $this->categories[$cat]=true; - }else{ - $this->categories[$cat]=false; - } - } - } - } - - $this->searchStrPKG = preg_replace("/^\+/","",$this->searchStrPKG); - if(empty($this->searchStrPKG)){ - $this->searchStrPKG = "*"; - } - - @ksort($this->categories); - -$CHKS = ""; + /* Create section checkboxes + */ + $Section_boxes = "
"; $i = 0; - if(is_array($this->categories)) - foreach($this->categories as $cat => $selected){ + foreach($this->package_sections as $cat => $selected){ if($i == 3){ - $CHKS .=""; + $Section_boxes .=""; $i = 0; } - $i ++ ; if($selected){ - $CHKS .=""; + $Section_boxes .=""; }else{ - $CHKS .=""; - } - } - $CHKS .= "
 ".$cat."  ".$cat."  ".$cat." 
"; - - - foreach($_POST as $name => $value){ - if(preg_match("/^wasonpage_/i",$name)){ - $name = preg_replace("/^wasonpage_/","",$name); - $n =base64_decode($name); - - if(isset($_POST['use_'.$name])){ - $this->selected[$n] = $n; - }else{ - if(isset($this->selected[$n])){ - unset($this->selected[$n]); - } - } - + $Section_boxes .=" ".$cat." "; } + $i ++ ; } + $Section_boxes .= ""; - /* Prepare search filter */ - $search_str = preg_replace("/\\\\\*/",".*",normalizePreg($this->searchStrPKG)); - + /* Create List && fill it with packages + */ $cnt = 0; - foreach($pkgs as $pkg){ - if($cnt > 200) { - msg_dialog::display(_("Error"), _("Search returned too many results - showing the first 200 matches, only!"), ERROR_DIALOG); - break; - } - if((preg_match("/^".$search_str."/i",$pkg[0]))|| - (preg_match("/^".$search_str."/i",$pkg[3]))){ - if($this->categories[$pkg[2]]){ - if(in_array($pkg[0],$this->selected)){ - $check = " checked "; - }else{ - $check = ""; - } - $cnt ++ ; - $chkbox = " - "; - $divlist->AddEntry(array(array("string"=>$chkbox, "attach" => "style='text-align:center;width:20px;'"), - array("string"=>$pkg[0], "attach" => "style='width:180px;'"), - array("string"=>htmlentities($pkg[1])), - array("string"=>htmlentities($pkg[3]), "attach" => "style='width:221px;border-right:0px;text-align:left;'"))); - } + $this->reload(); + $divlist = new divlist("PackageEntry"); + $divlist->SetPluginMode(); + $divlist->SetSummary(_("This list displays all assigned package names for this repository settings.")); + $divlist->SetEntriesPerPage(0); + $divlist->SetHeight("650px;"); + $divlist->SetHeader(array(array("string" => " ", "attach" => "style='text-align:center;width:20px;'"), + array("string" => "Name", "attach" => "style='width:180px;'"), + array("string" => "Version", "attach" ), + array("string" => "Description", "attach" => "style='width:240px;border-right:0px;text-align:left;'"))); + + foreach($this->pkgs as $pkg){ + if(in_array($pkg['PACKAGE'],$this->selected)){ + $check = " checked "; + }else{ + $check = ""; } + $chkbox = " + "; + $divlist->AddEntry(array(array("string"=>$chkbox, "attach" => "style='text-align:center;width:20px;'"), + array("string"=>$pkg['PACKAGE'], "attach" => "style='width:180px;'"), + array("string"=>htmlentities($pkg['VERSION'])), + array("string"=>htmlentities($pkg['DESCRIPTION']), "attach" => "style='width:221px;border-right:0px;text-align:left;'"))); } - session::set('searchStrPKG',$this->searchStrPKG); - $smarty->assign("CHKS" , $CHKS); + $smarty->assign("Section_boxes" , $Section_boxes); $smarty->assign("searchStrPKG" , $this->searchStrPKG); $smarty->assign("faihead" , ""); $smarty->assign("failist" , $divlist->DrawList()); @@ -157,9 +124,12 @@ $CHKS = " $value){ if(preg_match("/^wasonpage_/i",$name)){ $name = preg_replace("/^wasonpage_/","",$name); @@ -175,17 +145,43 @@ $CHKS = "
searchStrPKG = get_post("searchStrPKG"); + } + if(isset($_GET['search'])){ + $this->searchStrPKG= $_GET['search']."*"; + } + if(empty($this->searchStrPKG)){ + $this->searchStrPKG = "*"; + } + session::set('searchStrPKG',$this->searchStrPKG); } - /* Check supplied data */ - function check() + + /*! \brief Reload list of displayed packages + */ + function reload() { - /* Call common method to give check the hook */ - $message= plugin::check(); - - return ($message); + $this->pkgs = array(); + $q = new gosaSupportDaemon(); + $filter = preg_replace("/\*/","%",$this->searchStrPKG); + $attrs = array("distribution", "package","version", "section", "description", "timestamp"); + $ret = $q->FAI_get_packages($this->FAIdebianRelease,$attrs,$filter); + if($q->is_error()){ + msg_dialog::display(_("Service infrastructure"),msgPool::siError($q->get_error()),ERROR_DIALOG); + }else{ + foreach($ret as $attr){ + $this->pkgs[$attr['PACKAGE']] = $attr; + } + } } + + /*! \brief Return all selected packages + @return Array All selected package names + */ function save() { return($this->selected); diff --git a/gosa-plugins/fai/admin/fai/faiPackageEntry.tpl b/gosa-plugins/fai/admin/fai/faiPackageEntry.tpl index 615f931cf..552958e4b 100644 --- a/gosa-plugins/fai/admin/fai/faiPackageEntry.tpl +++ b/gosa-plugins/fai/admin/fai/faiPackageEntry.tpl @@ -33,7 +33,7 @@

- {$CHKS} + {$Section_boxes}
@@ -43,7 +43,7 @@
+ title='{t}Regular expression for matching object names{/t}'>