Code

Added Package selection dialog
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 28 Jan 2010 14:12:07 +0000 (14:12 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 28 Jan 2010 14:12:07 +0000 (14:12 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15422 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/fai/admin/fai/packageSelect/class_filterFAIPackages.inc [new file with mode: 0644]
gosa-plugins/fai/admin/fai/packageSelect/class_packageSelect.inc [new file with mode: 0644]
gosa-plugins/fai/admin/fai/packageSelect/selectPackage-filter.tpl [new file with mode: 0644]
gosa-plugins/fai/admin/fai/packageSelect/selectPackage-filter.xml [new file with mode: 0644]
gosa-plugins/fai/admin/fai/packageSelect/selectPackage-list.tpl [new file with mode: 0644]
gosa-plugins/fai/admin/fai/packageSelect/selectPackage-list.xml [new file with mode: 0644]

diff --git a/gosa-plugins/fai/admin/fai/packageSelect/class_filterFAIPackages.inc b/gosa-plugins/fai/admin/fai/packageSelect/class_filterFAIPackages.inc
new file mode 100644 (file)
index 0000000..2b718f9
--- /dev/null
@@ -0,0 +1,69 @@
+<?php
+
+class filterFAIPackages {
+
+  static function query($base, $scope, $filter, $attributes, $category, $objectStorage= "")
+  {
+    $pkgs = array();
+    $q          = new gosaSupportDaemon();
+    $filter     = array("%$filter%");
+    $attrs      = array("distribution", "package","version", "section", "description", "timestamp");
+    $release = session::get('packageSelect_Release');
+    $ret        = $q->FAI_get_packages($release,$attrs,$filter,0,200);
+    if($q->is_error()){
+      msg_dialog::display(_("Service infrastructure"),msgPool::siError($q->get_error()),ERROR_DIALOG);
+    }else{
+      foreach($ret as $attr){
+        
+        $attr['objectClass'] = "FAKE_OC__FaiPackage";
+        $attr['DESCRIPTION'] = base64_decode($attr['DESCRIPTION']);
+
+        $item = array();
+        $item['dn']   = "dn=".$attr['PACKAGE'].",".$attr['DISTRIBUTION'].",".$base;
+        $item['count']= 0;
+        foreach($attr as $key => $value){
+          $item['count']++;
+          $item[] = $key;
+          $item[$key] = array('count' => 1, $value);
+        }
+        $pkgs[] = $item;
+      }
+    }
+
+    return(filterLDAPBlacklist::filterByBlacklist($pkgs));
+  }
+
+  static function filterByBlacklist($entries)
+  {
+    if(session::is_set('filterBlacklist')){
+      $blist = session::get('filterBlacklist');
+      foreach($blist as $attr_name => $attr_values){
+        foreach($attr_values as $match){
+          foreach($entries as $id => $entry){
+            if(isset($entry[$attr_name])){
+              $test = $entry[$attr_name];
+              if(!is_array($test)) $test = array($test);
+              if(in_array($match, $test)) unset($entries[$id]);
+            }
+          }
+        }
+      }
+    }
+    return(array_values($entries));
+  }
+
+  function save()
+  {
+    $act = $this->detectPostActions();
+    $headpage = $this->getHeadpage();
+    if(!isset($act['targets'])) return(array());
+    $ret = array();
+    foreach($act['targets'] as $dn){
+      $ret[] = $headpage->getEntry($dn);
+    }
+    return($ret);
+  }
+
+}
+
+?>
diff --git a/gosa-plugins/fai/admin/fai/packageSelect/class_packageSelect.inc b/gosa-plugins/fai/admin/fai/packageSelect/class_packageSelect.inc
new file mode 100644 (file)
index 0000000..fba6e8b
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+/*
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id: class_groupManagement.inc 14766 2009-11-05 14:30:35Z hickert $$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+class packageSelect extends management
+{
+
+  protected $skipFooter = TRUE;
+  protected $skipHeader = TRUE;
+
+  function __construct($config,$ui)
+  {
+    $this->config = $config;
+    $this->ui = $ui;
+
+#    // Build filter
+#    if (session::global_is_set(get_class($this)."_filter")){
+#      $filter= session::global_get(get_class($this)."_filter");
+#    } else {
+  $filter = new filter(get_template_path("selectPackage-filter.xml", true, dirname(__FILE__)));
+#    }
+  $this->setFilter($filter);
+
+  // Build headpage
+  $headpage = new listing(get_template_path("selectPackage-list.xml", true, dirname(__FILE__)));
+  $headpage->setFilter($filter);
+  parent::__construct($config, $ui, "FAI-packages", $headpage);
+  }
+
+  function save()
+  {
+    $act = $this->detectPostActions();
+    $headpage = $this->getHeadpage();
+    if(!isset($act['targets'])) return(array());
+    $ret = array();
+    foreach($act['targets'] as $dn){
+      $ret[] = $headpage->getEntry($dn);
+    }
+    return($ret);
+  }
+
+} 
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/fai/admin/fai/packageSelect/selectPackage-filter.tpl b/gosa-plugins/fai/admin/fai/packageSelect/selectPackage-filter.tpl
new file mode 100644 (file)
index 0000000..2da0e67
--- /dev/null
@@ -0,0 +1,34 @@
+<div class="contentboxh">
+ <p class="contentboxh">
+  <img src="images/launch.png" align="right" alt="[F]">{t}Filter{/t}
+ </p>
+</div>
+
+<div class="contentboxb">
+
+<div style="border-top:1px solid #AAAAAA"></div>
+
+ <div style='padding: 3px;'>  
+  {t}A maximum of 200 entries will be shown here.{/t}
+ </div>
+ <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+  <tr>
+   <td>
+    <label for="NAME">
+     <img src="images/lists/search.png" align=middle>&nbsp;Name
+    </label>
+   </td>
+   <td>
+    {$NAME}
+   </td>
+  </tr>
+ </table>
+
+ <table summary=""  width="100%"  style="background:#EEEEEE;border-top:1px solid #B0B0B0;">
+  <tr>
+   <td width="100%" align="right">
+    {$APPLY}
+   </td>
+  </tr>
+ </table>
+</div>
diff --git a/gosa-plugins/fai/admin/fai/packageSelect/selectPackage-filter.xml b/gosa-plugins/fai/admin/fai/packageSelect/selectPackage-filter.xml
new file mode 100644 (file)
index 0000000..febabf2
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<filterdef>
+  <definition>
+    <category>groups</category>
+    <template>../plugins/admin/fai/packageSelect/selectPackage-filter.tpl</template>
+    <initial>true</initial>
+  </definition>
+
+  <search>
+    <query>
+      <backend>FAIPackages</backend>
+      <filter>$NAME</filter>
+      <attribute>SECTION</attribute>
+      <attribute>VERSION</attribute>
+      <attribute>PACKAGE</attribute>
+    </query>
+    <scope>auto</scope>
+  </search>
+
+  <element>
+    <type>textfield</type>
+    <tag>NAME</tag>
+    <size>20</size>
+    <maxlength>60</maxlength>
+    <default></default>
+    <unset></unset>
+    <set>*$</set>
+    <alphabet>true</alphabet>
+    <autocomplete>
+      <backend>FAIPackages</backend>
+      <filter>$NAME</filter>
+      <attribute>PACKAGE</attribute>
+      <frequency>0.5</frequency>
+      <characters>3</characters>
+    </autocomplete>
+  </element>
+
+</filterdef>
diff --git a/gosa-plugins/fai/admin/fai/packageSelect/selectPackage-list.tpl b/gosa-plugins/fai/admin/fai/packageSelect/selectPackage-list.tpl
new file mode 100644 (file)
index 0000000..344a065
--- /dev/null
@@ -0,0 +1,37 @@
+<input type='image' src='images/empty.png' name='no_action_posted' value='do_nothing' alt='' style='width:2px;height:2px;'>
+
+<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=2>
+  <tr>
+    <td style="vertical-align:top; width:50%;">
+      <div class="contentboxh">
+        <p class="contentboxh">&nbsp;{$HEADLINE}&nbsp;{$SIZELIMIT}</p>
+      </div>
+      
+      <div class="contentboxb">
+       <div style='background:white;padding:3px;'>
+        <table><tr>
+          <td>{$ROOT}&nbsp;</td><td>{$BACK}&nbsp;</td><td>{$HOME}&nbsp;</td><td>{$RELOAD}&nbsp;</td><td>{$SEPARATOR}&nbsp;</td><td>{t}Base{/t} {$BASE}&nbsp;<input class='center' type='image' src='images/lists/submit.png' align='middle' title='{t}Update{/t}' name='submit_department' alt='{t}Submit{/t}'>&nbsp;</td><td>{$SEPARATOR}&nbsp;</td><td><img src='images/rocket.png' alt='' class='center'></td><td> {$ACTIONS}</td>
+        </tr></table>
+       </div>
+      </div>
+      
+      <div style='height:4px;'>
+      </div>
+      
+      <input type="hidden" id="d_save" value="450">
+      <input type="hidden" id="d_space" value="760">
+      {$LIST}
+    </td>
+    <td style='vertical-align:top'>
+      {$FILTER}
+    </td>
+  </tr>
+</table>
+
+<p class="plugbottom">
+  <input type=submit name="packageSelect_save" value="{msgPool type=addButton}">
+  &nbsp;
+  <input type=submit name="packageSelect_cancel" value="{msgPool type=cancelButton}">
+</p>
+
+<input type="hidden" name="ignore">
diff --git a/gosa-plugins/fai/admin/fai/packageSelect/selectPackage-list.xml b/gosa-plugins/fai/admin/fai/packageSelect/selectPackage-list.xml
new file mode 100644 (file)
index 0000000..d1b73bd
--- /dev/null
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<list>
+  <definition>
+    <departmentBrowser>false</departmentBrowser>
+    <departmentRootVisible>false</departmentRootVisible>
+    <baseMode>false</baseMode>
+    <multiSelect>true</multiSelect>
+    <template>../plugins/admin/fai/packageSelect/selectPackage-list.tpl</template>
+    <label>Please select the desired entries</label>
+    <defaultSortColumn>1</defaultSortColumn>
+
+    <objectType>
+      <label>FAI</label>
+      <objectClass>FAKE_OC__FaiPackage</objectClass>
+      <category>faiPackage</category>
+      <class>faiPackage</class>
+      <image>plugins/fai/images/fai_packages.png</image>
+    </objectType>
+
+  </definition>
+
+  <table>
+    <layout>|20px;c||180|</layout>
+
+    <department>
+      <value>%{filter:objectType(dn,objectClass)}</value>
+    </department>
+
+    <department>
+      <value>%{filter:departmentLink(row,dn,description)}</value>
+      <span>1</span>
+    </department>
+
+    <column>
+      <value>%{filter:objectType(dn,objectClass)}</value>
+    </column>
+
+    <column>
+      <label>Name</label>
+      <sortAttribute>PACKAGE</sortAttribute>
+      <sortType>string</sortType>
+      <value>%{PACKAGE}</value>
+      <export>true</export>
+    </column>
+
+    <column>
+      <label>Version</label>
+      <sortAttribute>VERSION</sortAttribute>
+      <sortType>string</sortType>
+      <value>%{VERSION}</value>
+      <export>true</export>
+    </column>
+
+
+  </table>
+
+  <actionmenu>
+  </actionmenu>
+
+  <actiontriggers snapshot="false" copypaste="false">
+  </actiontriggers>
+
+</list>