aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2024-10-08 10:45:27 -0700
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2024-10-09 08:59:46 +0000
commitf582aba86ecfef6a9938c7ae696e90cd2ab6d718 (patch)
tree80b152873f7ebad36155ceee02ecdf0af86ace4f /apps
parentec396e588f2bc182a86ce4b16f945e13735f7b87 (diff)
downloadnextcloud-server-f582aba86ecfef6a9938c7ae696e90cd2ab6d718.tar.gz
nextcloud-server-f582aba86ecfef6a9938c7ae696e90cd2ab6d718.zip
fix: Fix empty sections appearing in search resultsbackport/48619/stable30
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'apps')
-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'
));