SettingsController.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Files_Sharing\Controller;
  8. use OCA\Files_Sharing\AppInfo\Application;
  9. use OCP\AppFramework\Controller;
  10. use OCP\AppFramework\Http\Attribute\NoAdminRequired;
  11. use OCP\AppFramework\Http\JSONResponse;
  12. use OCP\IConfig;
  13. use OCP\IRequest;
  14. class SettingsController extends Controller {
  15. public function __construct(
  16. IRequest $request,
  17. private IConfig $config,
  18. private string $userId,
  19. ) {
  20. parent::__construct(Application::APP_ID, $request);
  21. }
  22. #[NoAdminRequired]
  23. public function setDefaultAccept(bool $accept): JSONResponse {
  24. $this->config->setUserValue($this->userId, Application::APP_ID, 'default_accept', $accept ? 'yes' : 'no');
  25. return new JSONResponse();
  26. }
  27. #[NoAdminRequired]
  28. public function setUserShareFolder(string $shareFolder): JSONResponse {
  29. $this->config->setUserValue($this->userId, Application::APP_ID, 'share_folder', $shareFolder);
  30. return new JSONResponse();
  31. }
  32. #[NoAdminRequired]
  33. public function resetUserShareFolder(): JSONResponse {
  34. $this->config->deleteUserValue($this->userId, Application::APP_ID, 'share_folder');
  35. return new JSONResponse();
  36. }
  37. }