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

:sparkles: feat(management) Allow columns to add their attribute to searched attributes

This means if I have enough ACL and I add a column with field X, the
 search field will also search in X.

issue #5867
Showing with 37 additions and 2 deletions
+37 -2
...@@ -104,6 +104,7 @@ class managementFilter ...@@ -104,6 +104,7 @@ class managementFilter
$attrs = objects::getSearchedAttributes($type); $attrs = objects::getSearchedAttributes($type);
$this->searchAttributes[$type] = array(); $this->searchAttributes[$type] = array();
$this->parent->listing->fillSearchedAttributes($type, $attrs);
foreach ($attrs as $attr => $acl) { foreach ($attrs as $attr => $acl) {
$rights = $ui->get_permissions($base, $acl); $rights = $ui->get_permissions($base, $acl);
if (strpos($rights, 'r') !== FALSE) { if (strpos($rights, 'r') !== FALSE) {
......
...@@ -559,6 +559,25 @@ class managementListing ...@@ -559,6 +559,25 @@ class managementListing
{ {
return $this->multiSelect; return $this->multiSelect;
} }
}
?> function fillSearchedAttributes($type, array &$attrs)
{
global $ui;
$searchedAttributes = array();
foreach ($this->columns as $column) {
$column->fillSearchedAttributes($searchedAttributes);
}
$searchedAttributes = array_unique($searchedAttributes);
foreach ($searchedAttributes as $attr) {
if (!isset($attrs[$attr])) {
$category = $ui->getAttributeCategory($type, $attr);
if ($category !== FALSE) {
$attrs[$attr] = $category;
}
}
}
}
}
...@@ -116,6 +116,21 @@ class Column ...@@ -116,6 +116,21 @@ class Column
} }
} }
function fillSearchedAttributes(array &$attrs)
{
if (isset($this->attributes)) {
foreach ($this->attributes as $attr) {
if (($attr == 'mainAttr') || ($attr == 'nameAttr')) {
/* nameAttr and mainAttr as always searched for */
continue;
}
if ($attr != 'dn') {
$attrs[] = $attr;
}
}
}
}
function fillRowClasses(&$classes, ListingEntry $entry) function fillRowClasses(&$classes, ListingEntry $entry)
{ {
} }
......
  • SonarQube analysis reported 2 issues

    • :warning: 2 major

    Note: The following issues were found on lines that were not modified in the commit. Because these issues can't be reported as line comments, they are summarized here:

    1. :warning: Review the data-flow - use of uninitialized value. :blue_book:
    2. :warning: Review the data-flow - use of uninitialized value. :blue_book:

    By Ghost User on 2019-01-29T14:22:02 (imported from GitLab)

Supports Markdown
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