You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ServerDevNotice.php 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. /**
  3. * @copyright 2016, Roeland Jago Douma <roeland@famdouma.nl>
  4. *
  5. * @author Jan C. Borchardt <hey@jancborchardt.net>
  6. * @author Julius Härtl <jus@bitgrid.net>
  7. * @author Roeland Jago Douma <roeland@famdouma.nl>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. namespace OCA\Settings\Settings\Personal;
  26. use OCA\Viewer\Event\LoadViewer;
  27. use OCP\AppFramework\Http\TemplateResponse;
  28. use OCP\AppFramework\Services\IInitialState;
  29. use OCP\EventDispatcher\IEventDispatcher;
  30. use OCP\Files\IRootFolder;
  31. use OCP\IURLGenerator;
  32. use OCP\IUserSession;
  33. use OCP\Settings\ISettings;
  34. use OCP\Support\Subscription\IRegistry;
  35. use OCP\Util;
  36. class ServerDevNotice implements ISettings {
  37. /** @var IRegistry */
  38. private $registry;
  39. /** @var IEventDispatcher */
  40. private $eventDispatcher;
  41. /** @var IRootFolder */
  42. private $rootFolder;
  43. /** @var IUserSession */
  44. private $userSession;
  45. /** @var IInitialState */
  46. private $initialState;
  47. /** @var IURLGenerator */
  48. private $urlGenerator;
  49. public function __construct(IRegistry $registry,
  50. IEventDispatcher $eventDispatcher,
  51. IRootFolder $rootFolder,
  52. IUserSession $userSession,
  53. IInitialState $initialState,
  54. IURLGenerator $urlGenerator) {
  55. $this->registry = $registry;
  56. $this->eventDispatcher = $eventDispatcher;
  57. $this->rootFolder = $rootFolder;
  58. $this->userSession = $userSession;
  59. $this->initialState = $initialState;
  60. $this->urlGenerator = $urlGenerator;
  61. }
  62. /**
  63. * @return TemplateResponse
  64. */
  65. public function getForm() {
  66. $userFolder = $this->rootFolder->getUserFolder($this->userSession->getUser()->getUID());
  67. $hasInitialState = false;
  68. // If the Reasons to use Nextcloud.pdf file is here, let's init Viewer
  69. if ($userFolder->nodeExists('Reasons to use Nextcloud.pdf')) {
  70. $this->eventDispatcher->dispatch(LoadViewer::class, new LoadViewer());
  71. $hasInitialState = true;
  72. }
  73. // Always load the script
  74. Util::addScript('settings', 'vue-settings-nextcloud-pdf');
  75. $this->initialState->provideInitialState('has-reasons-use-nextcloud-pdf', $hasInitialState);
  76. return new TemplateResponse('settings', 'settings/personal/development.notice', [
  77. 'reasons-use-nextcloud-pdf-link' => $this->urlGenerator->linkToRoute('settings.Reasons.getPdf')
  78. ]);
  79. }
  80. /**
  81. * @return string the section ID, e.g. 'sharing'
  82. */
  83. public function getSection() {
  84. if ($this->registry->delegateHasValidSubscription()) {
  85. return null;
  86. }
  87. return 'personal-info';
  88. }
  89. /**
  90. * @return int whether the form should be rather on the top or bottom of
  91. * the admin section. The forms are arranged in ascending order of the
  92. * priority values. It is required to return a value between 0 and 100.
  93. *
  94. * E.g.: 70
  95. */
  96. public function getPriority() {
  97. return 1000;
  98. }
  99. }