1 <?php
3 class filterFAIPackages {
5 static function query($base, $scope, $filter, $attributes, $category, $objectStorage= "")
6 {
7 $filter= preg_replace('/\*/', '', $filter);
8 $pkgs = array();
9 $q = new gosaSupportDaemon();
10 $filter = array("%$filter%");
11 $attrs = array("distribution", "package","version", "section", "description", "timestamp");
12 $release = session::get('packageSelect_Release');
13 $ret = $q->FAI_get_packages($release,$attrs,$filter,0,200);
14 if($q->is_error()){
15 msg_dialog::display(_("Service infrastructure"),msgPool::siError($q->get_error()),ERROR_DIALOG);
16 }else{
17 foreach($ret as $attr){
19 $attr['objectClass'] = "FAKE_OC__FaiPackage";
20 $attr['DESCRIPTION'] = base64_decode($attr['DESCRIPTION']);
22 $item = array();
23 $item['dn'] = "dn=".$attr['PACKAGE'].",".$attr['DISTRIBUTION'].",".$base;
24 $item['count']= 0;
25 foreach($attr as $key => $value){
26 $item['count']++;
27 $item[] = $key;
28 $item[$key] = array('count' => 1, $value);
29 }
30 $pkgs[] = $item;
31 }
32 }
34 return(filterLDAPBlacklist::filterByBlacklist($pkgs));
35 }
37 static function filterByBlacklist($entries)
38 {
39 if(session::is_set('filterBlacklist')){
40 $blist = session::get('filterBlacklist');
41 foreach($blist as $attr_name => $attr_values){
42 foreach($attr_values as $match){
43 foreach($entries as $id => $entry){
44 if(isset($entry[$attr_name])){
45 $test = $entry[$attr_name];
46 if(!is_array($test)) $test = array($test);
47 if(in_array($match, $test)) unset($entries[$id]);
48 }
49 }
50 }
51 }
52 }
53 return(array_values($entries));
54 }
56 function save()
57 {
58 $act = $this->detectPostActions();
59 $headpage = $this->getHeadpage();
60 if(!isset($act['targets'])) return(array());
61 $ret = array();
62 foreach($act['targets'] as $dn){
63 $ret[] = $headpage->getEntry($dn);
64 }
65 return($ret);
66 }
68 }
70 ?>