Commit 5bc05872 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Merge branch '5135-filter-enhancement' into '1.4-dev'

Resolve "filter enhancement"

See merge request fusiondirectory/fd!279
parents 2e069eb5 e0f7377c
......@@ -30,15 +30,14 @@
*/
class divSelectBox
{
var $headers = FALSE;
var $a_entries;
var $summary;
var $cols;
protected $headers = FALSE;
protected $a_entries;
protected $summary;
protected $cols;
private $id;
protected $id;
// Members for page managment
var $height = '200px';
protected $height = '200px';
/*!
* \brief Default divSelectBox constructor
......@@ -70,7 +69,7 @@ class divSelectBox
*
* \param array $a_entriedata
*/
function AddEntry($a_entriedata)
function addEntry($a_entriedata)
{
$this->a_entries[] = $a_entriedata;
}
......@@ -80,7 +79,7 @@ class divSelectBox
*
* \param array $headers
*/
function SetHeaders($headers)
function setHeaders($headers)
{
$this->headers = $headers;
}
......@@ -88,7 +87,7 @@ class divSelectBox
/*!
* \brief Draw the list
*/
function DrawList()
function drawList()
{
$s_return = '';
$s_return .= '<div style="border:1px solid rgb(170,170,170);padding-right:1px;height:'.$this->height.';width:100%">'."\n";
......@@ -102,7 +101,7 @@ class divSelectBox
'border:none; '.
'"'.
">\n";
$s_return .= $this->_generatePage();
$s_return .= $this->generatePage();
$s_return .= '</table></div></div>';
if ($this->headers !== FALSE) {
$s_return .=
......@@ -113,20 +112,12 @@ class divSelectBox
return $s_return;
}
/*!
* \brief Get the number of entries
*/
function _numentries()
{
return count($this->a_entries);
}
/*!
* \brief Set summary
*
* \param string $msg
*/
function SetSummary($msg)
function setSummary($msg)
{
$this->s_summary = $msg;
}
......@@ -134,7 +125,7 @@ class divSelectBox
/*!
* \brief Generate the page
*/
function _generatePage()
protected function generatePage()
{
$display = '';
if ($this->headers !== FALSE) {
......@@ -147,13 +138,13 @@ class divSelectBox
}
$display .= '</tr></thead>'."\n";
}
return $display.'<tbody>'.$this->_generateBody().'</tbody>';
return $display.'<tbody>'.$this->generateBody().'</tbody>';
}
/*!
* \brief Generate the body
*/
function _generateBody()
protected function generateBody()
{
/* If divselectbox is empty, append a single white entry */
if (count($this->a_entries) == 0) {
......
......@@ -26,6 +26,9 @@ class ListingEntry implements ArrayAccess
private $attrs;
protected $listing;
/* Cache where columns may store stuff */
public $cache = array();
public function __construct(managementListing $listing, $type, $dn, array $attrs, $row = NULL)
{
$this->listing = $listing;
......
......@@ -32,6 +32,13 @@ class ManagementColumnAttribute extends CompositeAttribute
*/
class ManagementConfigurationDialog extends simplePlugin
{
static function plInfo ()
{
return array(
'plShortName' => 'ManagementConfigurationDialog',
);
}
static function getAttributesInfo ()
{
global $class_mapping;
......@@ -112,7 +119,6 @@ class ManagementConfigurationDialog extends simplePlugin
function execute ()
{
var_dump($this->managementColumns);
$smarty = get_smarty();
$smarty->assign('ManagementConfigurationACL', 'rw');
$str = parent::execute();
......
......@@ -56,7 +56,7 @@ class managementFilter
$this->pid = preg_replace('/[^0-9]/', '', microtime(TRUE));
foreach ($this->parent->objectTypes as $type) {
$this->types[$type] = array(
$this->types['filter_type_'.$type] = array(
'show' => TRUE,
'filters' => array(),
'infos' => objects::infos($type),
......@@ -82,8 +82,8 @@ class managementFilter
{
if (isset($_POST['FILTER_PID']) && ($_POST['FILTER_PID'] == $this->pid)) {
// Load post values and adapt filter, base and scope accordingly
foreach ($this->types as $type => &$data) {
$data['show'] = isset($_POST[$type]);
foreach ($this->types as $key => &$data) {
$data['show'] = isset($_POST[$key]);
}
unset($data);
......@@ -145,10 +145,10 @@ class managementFilter
$entries = array();
$row = 0;
foreach ($this->parent->objectTypes as $type) {
if (!$this->types[$type]['show']) {
if (!$this->types['filter_type_'.$type]['show']) {
continue;
}
$infos = $this->types[$type]['infos'];
$infos = $this->types['filter_type_'.$type]['infos'];
if ($this->scope == 'one') {
$searchBase = (empty($infos['ou']) ? $base : $infos['ou'].$base);
} else {
......
......@@ -290,6 +290,7 @@ class managementListing
if ($dn !== NULL) {
$this->parent->filter->setScope('base');
list($this->entries, $this->objectTypeCount) = $this->parent->filter->query($attrs, $dn);
$this->parent->filter->setScope('one');
} else {
list($this->entries, $this->objectTypeCount) = $this->parent->filter->query($attrs, $this->base);
}
......
......@@ -130,7 +130,7 @@ class Column
}
}
function compare($ao, $bo)
function compare(ListingEntry $ao, ListingEntry $bo)
{
if ($this->attribute == 'sort-attribute') {
// Override sort attribute from data if needed
......
......@@ -47,11 +47,6 @@ class PropertiesColumn extends Column
}
}
function isSortable()
{
return FALSE;
}
function fillNeededAttributes(array &$attrs)
{
foreach ($this->tabs as $classes) {
......@@ -63,15 +58,68 @@ class PropertiesColumn extends Column
function renderCell(ListingEntry $entry)
{
global $config;
$tabs = $this->computeIcons($entry);
$result = '';
foreach ($tabs as $tab) {
if (empty($tab['icon'])) {
$result .= '<img src="images/empty.png" alt="" class="optional '.$tab['tab'].'"/>';
} else {
$result .= '<input type="image" src="'.htmlentities($tab['icon'], ENT_COMPAT, 'UTF-8').'" '.
'alt="'.htmlentities($tab['title'], ENT_COMPAT, 'UTF-8').'" title="'.htmlentities($tab['title'], ENT_COMPAT, 'UTF-8').'" '.
'name="listing_edit_tab_'.$tab['tab'].'_'.$entry->row.'"/>';
}
}
return $result;
}
function compare(ListingEntry $ao, ListingEntry $bo)
{
if ($ao->getTemplatedType() != $bo->getTemplatedType()) {
return strcmp($ao->getTemplatedType(), $bo->getTemplatedType());
}
// Extract values from ao and bo
$a = $this->computeSortString($ao);
$b = $this->computeSortString($bo);
return strcmp($a, $b);
}
protected function computeSortString(ListingEntry $entry)
{
if (isset($entry->cache[__CLASS__]['sort'])) {
return $entry->cache[__CLASS__]['sort'];
}
$icons = $this->computeIcons($entry);
$entry->cache[__CLASS__]['sort'] = implode('', array_map(
function($tab)
{
return (empty($tab['icon']) ? 0 : 1);
},
$icons
));;
return $entry->cache[__CLASS__]['sort'];
}
protected function computeIcons(ListingEntry $entry)
{
if (isset($entry->cache[__CLASS__]['icons'])) {
return $entry->cache[__CLASS__]['icons'];
}
$infos = objects::infos($entry->getTemplatedType());
$icons = array();
/* Main tab is always there */
$pInfos = pluglist::pluginInfos($infos['mainTab']);
$result = '<input type="image" src="'.htmlentities((isset($pInfos['plSmallIcon']) ? $pInfos['plSmallIcon'] : $infos['icon']), ENT_COMPAT, 'UTF-8').'" '.
'alt="'.$pInfos['plShortName'].'" title="'.$pInfos['plShortName'].'" '.
'name="listing_edit_tab_'.$infos['mainTab'].'_'.$entry->row.'"/>';
$icons[] = array(
'icon' => (isset($pInfos['plSmallIcon']) ? $pInfos['plSmallIcon'] : $infos['icon']),
'title' => $pInfos['plShortName'],
'tab' => $infos['mainTab'],
);
if (!empty($entry)) {
if ($entry->isTemplate()) {
$attrs = $entry->getTemplatedFields();
......@@ -83,18 +131,23 @@ class PropertiesColumn extends Column
if ($status !== FALSE) {
$pInfos = pluglist::pluginInfos($class);
if (isset($pInfos['plSmallIcon'])) {
$result .= '<input type="image" src="'.htmlentities($pInfos['plSmallIcon'], ENT_COMPAT, 'UTF-8').'" '.
'alt="'.$pInfos['plShortName'].'" title="'.$pInfos['plShortName'].'" '.
'name="listing_edit_tab_'.$class.'_'.$entry->row.'"/>';
$icons[] = array(
'icon' => $pInfos['plSmallIcon'],
'title' => $pInfos['plShortName'],
'tab' => $class,
);
} else {
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $pInfos['plShortName']." ($class)", 'No icon for');
}
} else {
$result .= '<img src="images/empty.png" alt="" class="optional '.$class.'"/>';
$icons[] = array(
'tab' => $class,
);
}
}
}
return $result;
$entry->cache[__CLASS__]['icons'] = $icons;
return $entry->cache[__CLASS__]['icons'];
}
}
......@@ -371,7 +371,6 @@ class OrderedArrayAttribute extends SetAttribute
{
protected $order;
protected $edit_enabled;
protected $height = 90;
protected $headers = FALSE;
/*! \brief The constructor of OrderedArrayAttribute
......@@ -388,11 +387,6 @@ class OrderedArrayAttribute extends SetAttribute
$this->edit_enabled = $edit_enabled;
}
function setHeight($h)
{
$this->height = $h;
}
function setHeaders($h)
{
$this->headers = $h;
......@@ -447,11 +441,18 @@ class OrderedArrayAttribute extends SetAttribute
function renderOnlyFormInput ()
{
if (($this->size < 15) && ($this->size < count($this->value))) {
$this->size = min(15, count($this->value));
}
$id = $this->getHtmlId();
$div = new divSelectBox('rows'.$id);
$smarty = get_smarty();
$div->SetHeight($this->height);
$div->SetHeaders($this->headers);
$height = ($this->size * 26) + 6;
if ($this->headers) {
$height += 29;
}
$div->setHeight($height);
$div->setHeaders($this->headers);
foreach ($this->value as $key => $value) {
$fields = array();
foreach ($this->getAttributeArrayValue($key, $value) as $field) {
......@@ -468,9 +469,9 @@ class OrderedArrayAttribute extends SetAttribute
list ($img, $nbicons) = $this->genRowIcons($key, $value);
$fields[] = array("html" => $img, "attach" => 'style="border:0px;width:'.($nbicons * 20).'px;"');
$div->AddEntry($fields);
$div->addEntry($fields);
}
$smarty->assign("div_$id", $div->DrawList());
$smarty->assign("div_$id", $div->drawList());
return '{$div_'.$id.'}'."\n";
}
......
......@@ -196,11 +196,11 @@ class ACLEditionDialog extends GenericDialog
$field1 = array('html' => $infos['description'], 'attach' => 'style="width:140px"');
$field2 = array('html' => $summary);
$field3 = array('html' => $action, 'attach' => 'style="border-right:0px;width:40px"');
$aclList->AddEntry(array($field1, $field2, $field3));
$aclList->addEntry(array($field1, $field2, $field3));
}
$smarty->assign('headline', _('List of available ACL categories'));
$smarty->assign('aclEdition', $aclList->DrawList());
$smarty->assign('aclEdition', $aclList->drawList());
} elseif ($this->dialogState == 'edit') {
/* Collect objects for selected category */
$aclObjects = array();
......
......@@ -23,22 +23,12 @@
*/
class GroupContentColumn extends Column
{
function isSortable()
{
return FALSE;
}
function fillNeededAttributes(array &$attrs)
{
$attrs['gosaGroupObjects'] = '1';
}
function renderCell(ListingEntry $entry)
{
global $config;
if (strtolower($entry->getTemplatedType()) == 'ogroup') {
$types = preg_replace('/[^a-z]/i', '', $entry['gosaGroupObjects']);
$types = preg_replace('/[^a-z]/i', '', $entry[$this->attribute]);
} else {
$types = 'U';
}
......
......@@ -25,9 +25,9 @@ class groupManagement extends management
public static $columns = array(
array('ObjectTypeColumn', array()),
array('LinkColumn', array('attribute' => 'cn', 'label' => 'Name')),
array('LinkColumn', array('attribute' => 'description', 'label' => 'Description')),
array('GroupContentColumn', array('label' => 'Members')),
array('LinkColumn', array('attribute' => 'cn', 'label' => 'Name')),
array('LinkColumn', array('attribute' => 'description', 'label' => 'Description')),
array('GroupContentColumn', array('attribute' => 'gosaGroupObjects', 'label' => 'Members')),
array('PropertiesColumn', array('label' => 'Properties')),
array('ActionsColumn', array('label' => 'Actions')),
);
......
  • SonarQube analysis indicates that quality gate is failed.

    • Security Rating on New Code is passed: Actual value 1
    • Reliability Rating on New Code is passed: Actual value 1
    • Maintainability Rating on New Code is passed: Actual value 1
    • Duplicated Lines on New Code (%) is failed: Actual value 8.66372980910426 > 5

    SonarQube analysis reported no issues.

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