1
0

Admin.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. *
  7. * @license GNU AGPL version 3 or any later version
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as
  11. * published by the Free Software Foundation, either version 3 of the
  12. * License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. */
  23. namespace OCA\Encryption\Settings;
  24. use OC\Files\View;
  25. use OCA\Encryption\Crypto\Crypt;
  26. use OCA\Encryption\Session;
  27. use OCA\Encryption\Util;
  28. use OCP\AppFramework\Http\TemplateResponse;
  29. use OCP\IL10N;
  30. use OCP\ILogger;
  31. use OCP\ISession;
  32. use OCP\IUserManager;
  33. use OCP\IUserSession;
  34. use OCP\Settings\ISettings;
  35. use OCP\IConfig;
  36. class Admin implements ISettings {
  37. /** @var IL10N */
  38. private $l;
  39. /** @var ILogger */
  40. private $logger;
  41. /** @var IUserSession */
  42. private $userSession;
  43. /** @var IConfig */
  44. private $config;
  45. /** @var IUserManager */
  46. private $userManager;
  47. /** @var ISession */
  48. private $session;
  49. public function __construct(
  50. IL10N $l,
  51. ILogger $logger,
  52. IUserSession $userSession,
  53. IConfig $config,
  54. IUserManager $userManager,
  55. ISession $session
  56. ) {
  57. $this->l = $l;
  58. $this->logger = $logger;
  59. $this->userSession = $userSession;
  60. $this->config = $config;
  61. $this->userManager = $userManager;
  62. $this->session = $session;
  63. }
  64. /**
  65. * @return TemplateResponse
  66. */
  67. public function getForm() {
  68. $crypt = new Crypt(
  69. $this->logger,
  70. $this->userSession,
  71. $this->config,
  72. $this->l);
  73. $util = new Util(
  74. new View(),
  75. $crypt,
  76. $this->logger,
  77. $this->userSession,
  78. $this->config,
  79. $this->userManager);
  80. // Check if an adminRecovery account is enabled for recovering files after lost pwd
  81. $recoveryAdminEnabled = $this->config->getAppValue('encryption', 'recoveryAdminEnabled', '0');
  82. $session = new Session($this->session);
  83. $encryptHomeStorage = $util->shouldEncryptHomeStorage();
  84. $parameters = [
  85. 'recoveryEnabled' => $recoveryAdminEnabled,
  86. 'initStatus' => $session->getStatus(),
  87. 'encryptHomeStorage' => $encryptHomeStorage,
  88. 'masterKeyEnabled' => $util->isMasterKeyEnabled(),
  89. ];
  90. return new TemplateResponse('encryption', 'settings-admin', $parameters, '');
  91. }
  92. /**
  93. * @return string the section ID, e.g. 'sharing'
  94. */
  95. public function getSection() {
  96. return 'encryption';
  97. }
  98. /**
  99. * @return int whether the form should be rather on the top or bottom of
  100. * the admin section. The forms are arranged in ascending order of the
  101. * priority values. It is required to return a value between 0 and 100.
  102. *
  103. * E.g.: 70
  104. */
  105. public function getPriority() {
  106. return 5;
  107. }
  108. }