Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable23] Allow sub-admins to access delegated settings. #31102

Merged
merged 1 commit into from
Mar 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions lib/private/Settings/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,23 +335,20 @@ public function getPersonalSettings($section): array {

public function getAllowedAdminSettings(string $section, IUser $user): array {
$isAdmin = $this->groupManager->isAdmin($user->getUID());
$isSubAdmin = $this->subAdmin->isSubAdmin($user);
$subAdminOnly = !$isAdmin && $isSubAdmin;

if ($subAdminOnly) {
// not an admin => look if the user is still authorized to access some
// settings
$subAdminSettingsFilter = function (ISettings $settings) {
return $settings instanceof ISubAdminSettings;
};
$appSettings = $this->getSettings('admin', $section, $subAdminSettingsFilter);
} elseif ($isAdmin) {
if ($isAdmin) {
$appSettings = $this->getSettings('admin', $section);
} else {
$authorizedSettingsClasses = $this->mapper->findAllClassesForUser($user);
$authorizedGroupFilter = function (ISettings $settings) use ($authorizedSettingsClasses) {
return in_array(get_class($settings), $authorizedSettingsClasses) === true;
};
if ($this->subAdmin->isSubAdmin($user)) {
$authorizedGroupFilter = function (ISettings $settings) use ($authorizedSettingsClasses) {
return $settings instanceof ISubAdminSettings
|| in_array(get_class($settings), $authorizedSettingsClasses) === true;
};
} else {
$authorizedGroupFilter = function (ISettings $settings) use ($authorizedSettingsClasses) {
return in_array(get_class($settings), $authorizedSettingsClasses) === true;
};
}
$appSettings = $this->getSettings('admin', $section, $authorizedGroupFilter);
}

Expand Down