Code

updated templates
[gosa.git] / gosa-plugins / systems / admin / systems / class_filterOPSIHOSTS.inc
1 <?php
3 class filterOPSIHOSTS {
5   static function query($base, $scope, $filter, $attributes, $category, $objectStorage= "")
6   {
7     // Append opsi stuff ...
8     global $config;
9     $ui = get_userinfo();
10     $entries = array();
12     if(class_available('opsi') && $base == $config->current['BASE']){
14       // Explode filter into attribute and value to search for.
15       $attr = $value = "";
16       $filter = preg_replace("/\*/",".*",$filter);
17       if(preg_match("/=/", $filter)) {
18         list($fAttr,$fValue) = preg_split("/=/", $filter);
19       }
20  
21       // Check ACLs and opsi handle
22       $opsi_acl = $ui->get_permissions($base,"opsi/opsiProperties");
23       $opsi = new opsi($config);
24       $objects = array();
25       if($opsi instanceof opsi && $opsi->enabled() && preg_match("/r/",$opsi_acl)){
27         // Get list of opsi hosts 
28         $opsi_clients = $opsi->get_hosts_for_system_management();
29         if($opsi->is_error()){
30           msg_dialog::display(_("Error"),msgPool::siError($opsi->get_error()),ERROR_DIALOG);
31         }else{
32           foreach($opsi_clients as $entry){
33             if(empty($fAttr) || preg_match("/{$fValue}/i",$entry[$fAttr][0])){
34               $entry['objectClass'] = array("FAKE_OC_OpsiHost");
35               $item = array('count' => count($entry));
36               foreach($entry as  $name => $value){
37                 $item[] = $name;
38                 $item[$name] = $value;
39               }
40               $entries[] = $item;
41             }
42           }
43         }
44       }
45     }
46     return($entries);
47   }
48 }
50 ?>