SettingsController.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. /** @var IConfig */
  16. private $config;
  17. /** @var string */
  18. private $userId;
  19. public function __construct(IRequest $request,
  20. IConfig $config,
  21. string $userId) {
  22. parent::__construct(Application::APP_ID, $request);
  23. $this->config = $config;
  24. $this->userId = $userId;
  25. }
  26. #[NoAdminRequired]
  27. public function setDefaultAccept(bool $accept): JSONResponse {
  28. $this->config->setUserValue($this->userId, Application::APP_ID, 'default_accept', $accept ? 'yes' : 'no');
  29. return new JSONResponse();
  30. }
  31. #[NoAdminRequired]
  32. public function setUserShareFolder(string $shareFolder): JSONResponse {
  33. $this->config->setUserValue($this->userId, Application::APP_ID, 'share_folder', $shareFolder);
  34. return new JSONResponse();
  35. }
  36. #[NoAdminRequired]
  37. public function resetUserShareFolder(): JSONResponse {
  38. $this->config->deleteUserValue($this->userId, Application::APP_ID, 'share_folder');
  39. return new JSONResponse();
  40. }
  41. }