Commit 657c6a1d authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Merge branch '5135-filter-enhancement-and-management-refactor' into '1.4-dev'

Resolve "filter enhancement and management refactor"

See merge request fusiondirectory/fd!525
parents cc698efb a1e433c0
<fieldset><legend>{$NAME}</legend>
<label for="nt_{$attribute}" title="{t 1=$NAME}Minimum date for %1{/t}">
{t}Newer than{/t}
<input type="date" id="nt_{$attribute}" name="nt_{$attribute}" value="{$nt_value}"/>
</label>
<label for="ot_{$attribute}" title="{t 1=$NAME}Maximum date for %1{/t}">
{t}Older than{/t}
<input type="date" id="ot_{$attribute}" name="ot_{$attribute}" value="{$ot_value}"/>
</label>
</fieldset>
......@@ -28,12 +28,15 @@
{/foreach}
<hr/>
{if $BASEMODE}
<label for="SCOPE">
<input type="checkbox" id="SCOPE" name="SCOPE" value="1"
{if ($SCOPE == 'sub')}checked="checked"{/if}/>
&nbsp;{t}Search in subtrees{/t}
</label>
<hr/>
{/if}
<label for="SEARCH" title="{$SEARCHDESC|escape}"><img src="geticon.php?context=actions&amp;icon=system-search&amp;size=16" alt="Search"/>
<input class="filter_textfield" id="SEARCH" name="SEARCH" type="search" value="{$SEARCH}"/>
......
......@@ -427,8 +427,12 @@ class objects
if (!isset($infos['searchAttributes'])) {
$searchAttrs = array();
$searchAttrs[$infos['mainAttr']] = $infos['aclCategory'].'/'.$infos['mainTab'];
$searchAttrs[$infos['nameAttr']] = $infos['aclCategory'].'/'.$infos['mainTab'];
if (!empty($infos['mainAttr'])) {
$searchAttrs[$infos['mainAttr']] = $infos['aclCategory'].'/'.$infos['mainTab'];
}
if (!empty($infos['nameAttr'])) {
$searchAttrs[$infos['nameAttr']] = $infos['aclCategory'].'/'.$infos['mainTab'];
}
foreach ($config->data['TABS'][$infos['tabGroup']] as $tab) {
if (!plugin_available($tab['CLASS'])) {
continue;
......
......@@ -142,6 +142,11 @@ class Action
$this->enabledCallable = $callable;
}
function setInMenu($inmenu)
{
$this->inmenu = $inmenu;
}
function listActions()
{
return array($this->name);
......
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2017-2018 FusionDirectory
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*!
* \brief Filter on member types
*/
class DateFilterElement extends FilterElement
{
protected $attribute;
protected $label;
protected $min;
protected $max;
protected $types;
public function __construct(managementFilter $parent, $attribute, $label, $types = array())
{
global $config;
parent::__construct($parent);
$this->attribute = $attribute;
$this->label = $label;
$this->types = $types;
}
public function update()
{
if (!empty($_POST['nt_'.$this->attribute])) {
$this->min = $_POST['nt_'.$this->attribute];
} else {
$this->min = '';
}
if (!empty($_POST['ot_'.$this->attribute])) {
$this->max = $_POST['ot_'.$this->attribute];
} else {
$this->max = '';
}
}
public function render()
{
$smarty = get_smarty();
$smarty->assign('NAME', $this->label);
$smarty->assign('attribute', $this->attribute);
$smarty->assign('nt_value', $this->min);
$smarty->assign('ot_value', $this->max);
return $smarty->fetch(get_template_path('management/filter-element-date.tpl'));
}
public function getFilters($type, array &$filters)
{
if (!empty($this->types) && !in_array_ics($type, $this->types)) {
return FALSE;
}
if (!empty($this->min)) {
$filters[] = '('.$this->attribute.'>='.LdapGeneralizedTime::toString(new DateTime($this->min)).')';
}
if (!empty($this->max)) {
$filters[] = '('.$this->attribute.'<='.LdapGeneralizedTime::toString(new DateTime($this->max)).')';
}
return FALSE;
}
}
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2017-2018 FusionDirectory
Copyright (C) 2017-2019 FusionDirectory
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
......@@ -45,77 +46,3 @@ class FilterElement
return FALSE;
}
}
class TabFilterElement extends FilterElement
{
protected $tabs;
public function __construct(managementFilter $parent)
{
global $config;
parent::__construct($parent);
$this->tabs = array();
foreach ($this->parent->parent->objectTypes as $type) {
$infos = objects::infos($type);
foreach ($config->data['TABS'][$infos['tabGroup']] as $plug) {
$class = $plug['CLASS'];
if ($class == $infos['mainTab']) {
continue;
}
if (isset($this->tabs[$class])) {
continue;
}
if (class_available($class)) {
$classInfos = pluglist::pluginInfos($class);
if (isset($classInfos['plFilterObject'])) {
$this->tabs[$class] = array(
'filter' => $classInfos['plFilterObject'],
'infos' => $classInfos,
'checked' => FALSE,
);
}
}
}
}
}
public function update()
{
foreach ($this->tabs as $class => &$tab) {
$tab['checked'] = isset($_POST['filter_tab_'.$class]);
}
unset($tab);
}
public function render()
{
if (empty($this->tabs)) {
return '';
}
$inputs = array();
foreach ($this->tabs as $class => $tab) {
$inputs['filter_tab_'.$class] = array(
'name' => $tab['infos']['plShortName'],
'desc' => $tab['infos']['plShortName'].' '.$tab['filter'],
'icon' => (isset($tab['infos']['plSmallIcon']) ? $tab['infos']['plSmallIcon'] : NULL),
'checked' => $tab['checked'],
);
}
$smarty = get_smarty();
$smarty->assign('NAME', _('Tabs'));
$smarty->assign('INPUTS', $inputs);
return $smarty->fetch(get_template_path('management/filter-element.tpl'));
}
public function getFilters($type, array &$filters)
{
foreach ($this->tabs as $tab) {
if ($tab['checked']) {
$filters[] = $tab['filter'];
}
}
return FALSE;
}
}
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2017-2019 FusionDirectory
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class TabFilterElement extends FilterElement
{
protected $tabs;
public function __construct(managementFilter $parent)
{
global $config;
parent::__construct($parent);
$this->tabs = array();
foreach ($this->parent->parent->objectTypes as $type) {
$infos = objects::infos($type);
foreach ($config->data['TABS'][$infos['tabGroup']] as $plug) {
$class = $plug['CLASS'];
if ($class == $infos['mainTab']) {
continue;
}
if (isset($this->tabs[$class])) {
continue;
}
if (class_available($class)) {
$classInfos = pluglist::pluginInfos($class);
if (isset($classInfos['plFilterObject'])) {
$this->tabs[$class] = array(
'filter' => $classInfos['plFilterObject'],
'infos' => $classInfos,
'checked' => FALSE,
);
}
}
}
}
}
public function update()
{
foreach ($this->tabs as $class => &$tab) {
$tab['checked'] = isset($_POST['filter_tab_'.$class]);
}
unset($tab);
}
public function render()
{
if (empty($this->tabs)) {
return '';
}
$inputs = array();
foreach ($this->tabs as $class => $tab) {
$inputs['filter_tab_'.$class] = array(
'name' => $tab['infos']['plShortName'],
'desc' => $tab['infos']['plShortName'].' '.$tab['filter'],
'icon' => (isset($tab['infos']['plSmallIcon']) ? $tab['infos']['plSmallIcon'] : NULL),
'checked' => $tab['checked'],
);
}
$smarty = get_smarty();
$smarty->assign('NAME', _('Tabs'));
$smarty->assign('INPUTS', $inputs);
return $smarty->fetch(get_template_path('management/filter-element.tpl'));
}
public function getFilters($type, array &$filters)
{
foreach ($this->tabs as $tab) {
if ($tab['checked']) {
$filters[] = $tab['filter'];
}
}
return FALSE;
}
}
......@@ -122,6 +122,7 @@ class managementFilter
$smarty = get_smarty();
$smarty->assign('SCOPE', $this->scope);
$smarty->assign('BASEMODE', $this->parent->listing->getBaseMode());
$smarty->assign('FILTER_PID', $this->pid);
$smarty->assign('SEARCH', $this->search);
$smarty->assign('TYPES', $this->types);
......
......@@ -85,6 +85,11 @@ class managementListing
$this->reloadColumns();
}
function getBaseMode()
{
return $this->baseMode;
}
function reloadColumns()
{
$columnInfos = $this->parent->getColumnConfiguration();
......
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2018-2019 FusionDirectory
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*!
* \brief Column rendering LdapGeneralizedTime attributes
*/
class LdapGeneralizedTimeColumn extends LinkColumn
{
protected $type = 'string';
function renderCell(ListingEntry $entry)
{
$value = $this->getAttributeValue($entry);
if ($value != '') {
$dateObject = LdapGeneralizedTime::fromString($value);
if (is_object($dateObject)) {
return $this->renderLink($entry, $dateObject->format('Y-m-d, H:i:s'));
}
}
return '&nbsp;';
}
}
  • SonarQube analysis indicates that quality gate is failed.

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

    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