nextcloud/apps/encryption/settings/settings-personal.php

76 lines
2.2 KiB
PHP
Raw Normal View History

2015-02-24 21:05:19 +03:00
<?php
/**
2016-05-26 20:56:05 +03:00
* @author Björn Schießle <bjoern@schiessle.org>
* @author Clark Tomlinson <fallen013@gmail.com>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
2016-01-12 17:02:16 +03:00
* @copyright Copyright (c) 2016, ownCloud, Inc.
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
2015-02-24 21:05:19 +03:00
*/
$session = new \OCA\Encryption\Session(\OC::$server->getSession());
2015-04-02 14:12:05 +03:00
$userSession = \OC::$server->getUserSession();
2015-04-02 14:12:05 +03:00
$template = new OCP\Template('encryption', 'settings-personal');
$crypt = new \OCA\Encryption\Crypto\Crypt(
\OC::$server->getLogger(),
2015-04-02 14:12:05 +03:00
$userSession,
\OC::$server->getConfig(),
\OC::$server->getL10N('encryption'));
2015-03-31 18:13:36 +03:00
$util = new \OCA\Encryption\Util(
new \OC\Files\View(),
$crypt,
\OC::$server->getLogger(),
2015-04-02 14:12:05 +03:00
$userSession,
\OC::$server->getConfig(),
\OC::$server->getUserManager());
2015-03-31 18:13:36 +03:00
2015-04-02 14:12:05 +03:00
$keyManager = new \OCA\Encryption\KeyManager(
\OC::$server->getEncryptionKeyStorage(),
$crypt,
\OC::$server->getConfig(),
2015-04-02 14:12:05 +03:00
$userSession,
$session,
2015-03-31 18:13:36 +03:00
\OC::$server->getLogger(), $util);
2015-02-24 21:05:19 +03:00
2015-04-02 14:12:05 +03:00
$user = $userSession->getUser()->getUID();
2015-02-24 21:05:19 +03:00
$view = new \OC\Files\View('/');
2015-03-31 18:13:36 +03:00
$privateKeySet = $session->isPrivateKeySet();
2015-02-24 21:05:19 +03:00
// did we tried to initialize the keys for this session?
$initialized = $session->getStatus();
2015-02-24 21:05:19 +03:00
2015-03-27 03:35:36 +03:00
$recoveryAdminEnabled = \OC::$server->getConfig()->getAppValue('encryption', 'recoveryAdminEnabled');
$recoveryEnabledForUser = $util->isRecoveryEnabledForUser($user);
2015-02-24 21:05:19 +03:00
$result = false;
if ($recoveryAdminEnabled || !$privateKeySet) {
2015-04-02 14:12:05 +03:00
$template->assign('recoveryEnabled', $recoveryAdminEnabled);
$template->assign('recoveryEnabledForUser', $recoveryEnabledForUser);
$template->assign('privateKeySet', $privateKeySet);
$template->assign('initialized', $initialized);
2015-02-24 21:05:19 +03:00
2015-04-02 14:12:05 +03:00
$result = $template->fetchPage();
2015-02-24 21:05:19 +03:00
}
return $result;