Commit 8344b940 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Fixes #5070 First try at migrating packageSelect to simpleSelectManagement

parent 20204f28
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2003-2010 Cajus Pollmeier
......@@ -20,12 +19,13 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class filterFAIPackages {
class filterFAIPackages extends filterLDAPBlacklist
{
static function query($parent,$base, $scope, $filter, $attributes, $category, $objectStorage= "")
static function query($parent, $base, $scope, $filter, $attributes, $category, $objectStorage = '')
{
$customs = array();
foreach($parent->customs as $custom) {
foreach ($parent->customs as $custom) {
if ($parent->elementValues[$custom] == 'true') {
$customs[] = $custom;
}
......@@ -34,27 +34,27 @@ class filterFAIPackages {
$pkgs = array();
$q = new supportDaemon();
$filter = array("$filter");
$attrs = array("distribution", "package", "version", "section", "timestamp");
$attrs = array('distribution', 'package', 'version', 'section', 'timestamp');
$release = session::get('packageSelect_Release');
$ret = $q->FAI_get_packages($release,$attrs,$filter,0,200);
$ret = $q->FAI_get_packages($release, $attrs, $filter, 0, 200);
if ($q->is_error()) {
msg_dialog::display(_("Infrastructure service"), msgPool::siError($q->get_error()), ERROR_DIALOG);
msg_dialog::display(_('Infrastructure service'), msgPool::siError($q->get_error()), ERROR_DIALOG);
} else {
for ($i = 0;(count($ret)<200) && ($i<count($customs));$i++) {
$ret2 = $q->FAI_get_packages($customs[$i],$attrs,$filter,0,200-count($ret));
for ($i = 0;(count($ret) < 200) && ($i < count($customs));$i++) {
$ret2 = $q->FAI_get_packages($customs[$i], $attrs, $filter, 0, 200 - count($ret));
if ($q->is_error()) {
msg_dialog::display(_("Infrastructure service"), msgPool::siError($q->get_error()), ERROR_DIALOG);
msg_dialog::display(_('Infrastructure service'), msgPool::siError($q->get_error()), ERROR_DIALOG);
return array();
}
$ret = array_merge($ret,$ret2);
$ret = array_merge($ret, $ret2);
}
foreach($ret as $attr) {
$attr['objectClass'] = "FAKE_OC__FaiPackage";
foreach ($ret as $attr) {
$attr['objectClass'] = 'FAKE_OC__FaiPackage';
$item = array();
$item['dn'] = "dn=".$attr['PACKAGE'].",".$attr['DISTRIBUTION'].",".$base;
$item['dn'] = 'dn='.$attr['PACKAGE'].','.$attr['DISTRIBUTION'].','.$base;
$item['count'] = 0;
foreach($attr as $key => $value) {
foreach ($attr as $key => $value) {
$item['count']++;
$item[] = $key;
$item[$key] = array('count' => 1, $value);
......@@ -63,40 +63,21 @@ class filterFAIPackages {
}
}
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);
return static::filterByBlacklist($pkgs);
}
function save()
{
$act = $this->detectPostActions();
$headpage = $this->getHeadpage();
if (!isset($act['targets'])) return(array());
if (!isset($act['targets'])) {
return array();
}
$ret = array();
foreach ($act['targets'] as $dn) {
$ret[] = $headpage->getEntry($dn);
}
return $ret;
}
}
?>
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2003-2010 Cajus Pollmeier
......@@ -20,20 +19,26 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class packageSelect extends management
class packageSelect extends simpleSelectManagement
{
protected $skipFooter = TRUE;
protected $skipHeader = TRUE;
protected $objectTypes = array();
protected $autoFilter = FALSE;
protected $departmentBrowser = FALSE;
protected $departmentRootVisible = FALSE;
protected $baseMode = FALSE;
function __construct()
{
$filter = new filterFAIcustoms(get_template_path("selectPackage-filter.xml", TRUE, dirname(__FILE__)));
$this->setFilter($filter);
$this->filterXMLPath = get_template_path('selectPackage-filter.xml', TRUE, dirname(__FILE__));
$this->listXMLPath = get_template_path('selectPackage-list.xml', TRUE, dirname(__FILE__));
// Build headpage
$headpage = new listing(get_template_path("selectPackage-list.xml", TRUE, dirname(__FILE__)));
$headpage->setFilter($filter);
parent::__construct("FAI-packages", $headpage);
if (!session::global_is_set(get_class($this).'_filter')) {
$filter = new filterFAIcustoms($this->filterXMLPath);
session::global_set(get_class($this).'_filter', $filter);
}
parent::__construct();
}
function save()
......@@ -47,7 +52,5 @@ class packageSelect extends management
}
return $ret;
}
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
<div class="contentboxh">
<p class="contentboxh">
{t}Filter{/t}
</p>
<p>{t}Filter{/t}</p>
</div>
<div class="contentboxb">
<div style="padding:3px;">
{t}A maximum of 200 entries will be shown here.{/t}
</div>
<div style='padding: 3px;'>
{t}A maximum of 200 entries will be shown here.{/t}
</div>
{foreach from=$customs key=key item=value}
{$value}<label for="{$key}">&nbsp;custom {$key}</label><br/>
{/foreach}
<div style='padding:4px;'>
{foreach from=$customs key=key item=value}
{$value}
<label for="{$key}">custom {$key}</label><br/>
{/foreach}
</div>
<hr/>
<table style="width:100%;border-top:1px solid #B0B0B0;">
<tr>
<td>
<label for="NAME">
<img src="geticon.php?context=actions&icon=system-search&size=16" align=middle>&nbsp;{t}Name{/t}
</label>
</td>
<td>
{$NAME}
</td>
</tr>
</table>
<label for="NAME"><img src="geticon.php?context=actions&amp;icon=system-search&amp;size=16"/></label>{$NAME}
<table width="100%" style="background:#EEEEEE;border-top:1px solid #B0B0B0;">
<tr>
<td style="width:100%;text-align:right;">
<div>
{$APPLY}
</td>
</tr>
</table>
</div>
</div>
......@@ -18,14 +18,6 @@
<scope>auto</scope>
</search>
<element>
<type>checkbox</type>
<tag>CUSTOMCALIBRE7</tag>
<default>false</default>
<unset></unset>
<set>(&amp;(objectClass=FAIclass)(FAIstate=__NETBOOT__))</set>
</element>
<element>
<type>textfield</type>
<tag>NAME</tag>
......
<table style="width:100%;height:100%; vertical-align:top; text-align:left;">
<tr>
<td style="vertical-align:top; width:100%;">
<div class="contentboxh">
<p class="contentboxh">&nbsp;{$HEADLINE}&nbsp;{$SIZELIMIT}</p>
</div>
<table class="listing_container">
<tbody>
<tr>
<td class="list">
<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 class="optional">{$RELOAD}&nbsp;</td><td>{$SEPARATOR}&nbsp;</td>
<td><input class='center' type='image' src='geticon.php?context=actions&icon=submit&size=16' align='middle' title='{t}Update{/t}' name='submit_department' alt='{t}Submit{/t}'>&nbsp;</td><td>{$SEPARATOR}&nbsp;</td><td> {$ACTIONS}</td>
</tr></table>
</div>
</div>
<div class="contentboxb" style="background:white;">
<table>
<tbody>
<tr>
<td>{$ROOT}&nbsp;</td><td>{$BACK}&nbsp;</td><td>{$HOME}&nbsp;</td><td class="optional">{$RELOAD}&nbsp;</td><td>{$SEPARATOR}&nbsp;</td>
<td><input class="center" type="image" src="geticon.php?context=actions&amp;icon=submit&amp;size=16" title="{t}Update{/t}" name="submit_department" alt="{t}Submit{/t}"/>&nbsp;</td><td>{$SEPARATOR}&nbsp;</td>
<td>{$ACTIONS}</td>
</tr>
</tbody>
</table>
</div>
<div style='height:4px;'>
</div>
{$LIST}
</td>
<td style='vertical-align:top;min-width:250px'>
{$FILTER}
</td>
</tr>
<div style="margin-top:4px;">
{$LIST}
</div>
</td>
<td class="filter">
{$FILTER}
</td>
</tr>
</tbody>
</table>
<p class="plugbottom">
<input type=submit name="packageSelect_save" value="{msgPool type=addButton}">
<input type="submit" name="packageSelect_save" value="{msgPool type=addButton}"/>
&nbsp;
<input type=submit name="packageSelect_cancel" value="{msgPool type=cancelButton}">
<input type="submit" name="packageSelect_cancel" value="{msgPool type=cancelButton}"/>
</p>
<input type="hidden" name="ignore">
<input type="hidden" name="ignore"/>
......@@ -58,5 +58,4 @@
<actiontriggers snapshot="false" copypaste="false">
</actiontriggers>
</list>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment