From b53add9e6787341412f08f0cf85408e4836764ab Mon Sep 17 00:00:00 2001 From: Paolo Date: Mon, 11 Jul 2022 16:10:24 +0200 Subject: [PATCH] libraries/SearchBarLib->_organisationunit removes from the leaders array those elements with uid and name == null --- application/libraries/SearchBarLib.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/application/libraries/SearchBarLib.php b/application/libraries/SearchBarLib.php index a00ddeaae..3599f2a73 100644 --- a/application/libraries/SearchBarLib.php +++ b/application/libraries/SearchBarLib.php @@ -207,13 +207,17 @@ class SearchBarLib // Loop through the found leaders for this organisation unit for ($i = 0; $i < count($ou->leader_uid); $i++) { - // Empty object that will contains the leader uid and name - $leader = new stdClass(); - // Set the properties name and uid - $leader->uid = $ou->leader_uid[$i]; - $leader->name = $ou->leader_name[$i]; - // Add the leader object to the leaders array - $ou->leaders[] = $leader; + // If a leader exists for this organisationunit and has a name :D + if (!isEmptyString($ou->leader_uid[$i]) && !isEmptyString($ou->leader_name[$i])) + { + // Empty object that will contains the leader uid and name + $leader = new stdClass(); + // Set the properties name and uid + $leader->uid = $ou->leader_uid[$i]; + $leader->name = $ou->leader_name[$i]; + // Add the leader object to the leaders array + $ou->leaders[] = $leader; + } } // Remove the not needed properties leader_uid and leader_name