Code

Second FAI list rebuild
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 5 Jan 2010 12:09:41 +0000 (12:09 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 5 Jan 2010 12:09:41 +0000 (12:09 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15055 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/fai/admin/fai/class_faiManagement.inc
gosa-plugins/fai/admin/fai/class_filterFAI.inc [new file with mode: 0644]
gosa-plugins/fai/admin/fai/fai-filter.tpl
gosa-plugins/fai/admin/fai/fai-filter.xml
gosa-plugins/fai/admin/fai/fai-list.xml

index d962cf33bdbe57d1ea9d5b2fd8328912bfa93b0d..63e1733eef91c42012142121068a9a8d05994ba1 100644 (file)
@@ -39,8 +39,14 @@ class faiManagement extends management
   {
     $this->config = $config;
     $this->ui = $ui;
-   
-    $this->storagePoints = array(get_ou("roleRDN"));
+
+    $this->storagePoints = array(
+        get_ou('faiPartitionRDN'),
+        get_ou('faiPackageRDN'),
+        get_ou('faiScriptRDN'),
+        get_ou('faiVariableRDN'),
+        get_ou('faiHookRDN'),
+        get_ou('faiProfileRDN'),get_ou('faiTemplateRDN'));
  
     // Build filter
 #    if (session::global_is_set(get_class($this)."_filter")){
@@ -54,6 +60,7 @@ class faiManagement extends management
     // Build headpage
     $headpage = new listing(get_template_path("fai-list.xml", true));
     $headpage->setFilter($filter);
+    $headpage->registerElementFilter("filterProperties", "faiManagement::filterProperties");
 
     // Add copy&paste and snapshot handler.
     if ($this->config->boolValueIsTrue("main", "copyPaste")){
@@ -106,6 +113,42 @@ class faiManagement extends management
   }
 
 
+  static function filterProperties($row, $classes)
+  {
+    $objects = array(
+        "FAIpartitionTable"  => array("IMG"=> "plugins/fai/images/fai_partitionTable.png",
+          "NAME"=>_("Partition table"),"KZL"=> "PT", "VAR"=>"ShowPartitions"),
+        "FAIpackageList"     => array("IMG"=> "plugins/fai/images/fai_packages.png",
+          "NAME"=>_("Package list") ,  "KZL"=> "PL", "VAR"=>"ShowPackages"),
+        "FAIscript"          => array("IMG"=> "plugins/fai/images/fai_script.png",
+          "NAME"=>_("Scripts") ,       "KZL"=> "S",  "VAR"=>"ShowScripts"),
+        "FAIvariable"        => array("IMG"=> "plugins/fai/images/fai_variable.png",
+          "NAME"=>_("Variables") ,     "KZL"=> "V",  "VAR"=>"ShowVariables"),
+        "FAIhook"            => array("IMG"=> "plugins/fai/images/fai_hook.png",
+          "NAME"=>_("Hooks"),          "KZL"=> "H",  "VAR"=>"ShowHooks"),
+        "FAIprofile"         => array("IMG"=> "plugins/fai/images/fai_profile.png",
+          "NAME"=>_("Profile") ,       "KZL"=> "P",  "VAR"=>"ShowProfiles"),
+        "FAItemplate"        => array("IMG"=> "plugins/fai/images/fai_template.png",
+          "NAME"=>_("Templates") ,     "KZL"=> "T",  "VAR"=>"ShowTemplates"),
+        "opsi_netboot"       => array("IMG"=> "plugins/opsi/images/netboot_package.png",
+          "NAME"=>_("OPSI netboot product") ,     "KZL"=> "ON",  "VAR"=>"ShowOpsiNetboot"),
+        "opsi_local"         => array("IMG"=> "plugins/opsi/images/local_package.png",
+          "NAME"=>_("OPSI localboot product")   ,     "KZL"=> "OL",  "VAR"=>"ShowOpsiLocal"));
+
+    $icon_list = "";
+    foreach($objects as $type => $type_data){
+      if(in_array($type, $classes)){
+        $icon_list .= "<input type='image' src='".$type_data['IMG']."' title='".$type_data['NAME']."'
+          alt='".$type_data['KZL']."' class='center' name='edit_".$row."_".$type."'>\n";
+      }else{
+        $icon_list .= "<img src='images/empty.png' alt=' ' class='center'>\n";
+      }
+    }
+
+    return $icon_list;
+  }
+
+
 } 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
diff --git a/gosa-plugins/fai/admin/fai/class_filterFAI.inc b/gosa-plugins/fai/admin/fai/class_filterFAI.inc
new file mode 100644 (file)
index 0000000..6583ab1
--- /dev/null
@@ -0,0 +1,83 @@
+<?php
+
+class filterFAI extends filterLDAP{
+
+  static function query($base, $scope, $filter, $attributes, $category, $objectStorage= "")
+  {
+  /* Create a new list of FAI object
+     * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ...
+     */
+    $ObjectTypes = array(
+        "FAIpartitionTable"  => array("OU"=> get_ou('faiPartitionRDN') , "CHKBOX"=>"ShowPartitions"  ,"ACL" => "faiPartitionTable"),
+        "FAIpackageList"     => array("OU"=> get_ou('faiPackageRDN')   , "CHKBOX"=>"ShowPackages"    ,"ACL" => "faiPackage"),
+        "FAIscript"          => array("OU"=> get_ou('faiScriptRDN')    , "CHKBOX"=>"ShowScripts"     ,"ACL" => "faiScript"),
+        "FAIvariable"        => array("OU"=> get_ou('faiVariableRDN')  , "CHKBOX"=>"ShowVariables"   ,"ACL" => "faiVariable"),
+        "FAIhook"            => array("OU"=> get_ou('faiHookRDN')      , "CHKBOX"=>"ShowHooks"       ,"ACL" => "faiHook"),
+        "FAIprofile"         => array("OU"=> get_ou('faiProfileRDN')   , "CHKBOX"=>"ShowProfiles"    ,"ACL" => "faiProfile"),
+        "FAItemplate"        => array("OU"=> get_ou('faiTemplateRDN')  , "CHKBOX"=>"ShowTemplates"   ,"ACL" => "faiTemplate"));
+
+
+
+    global $config;
+    $tmp = FAI::get_all_objects_for_given_base($base,$filter);
+    $ui = get_userinfo();
+    $ldap = $config->get_ldap_link();
+    $ldap->cd($config->current['BASE']);
+
+    $result = array();
+    foreach($tmp as $entry){
+
+      /* Get some more informations about the object */
+      $ldap->cat($entry['dn'], array("cn","description","objectClass","FAIclass","FAIstate","objectClass"));
+      $object  = $ldap->fetch();
+
+      /* Walk through possible types */
+      foreach($ObjectTypes as $type => $rest){
+
+        $acl = $ui->get_permissions($object['dn'],"fai/".$rest ['ACL']);
+
+        if(in_array($type,$object['objectClass']) && preg_match("/r/",$acl)){
+
+          /* Prepare object */
+          unset($object['objectClass']['count']);
+          if(!isset($object['description'][0])){
+            $object['description'][0]="";
+          }
+
+          $dn = preg_replace("/^[^,]*+,/","",$object['dn']);
+
+          /* Clean up object informations */
+          $obj                  = array();
+          $obj['cn']            = $object['cn'][0];
+          $obj['dn']            = $object['cn'][0];
+          $obj['acl']           = $acl;
+          $obj['class']         = $rest ['ACL'];
+          $obj['FAIstate']      = $entry['FAIstate'];
+          $obj['description']   = $object['description'][0];
+          $obj['objectClass']   = $object['objectClass'];
+          $obj['TYPES'][]       = $type;
+        
+          if(!isset($result[$obj['cn']])){
+            $result[$obj['cn']] = $obj;
+          }else{
+            $result[$obj['cn']]['TYPES'][]=$type;
+          }
+        }
+      }
+    }
+
+    // Make results useable for the listing class.
+    $entries = array();
+    foreach($result as $entry){
+      $item=array('count' => count($entry));
+      foreach($entry as $name => $value){
+        $item[] = $name;
+        $item[$name] = $value ;       
+      }
+      $entries[] = $item;
+    }
+
+    return($entries);
+  }
+}
+?>
index 6495f8fb5503db32d3479f9e63be0012cb73a340..3c2904bfc12bdfb744f8fb00ef7de7d6fc6b5001 100644 (file)
    </td>
   </tr>
  </table>
+<div style="border-top:1px solid #AAAAAA"></div>
+
+{$PROFILE}   {t}Show profiles{/t}
+<br>{$TEMPLATE}  {t}Show templates{/t}
+<br>{$SCRIPT}    {t}Show scripts{/t}
+<br>{$HOOK}      {t}Show hooks{/t}
+<br>{$VARIABLE}  {t}Show variables{/t}
+<br>{$PACKAGE}   {t}Show packages{/t}
+<br>{$PARTITION} {t}Show partition{/t}
 
  <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
   <tr>
index 835a26d080e1d740fe6861b3b7014b04c9c57223..f54552dd1625b20a5673adccb8806daf3c198488 100644 (file)
@@ -9,8 +9,8 @@
 
   <search>
     <query>
-      <backend>LDAP</backend>
-      <filter>(&amp;(objectClass=FAIclass)$NAME)</filter>
+      <backend>FAI</backend>
+      <filter>(&amp;(|$PROFILE$HOOK$TEMPLATE$SCRIPT$VARIABLE$PACKAGE$PARTITION)$NAME)</filter>
       <attribute>dn</attribute>
       <attribute>objectClass</attribute>
       <attribute>cn</attribute>
     <value>Loading...</value>
   </element>
 
+  <element>
+    <type>checkbox</type>
+    <tag>PROFILE</tag>
+    <default>true</default>
+    <unset></unset>
+    <set>(objectClass=FAIprofile)</set>
+  </element>
+
+  <element>
+    <type>checkbox</type>
+    <tag>TEMPLATE</tag>
+    <default>true</default>
+    <unset></unset>
+    <set>(objectClass=FAItemplate)</set>
+  </element>
+
+  <element>
+    <type>checkbox</type>
+    <tag>SCRIPT</tag>
+    <default>true</default>
+    <unset></unset>
+    <set>(objectClass=FAIscript)</set>
+  </element>
+
+  <element>
+    <type>checkbox</type>
+    <tag>HOOK</tag>
+    <default>true</default>
+    <unset></unset>
+    <set>(objectClass=FAIhook)</set>
+  </element>
+
+  <element>
+    <type>checkbox</type>
+    <tag>VARIABLE</tag>
+    <default>true</default>
+    <unset></unset>
+    <set>(objectClass=FAIvariable)</set>
+  </element>
+
+  <element>
+    <type>checkbox</type>
+    <tag>PACKAGE</tag>
+    <default>true</default>
+    <unset></unset>
+    <set>(objectClass=FAIpackageList)</set>
+  </element>
+
+  <element>
+    <type>checkbox</type>
+    <tag>PARTITION</tag>
+    <default>true</default>
+    <unset></unset>
+    <set>(objectClass=FAIpartitionTable)</set>
+  </element>
+
   <element>
     <type>textfield</type>
     <tag>NAME</tag>
@@ -37,7 +93,7 @@
     <set>(cn=*$*)</set>
     <alphabet>false</alphabet>
     <autocomplete>
-      <backend>LDAP</backend>
+      <backend>FAI</backend>
       <filter>(&amp;(objectClass=FAIclass)(cn=*$NAME*))</filter>
       <attribute>cn</attribute>
       <frequency>0.5</frequency>
index cd37ca0c1696e4c15556a2ee214b1a72c5c69a6e..e4758ef6ec8eb7c56a246a7b7980ca39fa9f540c 100644 (file)
   </definition>
 
   <table>
-    <layout>|20px;c||250px|170px;r|</layout>
-
-    <department>
-      <value>%{filter:objectType(dn,objectClass)}</value>
-    </department>
+    <layout>|20px;c|||250px|170px;r|</layout>
 
     <department>
       <value>%{filter:departmentLink(row,dn,description)}</value>
       <export>true</export>
     </column>
 
+    <column>
+      <label>Properties</label>
+      <value>%{filter:filterProperties(row,TYPES)}</value>
+    </column>
+
     <column>
       <label>Actions</label>
       <value>%{filter:actions(dn,row,objectClass)}</value>