X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-plugins%2Ffai%2Fadmin%2Ffai%2Fclass_filterFAI.inc;h=5524e0c1f9df1819a90424ddf407314b12323a44;hb=b9312edd7dd76aaad3d6e7d123bc16748aa6380c;hp=c8d8ef6f34bc1829c0c89c8578cf49cc3fdb4546;hpb=2022eb26ccf6e0b95a31058014d000a621ce87be;p=gosa.git diff --git a/gosa-plugins/fai/admin/fai/class_filterFAI.inc b/gosa-plugins/fai/admin/fai/class_filterFAI.inc index c8d8ef6f3..5524e0c1f 100644 --- a/gosa-plugins/fai/admin/fai/class_filterFAI.inc +++ b/gosa-plugins/fai/admin/fai/class_filterFAI.inc @@ -49,12 +49,13 @@ class filterFAI extends filterLDAP{ /* Clean up object informations */ $obj = array(); $obj['cn'] = $object['cn'][0]; - $obj['dn'] = $object['cn'][0]; + $obj['dn'] = $object['cn'][0].",".get_ou("faiBaseRDN").$config->current['BASE']; $obj['acl'] = $acl; $obj['class'] = $rest ['ACL']; $obj['FAIstate'] = $entry['FAIstate']; $obj['description'] = $object['description'][0]; $obj['objectClass'] = $object['objectClass']; + $obj['objectClass'][] = 'FAKE_OC_FAI'; if(!preg_match("/freeze/i", $entry['FAIstate'])){ $obj['objectClass'][] = "FAKE_OC_IsBranch"; @@ -91,54 +92,68 @@ class filterFAI extends filterLDAP{ // Append opsi stuff ... - $opsi = new opsi($config); - - if($opsi instanceof opsi && $opsi->enabled()){ - $opsi_acl = $ui->get_permissions($base,"opsi/opsiProperties"); - if(preg_match("/r/",$opsi_acl)){ - $err = FALSE; - $n_pro = $opsi->get_netboot_products(); - $err |= $opsi->is_error(); - foreach($n_pro as $name => $data){ - $entry = array( - "cn" => $name, - "description" => $data['DESC'], - "type" => "opsi_netboot"); - $objects[$name]['opsi_netboot'] = $entry; - } - $l_pro = $opsi->get_local_products(); - $err |= $opsi->is_error(); - foreach($l_pro as $name => $data){ - $entry = array("cn" => $name, - "description" => $data['DESC'], - "type" => "opsi_local"); - $objects[$name]["opsi_local"] = $entry; - } - if($err){ - msg_dialog::display(_("Error"),msgPool::siError($opsi->get_error()),ERROR_DIALOG); + if(class_available('opsi') && $base == get_ou("faiBaseRDN").$config->current['BASE']){ + $opsi = new opsi($config); + $objects = array(); + if($opsi instanceof opsi && $opsi->enabled()){ + $opsi_acl = $ui->get_permissions($base,"opsi/opsiProperties"); + if(preg_match("/r/",$opsi_acl)){ + $err = FALSE; + + if(preg_match("/FAIstate=__NETBOOT__/", $filter)){ + $n_pro = $opsi->get_netboot_products(); + $err |= $opsi->is_error(); + foreach($n_pro as $name => $data){ + $entry = array( + "cn" => $name, + "description" => $data['DESC'], + "type" => "opsi_netboot"); + $objects[$name]['opsi_netboot'] = $entry; + } + } + if(preg_match("/FAIstate=__LOCALBOOT__/", $filter)){ + $l_pro = $opsi->get_local_products(); + $err |= $opsi->is_error(); + foreach($l_pro as $name => $data){ + $entry = array("cn" => $name, + "description" => $data['DESC'], + "type" => "opsi_local"); + $objects[$name]["opsi_local"] = $entry; + } + } + if($err){ + msg_dialog::display(_("Error"),msgPool::siError($opsi->get_error()),ERROR_DIALOG); + } } } - } - foreach($objects as $name => $data) - { - $data = array_pop($data); - $item =array(); - - // FAKE_OC_IsBranch allows us to delete this entry (indicates NOT freezed state) - $item['objectClass'] = array('count' => 2, $data['type'], "FAKE_OC_IsBranch"); - $item[] = 'objectClass'; - $item['cn'] = $data['cn']; - $item[] = 'cn'; - $item['description'] = $data['description']; - $item[] = 'description'; - $item['dn'] = $data['cn']; - $item[] = 'dn'; - $item['TYPES'] = array($data['type']); - $item[] = 'TYPES'; - $item['count'] = '5'; - $entries[] = $item; - + $cn_filter = ""; + if(preg_match("/^.*cn=([^)]*).*/",$filter)){ + $cn_filter = trim(preg_replace("/^.*cn=([^)]*).*/","\\1",$filter),"*"); + } + + foreach($objects as $name => $data) + { + $data = array_pop($data); + if(!empty($cn_filter) && !preg_match("/".preg_quote($cn_filter,'/')."/", $data['cn'])){ + continue; + } + $item =array(); + + $item['objectClass'] = array('count' => 2, $data['type'],"FAKE_OC_OPSI"); + $item[] = 'objectClass'; + $item['cn'] = $data['cn']; + $item[] = 'cn'; + $item['description'] = $data['description']; + $item[] = 'description'; + $item['dn'] = $data['cn']; + $item[] = 'dn'; + $item['TYPES'] = array($data['type']); + $item[] = 'TYPES'; + $item['count'] = '5'; + $entries[] = $item; + + } } return($entries);