Merge pull request #48619 from nextcloud/fix/unified-search-empty-sections

fix: Fix empty sections appearing in search results
pull/48628/head
Pytal 2 months ago committed by GitHub
commit d4e07ce171
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 20
      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'
));

Loading…
Cancel
Save