diff options
author | Pytal <24800714+Pytal@users.noreply.github.com> | 2024-10-09 01:58:52 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-09 01:58:52 -0700 |
commit | d4e07ce17181faed49e219648c15af4b2b001170 (patch) | |
tree | d21aaa4dbc3201d7951377e4a6450f8194a1e5c9 /apps | |
parent | d66e46919424ea3393d1189a5904f5dec6b28aee (diff) | |
parent | 40823775d905eee0fa35234bea72d550abd84031 (diff) | |
download | nextcloud-server-d4e07ce17181faed49e219648c15af4b2b001170.tar.gz nextcloud-server-d4e07ce17181faed49e219648c15af4b2b001170.zip |
Merge pull request #48619 from nextcloud/fix/unified-search-empty-sections
fix: Fix empty sections appearing in search results
Diffstat (limited to 'apps')
-rw-r--r-- | apps/settings/lib/Search/SectionSearch.php | 20 |
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' )); |