Code

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