settings-personal.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Björn Schießle <bjoern@schiessle.org>
  6. * @author Clark Tomlinson <fallen013@gmail.com>
  7. * @author Thomas Müller <thomas.mueller@tmit.eu>
  8. *
  9. * @license AGPL-3.0
  10. *
  11. * This code is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License, version 3,
  13. * as published by the Free Software Foundation.
  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, version 3,
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>
  22. *
  23. */
  24. $session = new \OCA\Encryption\Session(\OC::$server->getSession());
  25. $userSession = \OC::$server->getUserSession();
  26. $template = new OCP\Template('encryption', 'settings-personal');
  27. $crypt = new \OCA\Encryption\Crypto\Crypt(
  28. \OC::$server->getLogger(),
  29. $userSession,
  30. \OC::$server->getConfig(),
  31. \OC::$server->getL10N('encryption'));
  32. $util = new \OCA\Encryption\Util(
  33. new \OC\Files\View(),
  34. $crypt,
  35. \OC::$server->getLogger(),
  36. $userSession,
  37. \OC::$server->getConfig(),
  38. \OC::$server->getUserManager());
  39. $keyManager = new \OCA\Encryption\KeyManager(
  40. \OC::$server->getEncryptionKeyStorage(),
  41. $crypt,
  42. \OC::$server->getConfig(),
  43. $userSession,
  44. $session,
  45. \OC::$server->getLogger(), $util);
  46. $user = $userSession->getUser()->getUID();
  47. $view = new \OC\Files\View('/');
  48. $privateKeySet = $session->isPrivateKeySet();
  49. // did we tried to initialize the keys for this session?
  50. $initialized = $session->getStatus();
  51. $recoveryAdminEnabled = \OC::$server->getConfig()->getAppValue('encryption', 'recoveryAdminEnabled');
  52. $recoveryEnabledForUser = $util->isRecoveryEnabledForUser($user);
  53. $result = false;
  54. if ($recoveryAdminEnabled || !$privateKeySet) {
  55. $template->assign('recoveryEnabled', $recoveryAdminEnabled);
  56. $template->assign('recoveryEnabledForUser', $recoveryEnabledForUser);
  57. $template->assign('privateKeySet', $privateKeySet);
  58. $template->assign('initialized', $initialized);
  59. $result = $template->fetchPage();
  60. }
  61. return $result;