aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/lib
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2024-10-08 10:45:27 -0700
committerChristopher Ng <chrng8@gmail.com>2024-10-08 10:57:20 -0700
commit40823775d905eee0fa35234bea72d550abd84031 (patch)
tree72687dc0f288cf7bfc03be98a1fd0db430e728bf /apps/settings/lib
parent05886d281d4c9c9b980dc50eaf551f4c3b28b3ef (diff)
downloadnextcloud-server-40823775d905eee0fa35234bea72d550abd84031.tar.gz
nextcloud-server-40823775d905eee0fa35234bea72d550abd84031.zip
fix: Fix empty sections appearing in search resultsfix/unified-search-empty-sections
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'apps/settings/lib')
-rw-r--r--apps/settings/lib/Search/SectionSearch.php20
1 files changed, 18 insertions, 2 deletions
diff --git a/apps/settings/lib/Search/SectionSearch.php b/apps/settings/lib/Search/SectionSearch.php
index 321534581b5..15d98fbd1b9 100644
--- a/apps/settings/lib/Search/SectionSearch.php
+++ b/apps/settings/lib/Search/SectionSearch.php
@@ -74,9 +74,25 @@ class SectionSearch implements IProvider {
public function search(IUser $user, ISearchQuery $query): SearchResult {
$isAdmin = $this->groupManager->isAdmin($user->getUID());
+ $personalSections = $this->settingsManager->getPersonalSections();
+ foreach ($personalSections as $priority => $sections) {
+ $personalSections[$priority] = array_values(array_filter(
+ $sections,
+ fn (IIconSection $section) => !empty($this->settingsManager->getPersonalSettings($section->getID())),
+ ));
+ }
+
+ $adminSections = $this->settingsManager->getAdminSections();
+ foreach ($adminSections as $priority => $sections) {
+ $adminSections[$priority] = array_values(array_filter(
+ $sections,
+ fn (IIconSection $section) => !empty($this->settingsManager->getAllowedAdminSettings($section->getID(), $user)),
+ ));
+ }
+
$result = $this->searchSections(
$query,
- $this->settingsManager->getPersonalSections(),
+ $personalSections,
$isAdmin ? $this->l->t('Personal') : '',
'settings.PersonalSettings.index'
);
@@ -84,7 +100,7 @@ class SectionSearch implements IProvider {
if ($this->groupManager->isAdmin($user->getUID())) {
$result = array_merge($result, $this->searchSections(
$query,
- $this->settingsManager->getAdminSections(),
+ $adminSections,
$this->l->t('Administration'),
'settings.AdminSettings.index'
));