Code

Updated table summary
[gosa.git] / gosa-plugins / fai / admin / fai / class_filterFAI.inc
index 6583ab14ac2efb97b6d5f13aa32facb2f4b7314b..5524e0c1f9df1819a90424ddf407314b12323a44 100644 (file)
@@ -49,18 +49,27 @@ 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";
+          }
+          $object['FAIstate'] = $entry['FAIstate'];
+
           $obj['TYPES'][]       = $type;
-        
+          $obj['GROUPS'][$type]      = $object;
+
           if(!isset($result[$obj['cn']])){
             $result[$obj['cn']] = $obj;
           }else{
             $result[$obj['cn']]['TYPES'][]=$type;
+            $result[$obj['cn']]['GROUPS'][$type]=$object;
           }
         }
       }
@@ -69,14 +78,84 @@ class filterFAI extends filterLDAP{
     // Make results useable for the listing class.
     $entries = array();
     foreach($result as $entry){
-      $item=array('count' => count($entry));
+      $item=array('count' => count($entry) -1);
       foreach($entry as $name => $value){
-        $item[] = $name;
-        $item[$name] = $value ;       
+        if($name != "GROUPS"){
+          $item[] = $name;
+
+          $item[$name] = $value ;       
+        }
       }
+      $item['GROUPS'] = $entry['GROUPS'];
       $entries[] = $item;
     }
 
+
+    // Append opsi stuff ... 
+    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);
+          }
+        }
+      }
+
+      $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);
   }
 }