Skip to content

Commit

Permalink
Merge pull request #48619 from nextcloud/fix/unified-search-empty-sec…
Browse files Browse the repository at this point in the history
…tions

fix: Fix empty sections appearing in search results
  • Loading branch information
Pytal authored Oct 9, 2024
2 parents d66e469 + 4082377 commit d4e07ce
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions apps/settings/lib/Search/SectionSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,33 @@ 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'
);

if ($this->groupManager->isAdmin($user->getUID())) {
$result = array_merge($result, $this->searchSections(
$query,
$this->settingsManager->getAdminSections(),
$adminSections,
$this->l->t('Administration'),
'settings.AdminSettings.index'
));
Expand Down

0 comments on commit d4e07ce

Please sign in to comment.