1
0

AdminSettingsController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCA\Settings\Controller;
  7. use OCP\AppFramework\Controller;
  8. use OCP\AppFramework\Http\Attribute\NoAdminRequired;
  9. use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
  10. use OCP\AppFramework\Http\Attribute\OpenAPI;
  11. use OCP\AppFramework\Http\TemplateResponse;
  12. use OCP\AppFramework\Services\IInitialState;
  13. use OCP\Group\ISubAdmin;
  14. use OCP\IGroupManager;
  15. use OCP\INavigationManager;
  16. use OCP\IRequest;
  17. use OCP\IUserSession;
  18. use OCP\Settings\IDeclarativeManager;
  19. use OCP\Settings\IManager as ISettingsManager;
  20. #[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
  21. class AdminSettingsController extends Controller {
  22. use CommonSettingsTrait;
  23. public function __construct(
  24. $appName,
  25. IRequest $request,
  26. INavigationManager $navigationManager,
  27. ISettingsManager $settingsManager,
  28. IUserSession $userSession,
  29. IGroupManager $groupManager,
  30. ISubAdmin $subAdmin,
  31. IDeclarativeManager $declarativeSettingsManager,
  32. IInitialState $initialState,
  33. ) {
  34. parent::__construct($appName, $request);
  35. $this->navigationManager = $navigationManager;
  36. $this->settingsManager = $settingsManager;
  37. $this->userSession = $userSession;
  38. $this->groupManager = $groupManager;
  39. $this->subAdmin = $subAdmin;
  40. $this->declarativeSettingsManager = $declarativeSettingsManager;
  41. $this->initialState = $initialState;
  42. }
  43. /**
  44. * @NoSubAdminRequired
  45. * We are checking the permissions in the getSettings method. If there is no allowed
  46. * settings for the given section. The user will be greeted by an error message.
  47. */
  48. #[NoAdminRequired]
  49. #[NoCSRFRequired]
  50. public function index(string $section): TemplateResponse {
  51. return $this->getIndexResponse(
  52. 'admin',
  53. $section,
  54. );
  55. }
  56. }