settings-personal.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * Copyright (c) 2013 Sam Tuke <samtuke@owncloud.com>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. // Add CSS stylesheet
  9. \OC_Util::addStyle('files_encryption', 'settings-personal');
  10. $tmpl = new OCP\Template('files_encryption', 'settings-personal');
  11. $user = \OCP\USER::getUser();
  12. $view = new \OC_FilesystemView('/');
  13. $util = new \OCA\Encryption\Util($view, $user);
  14. $session = new \OCA\Encryption\Session($view);
  15. $privateKeySet = $session->getPrivateKey() !== false;
  16. // did we tried to initialize the keys for this session?
  17. $initialized = $session->getInitialized();
  18. $recoveryAdminEnabled = OC_Appconfig::getValue('files_encryption', 'recoveryAdminEnabled');
  19. $recoveryEnabledForUser = $util->recoveryEnabledForUser();
  20. $result = false;
  21. if ($recoveryAdminEnabled || !$privateKeySet) {
  22. \OCP\Util::addscript('files_encryption', 'settings-personal');
  23. \OCP\Util::addScript('settings', 'personal');
  24. $tmpl->assign('recoveryEnabled', $recoveryAdminEnabled);
  25. $tmpl->assign('recoveryEnabledForUser', $recoveryEnabledForUser);
  26. $tmpl->assign('privateKeySet', $privateKeySet);
  27. $tmpl->assign('initialized', $initialized);
  28. $result = $tmpl->fetchPage();
  29. }
  30. return $result;