Code

Updated opsi filter
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 6 Jan 2010 11:04:15 +0000 (11:04 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 6 Jan 2010 11:04:15 +0000 (11:04 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15080 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/fai/admin/fai/class_faiManagement.inc
gosa-plugins/fai/admin/fai/class_filterFAI.inc
gosa-plugins/fai/admin/fai/fai-filter.tpl
gosa-plugins/fai/admin/fai/fai-filter.xml

index a33359b6b78e3778177389c4cac0ed03b74f3b88..03ba0cd838a1db619407ce2d9bbcbd46c5acf3fd 100644 (file)
@@ -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'));
index c8d8ef6f34bc1829c0c89c8578cf49cc3fdb4546..e270058dd170ee13d87261a0a9f075d4d5c6524d 100644 (file)
@@ -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);
index 4bfc457ba8f049e22c2bcb6c57fe3619b591e0e9..8fa115813b173251bebaac48f02dd8f900cd468d 100644 (file)
 <br>{$VARIABLE}  {t}Show variables{/t}
 <br>{$PACKAGE}   {t}Show packages{/t}
 <br>{$PARTITION} {t}Show partition{/t}
+{if $opsi_available}
+<br>{$NETBOOT} {t}Show netboot products{/t}
+<br>{$LOCALBOOT} {t}Show localboot products{/t}
+{/if}
 
  <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
   <tr>
index f54552dd1625b20a5673adccb8806daf3c198488..5e2f47bc028e098c910b9bf51f5d76be51e1d004 100644 (file)
@@ -10,7 +10,7 @@
   <search>
     <query>
       <backend>FAI</backend>
-      <filter>(&amp;(|$PROFILE$HOOK$TEMPLATE$SCRIPT$VARIABLE$PACKAGE$PARTITION)$NAME)</filter>
+      <filter>(&amp;(|$PROFILE$HOOK$TEMPLATE$SCRIPT$VARIABLE$PACKAGE$PARTITION$NETBOOT$LOCALBOOT)$NAME)</filter>
       <attribute>dn</attribute>
       <attribute>objectClass</attribute>
       <attribute>cn</attribute>
     <value>Loading...</value>
   </element>
 
+  <element>
+    <type>checkbox</type>
+    <tag>NETBOOT</tag>
+    <default>true</default>
+    <unset></unset>
+    <set>(FAIstate=__NETBOOT__)</set>
+  </element>
+
+  <element>
+    <type>checkbox</type>
+    <tag>LOCALBOOT</tag>
+    <default>true</default>
+    <unset></unset>
+    <set>(FAIstate=__LOCALBOOT__)</set>
+  </element>
+
   <element>
     <type>checkbox</type>
     <tag>PROFILE</tag>