Admin.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 Bjoern Schiessle <bjoern@schiessle.org>
  4. *
  5. * @author Bjoern Schiessle <bjoern@schiessle.org>
  6. * @author Nicolas SIMIDE <2083596+dems54@users.noreply.github.com>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCA\ShareByMail\Settings;
  25. use OCP\AppFramework\Http\TemplateResponse;
  26. use OCP\AppFramework\Services\IInitialState;
  27. use OCP\IL10N;
  28. use OCP\Settings\IDelegatedSettings;
  29. class Admin implements IDelegatedSettings {
  30. private SettingsManager $settingsManager;
  31. private IL10N $l;
  32. private IInitialState $initialState;
  33. public function __construct(SettingsManager $settingsManager, IL10N $l, IInitialState $initialState) {
  34. $this->settingsManager = $settingsManager;
  35. $this->l = $l;
  36. $this->initialState = $initialState;
  37. }
  38. /**
  39. * @return TemplateResponse
  40. */
  41. public function getForm() {
  42. $this->initialState->provideInitialState('sendPasswordMail', $this->settingsManager->sendPasswordByMail());
  43. $this->initialState->provideInitialState('replyToInitiator', $this->settingsManager->replyToInitiator());
  44. return new TemplateResponse('sharebymail', 'settings-admin', [], '');
  45. }
  46. /**
  47. * @return string the section ID, e.g. 'sharing'
  48. */
  49. public function getSection() {
  50. return 'sharing';
  51. }
  52. /**
  53. * @return int whether the form should be rather on the top or bottom of
  54. * the admin section. The forms are arranged in ascending order of the
  55. * priority values. It is required to return a value between 0 and 100.
  56. *
  57. * E.g.: 70
  58. */
  59. public function getPriority() {
  60. return 40;
  61. }
  62. public function getName(): ?string {
  63. return $this->l->t('Share by mail');
  64. }
  65. public function getAuthorizedAppConfig(): array {
  66. return [
  67. 'sharebymail' => ['s/(sendpasswordmail|replyToInitiator)/'],
  68. ];
  69. }
  70. }