From 45849452b985beadb7b3996bd7e50dc8c6a95138 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come@opensides.be>
Date: Mon, 2 Oct 2017 10:01:32 +0200
Subject: [PATCH] :ambulance: fix(simpleplugin): Fixed filter when mainAttr is
 FALSE

There was problems with simpleManagement filters when the mainAttr value
 for one of the objectTypes listed is FALSE.
This was at least a problem for Audit. Maybe ACLs.

closes #5701
---
 include/class_objects.inc                       | 7 ++++++-
 include/simpleplugin/class_simpleManagement.inc | 8 ++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/include/class_objects.inc b/include/class_objects.inc
index fe2483c73..69fd929cc 100644
--- a/include/class_objects.inc
+++ b/include/class_objects.inc
@@ -57,12 +57,17 @@ class objects
       $attrs = array();
       foreach ($types as $type) {
         $infos = static::infos($type);
-        $attrs[] = $infos['mainAttr'];
+        if ($infos['mainAttr']) {
+          $attrs[] = $infos['mainAttr'];
+        }
       }
       $attrs = array_unique($attrs);
       if (count($attrs) == 1) {
         $attrs = $attrs[0];
       }
+      if (count($attrs) == 0) {
+        $attrs = array('dn' => 'raw');
+      }
     }
 
     if (is_array($attrs)) {
diff --git a/include/simpleplugin/class_simpleManagement.inc b/include/simpleplugin/class_simpleManagement.inc
index f81c6d519..17aae65f2 100644
--- a/include/simpleplugin/class_simpleManagement.inc
+++ b/include/simpleplugin/class_simpleManagement.inc
@@ -422,8 +422,12 @@ class simpleManagement
         );
         $this->filter->elementValues[$tag] = TRUE;
 
-        $attributes[] = $i['mainAttr'];
-        $attributes[] = $i['nameAttr'];
+        if ($i['mainAttr']) {
+          $attributes[] = $i['mainAttr'];
+        }
+        if ($i['nameAttr']) {
+          $attributes[] = $i['nameAttr'];
+        }
       }
       if (!static::$skipTemplates) {
         $tag    = 'FILTERTEMPLATE';
-- 
GitLab