From fe95d5e320f51425f310d462c2eba489c4fb53b1 Mon Sep 17 00:00:00 2001 From: psc Date: Tue, 12 Apr 2011 08:38:35 +0000 Subject: [PATCH] Make package filters for sections work (#6576) - Add support to FAI_get_packages function to filter by section, by adding a new attribute exclude_sections which allows the specification of an array with sections as keys (and arbitrary values). (This way its possible to create the array with array_filter and the existing package_sections array in class_faiPackageEntry) - Extend class_faiPackageEntry to hand the list of unselected sections to FAI_get_packages - Extend class_faiPackageEntry to keep the state of the section selection on page reload git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@20706 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../include/class_gosaSupportDaemon.inc | 15 +++++++++++- .../fai/admin/fai/class_faiPackageEntry.inc | 24 +++++++++++++++---- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/trunk/gosa-core/include/class_gosaSupportDaemon.inc b/trunk/gosa-core/include/class_gosaSupportDaemon.inc index af297df05..e88725235 100644 --- a/trunk/gosa-core/include/class_gosaSupportDaemon.inc +++ b/trunk/gosa-core/include/class_gosaSupportDaemon.inc @@ -280,7 +280,7 @@ class gosaSupportDaemon } - public function FAI_get_packages($release,$attrs,$package,$from=-1,$to=-1) + public function FAI_get_packages($release,$attrs,$package,$from=-1,$to=-1, $exclude_sections=array()) { $ret = array(); @@ -305,6 +305,18 @@ class gosaSupportDaemon /* If no package is given, search for all */ if(!count($package)) $package = array("%"); + /* If no section is given, search for all */ + $section_filter = ""; + if(count($exclude_sections)) { + $section_filter = 'AND'; + foreach ($exclude_sections as $section => $value) { + $section_filter .= "ne
" + .$section + ."
"; + } + $section_filter .= "
"; + } + /* Create limit tag */ if($from == -1){ $limit =""; @@ -325,6 +337,7 @@ class gosaSupportDaemon OR ".$pkgs." + ".$section_filter." ". $limit. ""; diff --git a/trunk/gosa-plugins/fai/admin/fai/class_faiPackageEntry.inc b/trunk/gosa-plugins/fai/admin/fai/class_faiPackageEntry.inc index f86f89a96..0ee58e8eb 100644 --- a/trunk/gosa-plugins/fai/admin/fai/class_faiPackageEntry.inc +++ b/trunk/gosa-plugins/fai/admin/fai/class_faiPackageEntry.inc @@ -79,18 +79,21 @@ class faiPackageEntry extends plugin "; $i = 0; foreach($this->package_sections as $cat => $selected){ + $Section_boxes .= ""; + if($i == 2){ $Section_boxes .=""; $i = 0; } if($selected){ - $Section_boxes .=""; }else{ - $Section_boxes .=""; } $i ++ ; + } $Section_boxes .= "
 ".$cat."  ".$cat." 
"; @@ -129,7 +132,6 @@ class faiPackageEntry extends plugin array("string"=>htmlentities($desc), "attach" => "style='border-right:0px;text-align:left;'"))); } - $smarty->assign("Section_boxes" , $Section_boxes); $smarty->assign("searchStrPKG" , $this->searchStrPKG); $smarty->assign("faihead" , ""); @@ -163,6 +165,15 @@ class faiPackageEntry extends plugin } } + if(preg_match("/^CAT/i", $name)) { + $key = "use$name"; + $section = preg_replace("/^CAT/i", "", $name); + if (isset($_POST[$key])) { + $this->package_sections[$section] = TRUE; + }else { + $this->package_sections[$section] = FALSE; + } + } } /* Get Posted search filter @@ -187,8 +198,13 @@ class faiPackageEntry extends plugin $this->pkgs = array(); $q = new gosaSupportDaemon(); $filter = preg_replace("/\*/","%",array($this->searchStrPKG)); + + /* Determine filter sections */ + $cb = create_function('$a', 'return $a != TRUE;'); + $exclude_sections = array_filter($this->package_sections, $cb); + $attrs = array("distribution", "package","version", "section", "description", "timestamp"); - $ret = $q->FAI_get_packages($this->FAIdebianRelease,$attrs,$filter,0,200); + $ret = $q->FAI_get_packages($this->FAIdebianRelease,$attrs,$filter,0,200, $exclude_sections); if($q->is_error()){ msg_dialog::display(_("Service infrastructure"),msgPool::siError($q->get_error()),ERROR_DIALOG); }else{ -- 2.30.2