3
class filterOpsiLicense {
5
static function query($base, $scope, $filter, $attributes, $category, $objectStorage= "")
8
if(!class_available('opsi')) return(array());
10
$config= session::global_get('config');
11
$ldap= $config->get_ldap_link(TRUE);
12
$flag= ($scope == "sub")?GL_SUBSEARCH:0;
13
$result= filterOpsiLicense::get_list($base, $filter, $attributes, $category, $objectStorage, $flag);
15
// Prepare filter and split it into attribute and value to search for
16
$filter=preg_replace("/\*/","",$filter);
18
if(!empty($filter) && preg_match("/=/", $filter)){
19
list($attr,$value) = preg_split("/=/", $filter);
24
foreach($result as $key => $entry){
25
if(!preg_match("/".$value."/i", $entry[$attr][0])){
31
return(filterACL::unifyResult($result));
34
static function get_list($base, $filter, $attributes, $category, $objectStorage, $flags= GL_SUBSEARCH)
36
$config= session::global_get('config');
37
$si = new opsiLicenceHandler($config);
39
if(!$si->enabled()) return(array());
41
$res = $si->listPools();
43
if($si->is_error() || !is_array($res)){
44
$this->init_successfull = FALSE;
45
msg_dialog::display(_("Error"),msgPool::siError($si->get_error()),ERROR_DIALOG);
49
// Reset the list of licenses
50
foreach($res as $item){
52
$item['objectClass'] = array('fake_opsiLicense');
54
// Fake an ldap entry, this enables ACL checks.
56
$entry['dn'] = "opsi:cn=".$item['cn'][0].",".$config->current['BASE'];
57
foreach($item as $name => $value){
59
$entry[$name] = $value;
61
$entry['count'] = count($item);
68
static function unifyResult($result)
71
foreach($result as $entry){
72
if(!isset($res[$entry['dn']])){
73
$res[$entry['dn']]=$entry;
76
return(array_values($res));