summaryrefslogtreecommitdiffstats
path: root/apps/encryption/lib
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2016-08-11 01:41:18 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2016-08-11 01:41:18 +0200
commitf3b15a9ab97ce4498bafc731dc24350e98a7cb51 (patch)
tree138f9aa4ea52bcd7c098d8454c1bca1fd6e1dcba /apps/encryption/lib
parent0fc34c99f4e1dbe26e5074102f48f75d70fe97d0 (diff)
downloadnextcloud-server-f3b15a9ab97ce4498bafc731dc24350e98a7cb51.tar.gz
nextcloud-server-f3b15a9ab97ce4498bafc731dc24350e98a7cb51.zip
fixes, improvements, and another app:
* setupSettings now also triggered on enable * fixes detection of present admin section or settings in the DB * add update routine in such cases * encryption app migrated
Diffstat (limited to 'apps/encryption/lib')
-rw-r--r--apps/encryption/lib/AppInfo/Application.php1
-rw-r--r--apps/encryption/lib/Settings/Admin.php127
2 files changed, 127 insertions, 1 deletions
diff --git a/apps/encryption/lib/AppInfo/Application.php b/apps/encryption/lib/AppInfo/Application.php
index bba522fbc8c..a43646d86d9 100644
--- a/apps/encryption/lib/AppInfo/Application.php
+++ b/apps/encryption/lib/AppInfo/Application.php
@@ -269,7 +269,6 @@ class Application extends \OCP\AppFramework\App {
public function registerSettings() {
// Register settings scripts
- App::registerAdmin('encryption', 'settings/settings-admin');
App::registerPersonal('encryption', 'settings/settings-personal');
}
}
diff --git a/apps/encryption/lib/Settings/Admin.php b/apps/encryption/lib/Settings/Admin.php
new file mode 100644
index 00000000000..71a365caee1
--- /dev/null
+++ b/apps/encryption/lib/Settings/Admin.php
@@ -0,0 +1,127 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Encryption\Settings;
+
+use OC\Files\View;
+use OCA\Encryption\Crypto\Crypt;
+use OCA\Encryption\Session;
+use OCA\Encryption\Util;
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\IL10N;
+use OCP\ILogger;
+use OCP\ISession;
+use OCP\IUserManager;
+use OCP\IUserSession;
+use OCP\Settings\IAdmin;
+use OCP\IConfig;
+
+class Admin implements IAdmin {
+
+ /** @var IL10N */
+ private $l;
+
+ /** @var ILogger */
+ private $logger;
+
+ /** @var IUserSession */
+ private $userSession;
+
+ /** @var IConfig */
+ private $config;
+
+ /** @var IUserManager */
+ private $userManager;
+
+ /** @var ISession */
+ private $session;
+
+ public function __construct(
+ IL10N $l,
+ ILogger $logger,
+ IUserSession $userSession,
+ IConfig $config,
+ IUserManager $userManager,
+ ISession $session
+ ) {
+ $this->l = $l;
+ $this->logger = $logger;
+ $this->userSession = $userSession;
+ $this->config = $config;
+ $this->userManager = $userManager;
+ $this->session = $session;
+ }
+
+ /**
+ * @return TemplateResponse
+ */
+ public function getForm() {
+ $crypt = new Crypt(
+ $this->logger,
+ $this->userSession,
+ $this->config,
+ $this->l);
+
+ $util = new Util(
+ new View(),
+ $crypt,
+ $this->logger,
+ $this->userSession,
+ $this->config,
+ $this->userManager);
+
+ // Check if an adminRecovery account is enabled for recovering files after lost pwd
+ $recoveryAdminEnabled = $this->config->getAppValue('encryption', 'recoveryAdminEnabled', '0');
+ $session = new Session($this->session);
+
+ $encryptHomeStorage = $util->shouldEncryptHomeStorage();
+
+ $parameters = [
+ 'recoveryEnabled' => $recoveryAdminEnabled,
+ 'initStatus' => $session->getStatus(),
+ 'encryptHomeStorage' => $encryptHomeStorage,
+ 'masterKeyEnabled' => $util->isMasterKeyEnabled(),
+ ];
+
+ return new TemplateResponse('encryption', 'settings-admin', $parameters, '');
+ }
+
+ /**
+ * @return string the section ID, e.g. 'sharing'
+ */
+ public function getSection() {
+ return 'encryption';
+ }
+
+ /**
+ * @return int whether the form should be rather on the top or bottom of
+ * the admin section. The forms are arranged in ascending order of the
+ * priority values. It is required to return a value between 0 and 100.
+ *
+ * E.g.: 70
+ */
+ public function getPriority() {
+ return 5;
+ }
+
+}