1
0

Personal.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\FederatedFileSharing\Settings;
  8. use OCA\FederatedFileSharing\FederatedShareProvider;
  9. use OCP\AppFramework\Http\TemplateResponse;
  10. use OCP\AppFramework\Services\IInitialState;
  11. use OCP\Defaults;
  12. use OCP\IURLGenerator;
  13. use OCP\IUserSession;
  14. use OCP\Settings\ISettings;
  15. class Personal implements ISettings {
  16. public function __construct(
  17. private FederatedShareProvider $federatedShareProvider,
  18. private IUserSession $userSession,
  19. private Defaults $defaults,
  20. private IInitialState $initialState,
  21. private IURLGenerator $urlGenerator,
  22. ) {
  23. }
  24. /**
  25. * @return TemplateResponse returns the instance with all parameters set, ready to be rendered
  26. * @since 9.1
  27. */
  28. public function getForm(): TemplateResponse {
  29. $cloudID = $this->userSession->getUser()->getCloudId();
  30. $url = 'https://nextcloud.com/sharing#' . $cloudID;
  31. $this->initialState->provideInitialState('color', $this->defaults->getDefaultColorPrimary());
  32. $this->initialState->provideInitialState('textColor', $this->defaults->getDefaultTextColorPrimary());
  33. $this->initialState->provideInitialState('logoPath', $this->defaults->getLogo());
  34. $this->initialState->provideInitialState('reference', $url);
  35. $this->initialState->provideInitialState('cloudId', $cloudID);
  36. $this->initialState->provideInitialState('docUrlFederated', $this->urlGenerator->linkToDocs('user-sharing-federated'));
  37. return new TemplateResponse('federatedfilesharing', 'settings-personal', [], TemplateResponse::RENDER_AS_BLANK);
  38. }
  39. /**
  40. * @return string the section ID, e.g. 'sharing'
  41. * @since 9.1
  42. */
  43. public function getSection(): ?string {
  44. if ($this->federatedShareProvider->isIncomingServer2serverShareEnabled() ||
  45. $this->federatedShareProvider->isIncomingServer2serverGroupShareEnabled()) {
  46. return 'sharing';
  47. }
  48. return null;
  49. }
  50. /**
  51. * @return int whether the form should be rather on the top or bottom of
  52. * the admin section. The forms are arranged in ascending order of the
  53. * priority values. It is required to return a value between 0 and 100.
  54. *
  55. * E.g.: 70
  56. * @since 9.1
  57. */
  58. public function getPriority(): int {
  59. return 40;
  60. }
  61. }