]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix: Fix empty sections appearing in search results fix/unified-search-empty-sections 48619/head
authorChristopher Ng <chrng8@gmail.com>
Tue, 8 Oct 2024 17:45:27 +0000 (10:45 -0700)
committerChristopher Ng <chrng8@gmail.com>
Tue, 8 Oct 2024 17:57:20 +0000 (10:57 -0700)
Signed-off-by: Christopher Ng <chrng8@gmail.com>
apps/settings/lib/Search/SectionSearch.php

index 321534581b53ed4fae33df543ad93866c307dc57..15d98fbd1b946d54d37ea2f212ef4d75efcf2abe 100644 (file)
@@ -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'
                        ));