From 2c283ccee6a326df69587a123c0551bdcc064922 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 6 Jan 2010 11:04:15 +0000 Subject: [PATCH] Updated opsi filter git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15080 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../fai/admin/fai/class_faiManagement.inc | 1 + .../fai/admin/fai/class_filterFAI.inc | 105 ++++++++++-------- gosa-plugins/fai/admin/fai/fai-filter.tpl | 4 + gosa-plugins/fai/admin/fai/fai-filter.xml | 18 ++- 4 files changed, 82 insertions(+), 46 deletions(-) diff --git a/gosa-plugins/fai/admin/fai/class_faiManagement.inc b/gosa-plugins/fai/admin/fai/class_faiManagement.inc index a33359b6b..03ba0cd83 100644 --- a/gosa-plugins/fai/admin/fai/class_faiManagement.inc +++ b/gosa-plugins/fai/admin/fai/class_faiManagement.inc @@ -460,6 +460,7 @@ class faiManagement extends management $headpage->update(); $smarty = get_smarty(); $smarty->assign("fai_release", $this->fai_release); + $smarty->assign("opsi_available", is_object($this->opsi)); $smarty->assign("fai_base", $this->fai_base); $r = $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs')); $c = $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs')); diff --git a/gosa-plugins/fai/admin/fai/class_filterFAI.inc b/gosa-plugins/fai/admin/fai/class_filterFAI.inc index c8d8ef6f3..e270058dd 100644 --- a/gosa-plugins/fai/admin/fai/class_filterFAI.inc +++ b/gosa-plugins/fai/admin/fai/class_filterFAI.inc @@ -91,54 +91,69 @@ 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(); + + // 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; + + } } return($entries); diff --git a/gosa-plugins/fai/admin/fai/fai-filter.tpl b/gosa-plugins/fai/admin/fai/fai-filter.tpl index 4bfc457ba..8fa115813 100644 --- a/gosa-plugins/fai/admin/fai/fai-filter.tpl +++ b/gosa-plugins/fai/admin/fai/fai-filter.tpl @@ -47,6 +47,10 @@
{$VARIABLE} {t}Show variables{/t}
{$PACKAGE} {t}Show packages{/t}
{$PARTITION} {t}Show partition{/t} +{if $opsi_available} +
{$NETBOOT} {t}Show netboot products{/t} +
{$LOCALBOOT} {t}Show localboot products{/t} +{/if} diff --git a/gosa-plugins/fai/admin/fai/fai-filter.xml b/gosa-plugins/fai/admin/fai/fai-filter.xml index f54552dd1..5e2f47bc0 100644 --- a/gosa-plugins/fai/admin/fai/fai-filter.xml +++ b/gosa-plugins/fai/admin/fai/fai-filter.xml @@ -10,7 +10,7 @@ FAI - (&(|$PROFILE$HOOK$TEMPLATE$SCRIPT$VARIABLE$PACKAGE$PARTITION)$NAME) + (&(|$PROFILE$HOOK$TEMPLATE$SCRIPT$VARIABLE$PACKAGE$PARTITION$NETBOOT$LOCALBOOT)$NAME) dn objectClass cn @@ -27,6 +27,22 @@ Loading... + + checkbox + NETBOOT + true + + (FAIstate=__NETBOOT__) + + + + checkbox + LOCALBOOT + true + + (FAIstate=__LOCALBOOT__) + + checkbox PROFILE -- 2.30.2