diff --git a/apps/settings/lib/Search/SectionSearch.php b/apps/settings/lib/Search/SectionSearch.php index 321534581b53e..15d98fbd1b946 100644 --- a/apps/settings/lib/Search/SectionSearch.php +++ b/apps/settings/lib/Search/SectionSearch.php @@ -74,9 +74,25 @@ public function getOrder(string $route, array $routeParameters): int { 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 @@ public function search(IUser $user, ISearchQuery $query): SearchResult { if ($this->groupManager->isAdmin($user->getUID())) { $result = array_merge($result, $this->searchSections( $query, - $this->settingsManager->getAdminSections(), + $adminSections, $this->l->t('Administration'), 'settings.AdminSettings.index' ));