1
0

SettingsController.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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\JSONResponse;
  11. use OCP\IConfig;
  12. use OCP\IRequest;
  13. class SettingsController extends Controller {
  14. /** @var IConfig */
  15. private $config;
  16. /** @var string */
  17. private $userId;
  18. public function __construct(IRequest $request,
  19. IConfig $config,
  20. string $userId) {
  21. parent::__construct(Application::APP_ID, $request);
  22. $this->config = $config;
  23. $this->userId = $userId;
  24. }
  25. /**
  26. * @NoAdminRequired
  27. */
  28. public function setDefaultAccept(bool $accept): JSONResponse {
  29. $this->config->setUserValue($this->userId, Application::APP_ID, 'default_accept', $accept ? 'yes' : 'no');
  30. return new JSONResponse();
  31. }
  32. /**
  33. * @NoAdminRequired
  34. */
  35. public function setUserShareFolder(string $shareFolder): JSONResponse {
  36. $this->config->setUserValue($this->userId, Application::APP_ID, 'share_folder', $shareFolder);
  37. return new JSONResponse();
  38. }
  39. /**
  40. * @NoAdminRequired
  41. */
  42. public function resetUserShareFolder(): JSONResponse {
  43. $this->config->deleteUserValue($this->userId, Application::APP_ID, 'share_folder');
  44. return new JSONResponse();
  45. }
  46. }