1
0

Admin.php 3.2 KB

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