Commit 31e4575a 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!526
parents 657c6a1d 0621d3cc
......@@ -109,9 +109,8 @@ class ManagementConfigurationDialog extends simplePlugin
foreach ($columnInfos as $column) {
if (!isset($column[1]['attributes'])) {
$column[1]['attributes'] = '';
}
if (is_array($column[1]['attributes'])) {
$column[1]['attributes'] = implode(',', $column[1]['attributes']);
} elseif (is_array($column[1]['attributes'])) {
$column[1]['attributes'] = json_encode($column[1]['attributes']);
}
if (!isset($column[1]['label'])) {
$column[1]['label'] = '';
......@@ -160,7 +159,12 @@ class ManagementConfigurationDialog extends simplePlugin
foreach ($values as $value) {
$column = array($value[0], array());
if (!empty($value[1])) {
$column[1]['attributes'] = $value[1];
$jsonDecoded = json_decode($value[1], TRUE);
if ($jsonDecoded !== NULL) {
$column[1]['attributes'] = $jsonDecoded;
} else {
$column[1]['attributes'] = $value[1];
}
}
if (!empty($value[2])) {
$column[1]['label'] = $value[2];
......
......@@ -24,10 +24,12 @@
class Column
{
/*! \brief Array of attributes to look for, ordered by priority
* The first non-empty attribute will be displayed */
protected $attributes;
* The first non-empty attribute will be displayed
* The array is organized as the one passed to objects::ls
* */
private $attributes;
/*! \brief Same thing for templates, if it differs */
protected $templateAttributes = NULL;
private $templateAttributes = NULL;
protected $label;
protected $type = 'string';
......@@ -61,13 +63,30 @@ class Column
function __construct(managementListing $parent, array $attributes = NULL, $label = NULL)
{
$this->parent = $parent;
$this->attributes = $attributes;
$this->setAttributesVar('attributes', $attributes);
$this->label = $label;
}
protected function setAttributesVar($var, array $attributes = NULL)
{
if (is_array($attributes) && is_numeric(key($attributes))) {
$val = array();
foreach ($attributes as $attribute) {
if ($attribute == 'dn') {
$val[$attribute] = 'raw';
} else {
$val[$attribute] = 1;
}
}
$this->$var = $val;
} else {
$this->$var = $attributes;
}
}
function setTemplateAttributes(array $attributes = NULL)
{
$this->templateAttributes = $attributes;
$this->setAttributesVar('templateAttributes', $attributes);
}
function isSortable()
......@@ -102,16 +121,12 @@ class Column
function fillNeededAttributes(array &$attrs)
{
if (isset($this->attributes)) {
foreach ($this->attributes as $attr) {
foreach ($this->attributes as $attr => $how) {
if (($attr == 'mainAttr') || ($attr == 'nameAttr')) {
/* nameAttr and mainAttr as always set as needed in managementFilter */
continue;
}
if ($attr == 'dn') {
$attrs[$attr] = 'raw';
} else {
$attrs[$attr] = '1';
}
$attrs[$attr] = $how;
}
}
}
......@@ -119,7 +134,7 @@ class Column
function fillSearchedAttributes(array &$attrs)
{
if (isset($this->attributes)) {
foreach ($this->attributes as $attr) {
foreach (array_keys($this->attributes) as $attr) {
if (($attr == 'mainAttr') || ($attr == 'nameAttr')) {
/* nameAttr and mainAttr as always searched for */
continue;
......@@ -142,7 +157,7 @@ class Column
$attrs = $this->templateAttributes;
}
if (isset($attrs)) {
foreach ($attrs as $attr) {
foreach (array_keys($attrs) as $attr) {
if (($attr == 'mainAttr') || ($attr == 'nameAttr')) {
$infos = objects::infos($entry->getTemplatedType());
$attr = $infos[$attr];
......
......@@ -29,7 +29,18 @@ class LinkColumn extends Column
if ($value == '') {
return ' ';
} else {
return $this->renderLink($entry, htmlentities($value, ENT_COMPAT, 'UTF-8'));
if (is_array($value)) {
$value = array_map(
function ($v)
{
return htmlentities($v, ENT_COMPAT, 'UTF-8');
},
$value
);
return $this->renderLink($entry, implode("<br/>\n", $value));
} else {
return $this->renderLink($entry, htmlentities($value, ENT_COMPAT, 'UTF-8'));
}
}
}
......
  • 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.0595138306789607

    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