Skip to content

Commit 1085e55

Browse files
IONOS(admin-delegation): implement delegated settings logic in Manager and NavigationManager
Signed-off-by: Misha M.-Kupriyanov <kupriyanov@strato.de>
1 parent b1c78f8 commit 1085e55

File tree

2 files changed

+39
-19
lines changed

2 files changed

+39
-19
lines changed

lib/private/NavigationManager.php

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -267,25 +267,38 @@ private function init(bool $resolveClosures = true): void {
267267
'name' => $l->t('Apps'),
268268
]);
269269

270-
// Personal settings
271-
$this->add([
272-
'type' => 'settings',
273-
'id' => 'settings',
274-
'order' => 3,
275-
'href' => $this->urlGenerator->linkToRoute('settings.PersonalSettings.index'),
276-
'name' => $l->t('Personal settings'),
277-
'icon' => $this->urlGenerator->imagePath('settings', 'personal.svg'),
278-
]);
279-
280-
// Admin settings
281-
$this->add([
282-
'type' => 'settings',
283-
'id' => 'admin_settings',
284-
'order' => 4,
285-
'href' => $this->urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => 'overview']),
286-
'name' => $l->t('Administration settings'),
287-
'icon' => $this->urlGenerator->imagePath('settings', 'admin.svg'),
288-
]);
270+
$hasDelegatedSettings = $this->config->getSystemValueBool('settings.only-delegated-settings');
271+
272+
if ($hasDelegatedSettings) {
273+
$this->add([
274+
'type' => 'settings',
275+
'id' => 'settings',
276+
'order' => 3,
277+
'href' => $this->urlGenerator->linkToRoute('settings.PersonalSettings.index'),
278+
'name' => $l->t('Settings'),
279+
'icon' => $this->urlGenerator->imagePath('settings', 'admin.svg'),
280+
]);
281+
} else {
282+
// Personal settings
283+
$this->add([
284+
'type' => 'settings',
285+
'id' => 'settings',
286+
'order' => 3,
287+
'href' => $this->urlGenerator->linkToRoute('settings.PersonalSettings.index'),
288+
'name' => $l->t('Personal settings'),
289+
'icon' => $this->urlGenerator->imagePath('settings', 'personal.svg'),
290+
]);
291+
292+
// Admin settings
293+
$this->add([
294+
'type' => 'settings',
295+
'id' => 'admin_settings',
296+
'order' => 4,
297+
'href' => $this->urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => 'overview']),
298+
'name' => $l->t('Administration settings'),
299+
'icon' => $this->urlGenerator->imagePath('settings', 'admin.svg'),
300+
]);
301+
}
289302
} else {
290303
// Personal settings
291304
$this->add([

lib/private/Settings/Manager.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Closure;
1010
use OCP\AppFramework\QueryException;
1111
use OCP\Group\ISubAdmin;
12+
use OCP\IConfig;
1213
use OCP\IGroupManager;
1314
use OCP\IL10N;
1415
use OCP\IServerContainer;
@@ -54,6 +55,7 @@ public function __construct(
5455
AuthorizedGroupMapper $mapper,
5556
IGroupManager $groupManager,
5657
ISubAdmin $subAdmin,
58+
private IConfig $config
5759
) {
5860
$this->log = $log;
5961
$this->l10nFactory = $l10nFactory;
@@ -303,6 +305,11 @@ public function getPersonalSettings(string $section): array {
303305
*/
304306
public function getAllowedAdminSettings(string $section, IUser $user): array {
305307
$isAdmin = $this->groupManager->isAdmin($user->getUID());
308+
309+
if ($this->config->getSystemValueBool('settings.only-delegated-settings')) {
310+
$isAdmin = false;
311+
}
312+
306313
if ($isAdmin) {
307314
$appSettings = $this->getSettings('admin', $section);
308315
} else {

0 commit comments

Comments
 (0)