Code

Updated license mangement
[gosa.git] / gosa-plugins / opsi / admin / opsiLicenses / class_filterOpsiLicense.inc
1 <?php
3 class filterOpsiLicense {
5   static function query($base, $scope, $filter, $attributes, $category, $objectStorage= "")
6   {
7     $config= session::global_get('config');
8     $si = new opsiLicenceHandler($config);
9     $res = $si->listPools();
10     $result = array();
11     if($si->is_error() || !is_array($res)){
12       $this->init_successfull = FALSE;
13       msg_dialog::display(_("Error"),msgPool::siError($si->get_error()),ERROR_DIALOG);
14       return;
15     }else{
17       // Reset the list of licenses
18       foreach($res as $item){
20         $item['objectClass'] = array('fake_opsiLicense');
22         // Fake an ldap entry, this enables ACL checks.
23         $entry = array();
24         $entry['dn'] = "opsi:cn=".$item['cn'][0].",".$config->current['BASE'];
25         foreach($item as $name => $value){
26           $entry[] = $name;
27           $entry[$name] = $value;
28         }
29         $entry['count'] = count($item);
30         $result[] = $entry;
31       }
32     }
33     return(filterACL::unifyResult($result));
34   }
36   static function unifyResult($result)
37   {
38     $res=array();
39     foreach($result as $entry){
40       if(!isset($res[$entry['dn']])){
41         $res[$entry['dn']]=$entry;
42       }
43     }
44     return(array_values($res)); 
45   }
46 }
48 ?>