1
0

Admin.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCA\Encryption\Settings;
  7. use OC\Files\View;
  8. use OCA\Encryption\Crypto\Crypt;
  9. use OCA\Encryption\Session;
  10. use OCA\Encryption\Util;
  11. use OCP\AppFramework\Http\TemplateResponse;
  12. use OCP\IConfig;
  13. use OCP\IL10N;
  14. use OCP\ISession;
  15. use OCP\IUserManager;
  16. use OCP\IUserSession;
  17. use OCP\Settings\ISettings;
  18. use Psr\Log\LoggerInterface;
  19. class Admin implements ISettings {
  20. public function __construct(
  21. private IL10N $l,
  22. private LoggerInterface $logger,
  23. private IUserSession $userSession,
  24. private IConfig $config,
  25. private IUserManager $userManager,
  26. private ISession $session,
  27. ) {
  28. }
  29. /**
  30. * @return TemplateResponse
  31. */
  32. public function getForm() {
  33. $crypt = new Crypt(
  34. $this->logger,
  35. $this->userSession,
  36. $this->config,
  37. $this->l);
  38. $util = new Util(
  39. new View(),
  40. $crypt,
  41. $this->userSession,
  42. $this->config,
  43. $this->userManager);
  44. // Check if an adminRecovery account is enabled for recovering files after lost pwd
  45. $recoveryAdminEnabled = $this->config->getAppValue('encryption', 'recoveryAdminEnabled', '0');
  46. $session = new Session($this->session);
  47. $encryptHomeStorage = $util->shouldEncryptHomeStorage();
  48. $parameters = [
  49. 'recoveryEnabled' => $recoveryAdminEnabled,
  50. 'initStatus' => $session->getStatus(),
  51. 'encryptHomeStorage' => $encryptHomeStorage,
  52. 'masterKeyEnabled' => $util->isMasterKeyEnabled(),
  53. ];
  54. return new TemplateResponse('encryption', 'settings-admin', $parameters, '');
  55. }
  56. /**
  57. * @return string the section ID, e.g. 'sharing'
  58. */
  59. public function getSection() {
  60. return 'security';
  61. }
  62. /**
  63. * @return int whether the form should be rather on the top or bottom of
  64. * the admin section. The forms are arranged in ascending order of the
  65. * priority values. It is required to return a value between 0 and 100.
  66. *
  67. * E.g.: 70
  68. */
  69. public function getPriority() {
  70. return 11;
  71. }
  72. }