diff --git a/apps/encryption/appinfo/app.php b/apps/encryption/appinfo/app.php
index 22c35f8791..950166dca2 100644
--- a/apps/encryption/appinfo/app.php
+++ b/apps/encryption/appinfo/app.php
@@ -31,5 +31,4 @@ $app = new Application([], $encryptionSystemReady);
if ($encryptionSystemReady) {
$app->registerEncryptionModule();
$app->registerHooks();
- $app->registerSettings();
}
diff --git a/apps/encryption/appinfo/info.xml b/apps/encryption/appinfo/info.xml
index 36b6774c6e..7cfdc93438 100644
--- a/apps/encryption/appinfo/info.xml
+++ b/apps/encryption/appinfo/info.xml
@@ -19,7 +19,7 @@
user-encryptionadmin-encryption
- 1.7.0
+ 1.7.1
@@ -29,6 +29,7 @@
OCA\Encryption\Settings\Admin
+ OCA\Encryption\Settings\PersonalOCA\Encryption\Command\EnableMasterKey
diff --git a/apps/encryption/lib/AppInfo/Application.php b/apps/encryption/lib/AppInfo/Application.php
index a43646d86d..56c2dafdab 100644
--- a/apps/encryption/lib/AppInfo/Application.php
+++ b/apps/encryption/lib/AppInfo/Application.php
@@ -266,9 +266,4 @@ class Application extends \OCP\AppFramework\App {
);
}
-
- public function registerSettings() {
- // Register settings scripts
- App::registerPersonal('encryption', 'settings/settings-personal');
- }
}
diff --git a/apps/encryption/lib/Settings/Personal.php b/apps/encryption/lib/Settings/Personal.php
new file mode 100644
index 0000000000..5b01c22453
--- /dev/null
+++ b/apps/encryption/lib/Settings/Personal.php
@@ -0,0 +1,95 @@
+
+ *
+ * @author Arthur Schiwon
+ *
+ * @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 .
+ *
+ */
+
+namespace OCA\Encryption\Settings;
+
+
+use OCA\Encryption\Session;
+use OCA\Encryption\Util;
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\IConfig;
+use OCP\IUserSession;
+use OCP\Settings\ISettings;
+
+class Personal implements ISettings {
+
+ /** @var IConfig */
+ private $config;
+ /** @var Session */
+ private $session;
+ /** @var Util */
+ private $util;
+ /** @var IUserSession */
+ private $userSession;
+
+ public function __construct(IConfig $config, Session $session, Util $util, IUserSession $userSession) {
+ $this->config = $config;
+ $this->session = $session;
+ $this->util = $util;
+ $this->userSession = $userSession;
+ }
+
+ /**
+ * @return TemplateResponse returns the instance with all parameters set, ready to be rendered
+ * @since 9.1
+ */
+ public function getForm() {
+ $recoveryAdminEnabled = $this->config->getAppValue('encryption', 'recoveryAdminEnabled');
+ $privateKeySet = $this->session->isPrivateKeySet();
+
+ if (!$recoveryAdminEnabled && $privateKeySet) {
+ return new TemplateResponse('settings', 'settings/empty', [], '');
+ }
+
+ $userId = $this->userSession->getUser()->getUID();
+ $recoveryEnabledForUser = $this->util->isRecoveryEnabledForUser($userId);
+
+ $parameters = [
+ 'recoveryEnabled' => $recoveryAdminEnabled,
+ 'recoveryEnabledForUser' => $recoveryEnabledForUser,
+ 'privateKeySet' => $privateKeySet,
+ 'initialized' => $this->session->getStatus(),
+ ];
+ return new TemplateResponse('encryption', 'settings-personal', $parameters, '');
+ }
+
+ /**
+ * @return string the section ID, e.g. 'sharing'
+ * @since 9.1
+ */
+ public function getSection() {
+ return 'security';
+ }
+
+ /**
+ * @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
+ * @since 9.1
+ */
+ public function getPriority() {
+ return 80;
+ }
+}
diff --git a/apps/encryption/settings/settings-personal.php b/apps/encryption/settings/settings-personal.php
deleted file mode 100644
index 6608340888..0000000000
--- a/apps/encryption/settings/settings-personal.php
+++ /dev/null
@@ -1,76 +0,0 @@
-
- * @author Clark Tomlinson
- * @author Thomas Müller
- *
- * @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
- *
- */
-
-$session = new \OCA\Encryption\Session(\OC::$server->getSession());
-$userSession = \OC::$server->getUserSession();
-
-$template = new OCP\Template('encryption', 'settings-personal');
-$crypt = new \OCA\Encryption\Crypto\Crypt(
- \OC::$server->getLogger(),
- $userSession,
- \OC::$server->getConfig(),
- \OC::$server->getL10N('encryption'));
-
-$util = new \OCA\Encryption\Util(
- new \OC\Files\View(),
- $crypt,
- \OC::$server->getLogger(),
- $userSession,
- \OC::$server->getConfig(),
- \OC::$server->getUserManager());
-
-$keyManager = new \OCA\Encryption\KeyManager(
- \OC::$server->getEncryptionKeyStorage(),
- $crypt,
- \OC::$server->getConfig(),
- $userSession,
- $session,
- \OC::$server->getLogger(), $util);
-
-$user = $userSession->getUser()->getUID();
-
-$view = new \OC\Files\View('/');
-
-
-
-$privateKeySet = $session->isPrivateKeySet();
-// did we tried to initialize the keys for this session?
-$initialized = $session->getStatus();
-
-$recoveryAdminEnabled = \OC::$server->getConfig()->getAppValue('encryption', 'recoveryAdminEnabled');
-$recoveryEnabledForUser = $util->isRecoveryEnabledForUser($user);
-
-$result = false;
-
-if ($recoveryAdminEnabled || !$privateKeySet) {
- $template->assign('recoveryEnabled', $recoveryAdminEnabled);
- $template->assign('recoveryEnabledForUser', $recoveryEnabledForUser);
- $template->assign('privateKeySet', $privateKeySet);
- $template->assign('initialized', $initialized);
-
- $result = $template->fetchPage();
-}
-
-return $result;
-
diff --git a/apps/federatedfilesharing/appinfo/app.php b/apps/federatedfilesharing/appinfo/app.php
index b6a145bcc2..62265ff064 100644
--- a/apps/federatedfilesharing/appinfo/app.php
+++ b/apps/federatedfilesharing/appinfo/app.php
@@ -26,8 +26,6 @@ use OCA\FederatedFileSharing\Notifier;
$app = new \OCA\FederatedFileSharing\AppInfo\Application();
$eventDispatcher = \OC::$server->getEventDispatcher();
-$app->registerSettings();
-
$manager = \OC::$server->getNotificationManager();
$manager->registerNotifier(function() {
return \OC::$server->query(Notifier::class);
diff --git a/apps/federatedfilesharing/appinfo/info.xml b/apps/federatedfilesharing/appinfo/info.xml
index aaacf3ec80..ce2e2286be 100644
--- a/apps/federatedfilesharing/appinfo/info.xml
+++ b/apps/federatedfilesharing/appinfo/info.xml
@@ -6,7 +6,7 @@
AGPLBjoern SchiessleRoeland Jago Douma
- 1.3.0
+ 1.3.1FederatedFileSharingother
@@ -14,5 +14,7 @@
OCA\FederatedFileSharing\Settings\Admin
+ OCA\FederatedFileSharing\Settings\Personal
+ OCA\FederatedFileSharing\Settings\PersonalSection
diff --git a/apps/federatedfilesharing/lib/AppInfo/Application.php b/apps/federatedfilesharing/lib/AppInfo/Application.php
index 346d3c4e29..a2e2f76186 100644
--- a/apps/federatedfilesharing/lib/AppInfo/Application.php
+++ b/apps/federatedfilesharing/lib/AppInfo/Application.php
@@ -69,13 +69,6 @@ class Application extends App {
});
}
- /**
- * register personal and admin settings page
- */
- public function registerSettings() {
- \OCP\App::registerPersonal('federatedfilesharing', 'settings-personal');
- }
-
/**
* get instance of federated share provider
*
diff --git a/apps/federatedfilesharing/lib/Settings/Personal.php b/apps/federatedfilesharing/lib/Settings/Personal.php
new file mode 100644
index 0000000000..854f5f13ab
--- /dev/null
+++ b/apps/federatedfilesharing/lib/Settings/Personal.php
@@ -0,0 +1,101 @@
+
+ *
+ * @author Arthur Schiwon
+ *
+ * @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 .
+ *
+ */
+
+namespace OCA\FederatedFileSharing\Settings;
+
+
+use OCA\FederatedFileSharing\FederatedShareProvider;
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\IL10N;
+use OCP\IURLGenerator;
+use OCP\IUserSession;
+use OCP\Settings\ISettings;
+
+class Personal implements ISettings {
+
+ /** @var FederatedShareProvider */
+ private $federatedShareProvider;
+ /** @var IUserSession */
+ private $userSession;
+ /** @var IL10N */
+ private $l;
+ /** @var IURLGenerator */
+ private $urlGenerator;
+ /** @var \OC_Defaults */
+ private $defaults;
+
+ public function __construct(
+ FederatedShareProvider $federatedShareProvider, #
+ IUserSession $userSession,
+ IL10N $l,
+ IURLGenerator $urlGenerator,
+ \OC_Defaults $defaults
+ ) {
+ $this->federatedShareProvider = $federatedShareProvider;
+ $this->userSession = $userSession;
+ $this->l = $l;
+ $this->urlGenerator = $urlGenerator;
+ $this->defaults = $defaults;
+ }
+
+ /**
+ * @return TemplateResponse returns the instance with all parameters set, ready to be rendered
+ * @since 9.1
+ */
+ public function getForm() {
+ $cloudID = $this->userSession->getUser()->getCloudId();
+ $url = 'https://nextcloud.com/federation#' . $cloudID;
+
+ $parameters = [
+ 'outgoingServer2serverShareEnabled' => $this->federatedShareProvider->isOutgoingServer2serverShareEnabled(),
+ 'message_with_URL' => $this->l->t('Share with me through my #Nextcloud Federated Cloud ID, see %s', [$url]),
+ 'message_without_URL' => $this->l->t('Share with me through my #Nextcloud Federated Cloud ID', [$cloudID]),
+ 'logoPath' => $this->urlGenerator->imagePath('core', 'logo-icon.svg'),
+ 'reference' => $url,
+ 'cloudId' => $cloudID,
+ 'color' => $this->defaults->getColorPrimary(),
+ 'textColor' => "#ffffff",
+ ];
+ return new TemplateResponse('federatedfilesharing', 'settings-personal', $parameters, '');
+ }
+
+ /**
+ * @return string the section ID, e.g. 'sharing'
+ * @since 9.1
+ */
+ public function getSection() {
+ return 'sharing';
+ }
+
+ /**
+ * @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
+ * @since 9.1
+ */
+ public function getPriority() {
+ return 40;
+ }
+}
diff --git a/apps/federatedfilesharing/lib/Settings/PersonalSection.php b/apps/federatedfilesharing/lib/Settings/PersonalSection.php
new file mode 100644
index 0000000000..330a4efd7f
--- /dev/null
+++ b/apps/federatedfilesharing/lib/Settings/PersonalSection.php
@@ -0,0 +1,86 @@
+
+ *
+ * @author Arthur Schiwon
+ *
+ * @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 .
+ *
+ */
+
+namespace OCA\FederatedFileSharing\Settings;
+
+
+use OCP\IL10N;
+use OCP\IURLGenerator;
+use OCP\Settings\IIconSection;
+
+class PersonalSection implements IIconSection {
+ /** @var IURLGenerator */
+ private $urlGenerator;
+ /** @var IL10N */
+ private $l;
+
+ public function __construct(IURLGenerator $urlGenerator, IL10N $l) {
+ $this->urlGenerator = $urlGenerator;
+ $this->l = $l;
+ }
+
+ /**
+ * returns the relative path to an 16*16 icon describing the section.
+ * e.g. '/core/img/places/files.svg'
+ *
+ * @returns string
+ * @since 13.0.0
+ */
+ public function getIcon() {
+ return $this->urlGenerator->imagePath('core', 'actions/share.svg');
+ }
+
+ /**
+ * returns the ID of the section. It is supposed to be a lower case string,
+ * e.g. 'ldap'
+ *
+ * @returns string
+ * @since 9.1
+ */
+ public function getID() {
+ return 'sharing';
+ }
+
+ /**
+ * returns the translated name as it should be displayed, e.g. 'LDAP / AD
+ * integration'. Use the L10N service to translate it.
+ *
+ * @return string
+ * @since 9.1
+ */
+ public function getName() {
+ return $this->l->t('Sharing');
+ }
+
+ /**
+ * @return int whether the form should be rather on the top or bottom of
+ * the settings navigation. The sections are arranged in ascending order of
+ * the priority values. It is required to return a value between 0 and 99.
+ *
+ * E.g.: 70
+ * @since 9.1
+ */
+ public function getPriority() {
+ return 15;
+ }
+}
diff --git a/apps/federatedfilesharing/settings-personal.php b/apps/federatedfilesharing/settings-personal.php
deleted file mode 100644
index cd22cc1708..0000000000
--- a/apps/federatedfilesharing/settings-personal.php
+++ /dev/null
@@ -1,72 +0,0 @@
-
- * @author Björn Schießle
- * @author Jan-Christoph Borchardt
- * @author Thomas Müller
- *
- * @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
- *
- */
-
-use OCA\FederatedFileSharing\AppInfo\Application;
-
-\OC_Util::checkLoggedIn();
-
-$l = \OC::$server->getL10N('federatedfilesharing');
-
-$app = new Application();
-$federatedShareProvider = $app->getFederatedShareProvider();
-
-$isIE8 = false;
-preg_match('/MSIE (.*?);/', $_SERVER['HTTP_USER_AGENT'], $matches);
-if (count($matches) > 0 && $matches[1] <= 9) {
- $isIE8 = true;
-}
-
-$cloudID = \OC::$server->getUserSession()->getUser()->getCloudId();
-$url = 'https://nextcloud.com/federation#' . $cloudID;
-$logoPath = \OC::$server->getURLGenerator()->imagePath('core', 'logo-icon.svg');
-/** @var \OCP\Defaults $theme */
-$theme = \OC::$server->query(\OCP\Defaults::class);
-$color = $theme->getColorPrimary();
-$textColor = "#ffffff";
-if(\OC::$server->getAppManager()->isEnabledForUser("theming")) {
- $logoPath = $theme->getLogo();
- try {
- $util = \OC::$server->query("\OCA\Theming\Util");
- if($util->invertTextColor($color)) {
- $textColor = "#000000";
- }
- } catch (OCP\AppFramework\QueryException $e) {
-
- }
-}
-
-
-$tmpl = new OCP\Template('federatedfilesharing', 'settings-personal');
-$tmpl->assign('outgoingServer2serverShareEnabled', $federatedShareProvider->isOutgoingServer2serverShareEnabled());
-$tmpl->assign('message_with_URL', $l->t('Share with me through my #Nextcloud Federated Cloud ID, see %s', [$url]));
-$tmpl->assign('message_without_URL', $l->t('Share with me through my #Nextcloud Federated Cloud ID', [$cloudID]));
-$tmpl->assign('logoPath', $logoPath);
-$tmpl->assign('reference', $url);
-$tmpl->assign('cloudId', $cloudID);
-$tmpl->assign('showShareIT', !$isIE8);
-$tmpl->assign('color', $color);
-$tmpl->assign('textColor', $textColor);
-
-return $tmpl->fetchPage();
diff --git a/apps/federatedfilesharing/templates/settings-personal.php b/apps/federatedfilesharing/templates/settings-personal.php
index 126daae27d..c6be2a45f1 100644
--- a/apps/federatedfilesharing/templates/settings-personal.php
+++ b/apps/federatedfilesharing/templates/settings-personal.php
@@ -18,7 +18,6 @@ style('federatedfilesharing', 'settings-personal');
-
t('Share it so your friends can share files with you:')); ?>
-
diff --git a/apps/files_external/appinfo/app.php b/apps/files_external/appinfo/app.php
index ddf609129f..250cbbd00d 100644
--- a/apps/files_external/appinfo/app.php
+++ b/apps/files_external/appinfo/app.php
@@ -35,8 +35,6 @@ require_once __DIR__ . '/../3rdparty/autoload.php';
\OC_Mount_Config::$app = new \OCA\Files_External\AppInfo\Application();
$appContainer = \OC_Mount_Config::$app->getContainer();
-\OC_Mount_Config::$app->registerSettings();
-
\OCA\Files\App::getNavigationManager()->add(function () {
$l = \OC::$server->getL10N('files_external');
return [
diff --git a/apps/files_external/appinfo/info.xml b/apps/files_external/appinfo/info.xml
index 5772b89ba9..74cb3e64e4 100644
--- a/apps/files_external/appinfo/info.xml
+++ b/apps/files_external/appinfo/info.xml
@@ -14,7 +14,7 @@ External storage can be configured using the GUI or at the command line. This se
admin-external-storage
- 1.4.0
+ 1.4.1
@@ -29,6 +29,8 @@ External storage can be configured using the GUI or at the command line. This se
OCA\Files_External\Settings\AdminOCA\Files_External\Settings\Section
+ OCA\Files_External\Settings\Personal
+ OCA\Files_External\Settings\PersonalSection
diff --git a/apps/files_external/lib/AppInfo/Application.php b/apps/files_external/lib/AppInfo/Application.php
index fcf10adb37..0bbb81dfea 100644
--- a/apps/files_external/lib/AppInfo/Application.php
+++ b/apps/files_external/lib/AppInfo/Application.php
@@ -64,24 +64,6 @@ class Application extends App implements IBackendProvider, IAuthMechanismProvide
);
}
- /**
- * Register settings templates
- */
- public function registerSettings() {
- $container = $this->getContainer();
- $userSession = $container->getServer()->getUserSession();
- if (!$userSession->isLoggedIn()) {
- return;
- }
- $backendService = $container->query('OCA\\Files_External\\Service\\BackendService');
-
- /** @var \OCA\Files_External\Service\UserGlobalStoragesService $userGlobalStoragesService */
- $userGlobalStoragesService = $container->query('OCA\Files_External\Service\UserGlobalStoragesService');
- if (count($userGlobalStoragesService->getStorages()) > 0 || $backendService->isUserMountingAllowed()) {
- \OCP\App::registerPersonal('files_external', 'personal');
- }
- }
-
/**
* @{inheritdoc}
*/
diff --git a/apps/files_external/lib/Settings/Personal.php b/apps/files_external/lib/Settings/Personal.php
new file mode 100644
index 0000000000..946ba9f694
--- /dev/null
+++ b/apps/files_external/lib/Settings/Personal.php
@@ -0,0 +1,103 @@
+
+ *
+ * @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 .
+ *
+ */
+
+namespace OCA\Files_External\Settings;
+
+use OCA\Files_External\Lib\Auth\Password\GlobalAuth;
+use OCA\Files_External\Service\BackendService;
+use OCA\Files_External\Service\GlobalStoragesService;
+use OCA\Files_External\Service\UserGlobalStoragesService;
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\Encryption\IManager;
+use OCP\IUserSession;
+use OCP\Settings\ISettings;
+
+class Personal implements ISettings {
+
+ /** @var IManager */
+ private $encryptionManager;
+
+ /** @var UserGlobalStoragesService */
+ private $userGlobalStoragesService;
+
+ /** @var BackendService */
+ private $backendService;
+
+ /** @var GlobalAuth */
+ private $globalAuth;
+
+ /** @var IUserSession */
+ private $userSession;
+
+ public function __construct(
+ IManager $encryptionManager,
+ UserGlobalStoragesService $userGlobalStoragesService,
+ BackendService $backendService,
+ GlobalAuth $globalAuth,
+ IUserSession $userSession
+ ) {
+ $this->encryptionManager = $encryptionManager;
+ $this->userGlobalStoragesService = $userGlobalStoragesService;
+ $this->backendService = $backendService;
+ $this->globalAuth = $globalAuth;
+ $this->userSession = $userSession;
+ }
+
+ /**
+ * @return TemplateResponse
+ */
+ public function getForm() {
+ $uid = $this->userSession->getUser()->getUID();
+
+ $parameters = [
+ 'encryptionEnabled' => $this->encryptionManager->isEnabled(),
+ 'visibilityType' => BackendService::VISIBILITY_PERSONAL,
+ 'storages' => $this->userGlobalStoragesService->getStorages(),
+ 'backends' => $this->backendService->getAvailableBackends(),
+ 'authMechanisms' => $this->backendService->getAuthMechanisms(),
+ 'dependencies' => \OC_Mount_Config::dependencyMessage($this->backendService->getBackends()),
+ 'allowUserMounting' => $this->backendService->isUserMountingAllowed(),
+ 'globalCredentials' => $this->globalAuth->getAuth($uid),
+ 'globalCredentialsUid' => $uid,
+ ];
+
+ return new TemplateResponse('files_external', 'settings', $parameters, '');
+ }
+
+ /**
+ * @return string the section ID, e.g. 'sharing'
+ */
+ public function getSection() {
+ return 'externalstorages';
+ }
+
+ /**
+ * @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 40;
+ }
+
+}
diff --git a/apps/files_external/lib/Settings/PersonalSection.php b/apps/files_external/lib/Settings/PersonalSection.php
new file mode 100644
index 0000000000..32a841c420
--- /dev/null
+++ b/apps/files_external/lib/Settings/PersonalSection.php
@@ -0,0 +1,67 @@
+
+ *
+ * @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 .
+ *
+ */
+
+namespace OCA\Files_External\Settings;
+
+
+use OCA\Files_External\Service\BackendService;
+use OCA\Files_External\Service\UserGlobalStoragesService;
+use OCP\IL10N;
+use OCP\IURLGenerator;
+use OCP\IUserSession;
+
+class PersonalSection extends Section {
+ /** @var IUserSession */
+ private $userSession;
+
+ /** @var UserGlobalStoragesService */
+ private $userGlobalStoragesService;
+
+ /** @var BackendService */
+ private $backendService;
+
+ public function __construct(
+ IURLGenerator $url,
+ IL10N $l,
+ IUserSession $userSession,
+ UserGlobalStoragesService $userGlobalStoragesService,
+ BackendService $backendService
+ ) {
+ parent::__construct($url, $l);
+ $this->userSession = $userSession;
+ $this->userGlobalStoragesService = $userGlobalStoragesService;
+ $this->backendService = $backendService;
+ }
+
+ public function getID() {
+ if (!$this->userSession->isLoggedIn()) {
+ // we need to return the proper id while installing/upgrading the app
+ return parent::getID();
+ }
+
+ if (count($this->userGlobalStoragesService->getStorages()) > 0 || $this->backendService->isUserMountingAllowed()) {
+ return parent::getID();
+ } else {
+ // by returning a different id, no matching settings will be found and the item will be hidden
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/files_external/personal.php b/apps/files_external/personal.php
deleted file mode 100644
index e213125238..0000000000
--- a/apps/files_external/personal.php
+++ /dev/null
@@ -1,47 +0,0 @@
-
- * @author Michael Gapczynski
- * @author Morris Jobke
- * @author Robin Appelman
- * @author Robin McCorkell
- * @author Vincent Petry
- *
- * @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
- *
- */
-
-use \OCA\Files_External\Service\BackendService;
-
-// we must use the same container
-$appContainer = \OC_Mount_Config::$app->getContainer();
-$backendService = $appContainer->query('OCA\Files_External\Service\BackendService');
-$userStoragesService = $appContainer->query('OCA\Files_External\Service\UserStoragesService');
-$globalAuth = $appContainer->query('OCA\Files_External\Lib\Auth\Password\GlobalAuth');
-
-$tmpl = new OCP\Template('files_external', 'settings');
-$tmpl->assign('encryptionEnabled', \OC::$server->getEncryptionManager()->isEnabled());
-$tmpl->assign('visibilityType', BackendService::VISIBILITY_PERSONAL);
-$tmpl->assign('storages', $userStoragesService->getStorages());
-$tmpl->assign('dependencies', OC_Mount_Config::dependencyMessage($backendService->getBackends()));
-$tmpl->assign('backends', $backendService->getAvailableBackends());
-$tmpl->assign('authMechanisms', $backendService->getAuthMechanisms());
-$uid = \OC::$server->getUserSession()->getUser()->getUID();
-$tmpl->assign('globalCredentials', $globalAuth->getAuth($uid));
-$tmpl->assign('globalCredentialsUid', $uid);
-$tmpl->assign('allowUserMounting', $backendService->isUserMountingAllowed());
-return $tmpl->fetchPage();
diff --git a/apps/twofactor_backupcodes/appinfo/info.xml b/apps/twofactor_backupcodes/appinfo/info.xml
index 92300320e1..7faf2825be 100644
--- a/apps/twofactor_backupcodes/appinfo/info.xml
+++ b/apps/twofactor_backupcodes/appinfo/info.xml
@@ -28,4 +28,8 @@
OCA\TwoFactorBackupCodes\Migration\CopyEntriesFromOldTable
+
+
+ OCA\TwoFactorBackupCodes\Settings\Personal
+
diff --git a/apps/twofactor_backupcodes/lib/AppInfo/Application.php b/apps/twofactor_backupcodes/lib/AppInfo/Application.php
index ad92c0b147..050473f7ef 100644
--- a/apps/twofactor_backupcodes/lib/AppInfo/Application.php
+++ b/apps/twofactor_backupcodes/lib/AppInfo/Application.php
@@ -37,7 +37,6 @@ class Application extends App {
*/
public function register() {
$this->registerHooksAndEvents();
- $this->registerPersonalPage();
}
/**
@@ -52,11 +51,4 @@ class Application extends App {
$mapper = $this->getContainer()->query(BackupCodeMapper::class);
$mapper->deleteCodesByUserId($params['uid']);
}
-
- /**
- * Register personal settings for notifications and emails
- */
- public function registerPersonalPage() {
- \OCP\App::registerPersonal($this->getContainer()->getAppName(), 'settings/personal');
- }
}
diff --git a/apps/twofactor_backupcodes/lib/Settings/Personal.php b/apps/twofactor_backupcodes/lib/Settings/Personal.php
new file mode 100644
index 0000000000..eb28dacb42
--- /dev/null
+++ b/apps/twofactor_backupcodes/lib/Settings/Personal.php
@@ -0,0 +1,82 @@
+
+ *
+ * @author Arthur Schiwon
+ *
+ * @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 .
+ *
+ */
+
+namespace OCA\TwoFactorBackupCodes\Settings;
+
+
+use OCA\TwoFactorBackupCodes\AppInfo\Application;
+use OCA\TwoFactorBackupCodes\Provider\BackupCodesProvider;
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\IUserSession;
+use OCP\Settings\ISettings;
+
+class Personal implements ISettings {
+
+ /** @var Application */
+ private $app;
+ /** @var BackupCodesProvider */
+ private $provider;
+ /** @var IUserSession */
+ private $userSession;
+
+ public function __construct(Application $app, BackupCodesProvider $provider, IUserSession $userSession) {
+ $this->app = $app;
+ $this->provider = $provider;
+ $this->userSession = $userSession;
+ }
+
+ /**
+ * @return TemplateResponse returns the instance with all parameters set, ready to be rendered
+ * @since 9.1
+ */
+ public function getForm() {
+ $templateOwner = 'settings';
+ $templateName = 'settings/empty';
+ if ($this->provider->isActive($this->userSession->getUser())) {
+ $templateOwner = $this->app->getContainer()->getAppName();
+ $templateName = 'personal';
+ }
+
+ return new TemplateResponse($templateOwner, $templateName, [], '');
+ }
+
+ /**
+ * @return string the section ID, e.g. 'sharing'
+ * @since 9.1
+ */
+ public function getSection() {
+ return 'security';
+ }
+
+ /**
+ * @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
+ * @since 9.1
+ */
+ public function getPriority() {
+ return 40;
+ }
+}
diff --git a/apps/twofactor_backupcodes/settings/personal.php b/apps/twofactor_backupcodes/settings/personal.php
deleted file mode 100644
index 48c84a3355..0000000000
--- a/apps/twofactor_backupcodes/settings/personal.php
+++ /dev/null
@@ -1,19 +0,0 @@
-query(BackupCodesProvider::class);
-$user = OC::$server->getUserSession()->getUser();
-
-if ($provider->isActive($user)) {
- $tmpl = new Template('twofactor_backupcodes', 'personal');
- return $tmpl->fetchPage();
-} else {
- return "";
-}
-
-// @codeCoverageIgnoreEnd
diff --git a/db_structure.xml b/db_structure.xml
index 583e9bb852..ac7f4b3c71 100644
--- a/db_structure.xml
+++ b/db_structure.xml
@@ -2135,6 +2135,127 @@
+
', '', $sectionName);
- if (strpos($regs['class'], 'data-anchor-name') !== false) {
- preg_match('%.*data-anchor-name="(?P[^"]*)"%i', $regs['class'], $matches);
- $anchor = $matches['anchor'];
- } else {
- $anchor = strtolower($sectionName);
- $anchor = str_replace(' ', '-', $anchor);
- }
-
- return array(
- 'anchor' => $anchor,
- 'section-name' => $sectionName,
- 'form' => $form
- );
- }
- return array(
- 'form' => $form
- );
-}, $forms);
-
-$formsAndMore = array_merge($formsAndMore, $formsMap);
-
-$tmpl->assign('forms', $formsAndMore);
-$tmpl->printPage();
diff --git a/settings/routes.php b/settings/routes.php
index 048febaa12..12da950ed2 100644
--- a/settings/routes.php
+++ b/settings/routes.php
@@ -65,6 +65,7 @@ $application->registerRoutes($this, [
['name' => 'Certificate#removePersonalRootCertificate', 'url' => '/settings/personal/certificate/{certificateIdentifier}', 'verb' => 'DELETE'],
['name' => 'Certificate#addSystemRootCertificate', 'url' => '/settings/admin/certificate', 'verb' => 'POST'],
['name' => 'Certificate#removeSystemRootCertificate', 'url' => '/settings/admin/certificate/{certificateIdentifier}', 'verb' => 'DELETE'],
+ ['name' => 'PersonalSettings#index', 'url' => '/settings/user/{section}', 'verb' => 'GET', 'defaults' => ['section' => 'personal-info']],
['name' => 'AdminSettings#index', 'url' => '/settings/admin/{section}', 'verb' => 'GET', 'defaults' => ['section' => 'server']],
['name' => 'AdminSettings#form', 'url' => '/settings/admin/{section}', 'verb' => 'GET'],
['name' => 'ChangePassword#changePersonalPassword', 'url' => '/settings/personal/changepassword', 'verb' => 'POST'],
@@ -82,8 +83,6 @@ $application->registerRoutes($this, [
// Settings pages
$this->create('settings_help', '/settings/help')
->actionInclude('settings/help.php');
-$this->create('settings_personal', '/settings/personal')
- ->actionInclude('settings/personal.php');
$this->create('settings_users', '/settings/users')
->actionInclude('settings/users.php');
// Settings ajax actions
diff --git a/settings/templates/admin/additional.php b/settings/templates/settings/additional.php
similarity index 100%
rename from settings/templates/admin/additional.php
rename to settings/templates/settings/additional.php
diff --git a/settings/templates/admin/additional-mail.php b/settings/templates/settings/admin/additional-mail.php
similarity index 100%
rename from settings/templates/admin/additional-mail.php
rename to settings/templates/settings/admin/additional-mail.php
diff --git a/settings/templates/admin/encryption.php b/settings/templates/settings/admin/encryption.php
similarity index 100%
rename from settings/templates/admin/encryption.php
rename to settings/templates/settings/admin/encryption.php
diff --git a/settings/templates/admin/server.development.notice.php b/settings/templates/settings/admin/server.development.notice.php
similarity index 100%
rename from settings/templates/admin/server.development.notice.php
rename to settings/templates/settings/admin/server.development.notice.php
diff --git a/settings/templates/admin/server.php b/settings/templates/settings/admin/server.php
similarity index 100%
rename from settings/templates/admin/server.php
rename to settings/templates/settings/admin/server.php
diff --git a/settings/templates/admin/sharing.php b/settings/templates/settings/admin/sharing.php
similarity index 100%
rename from settings/templates/admin/sharing.php
rename to settings/templates/settings/admin/sharing.php
diff --git a/settings/templates/admin/tipstricks.php b/settings/templates/settings/admin/tipstricks.php
similarity index 100%
rename from settings/templates/admin/tipstricks.php
rename to settings/templates/settings/admin/tipstricks.php
diff --git a/settings/templates/settings/empty.php b/settings/templates/settings/empty.php
new file mode 100644
index 0000000000..0ed8a873d3
--- /dev/null
+++ b/settings/templates/settings/empty.php
@@ -0,0 +1,25 @@
+
+ *
+ * @author Arthur Schiwon
+ *
+ * @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 .
+ *
+ */
+
+ # used for Personal/Additional settings as fallback for legacy settings
+?>
diff --git a/settings/templates/admin/frame.php b/settings/templates/settings/frame.php
similarity index 65%
rename from settings/templates/admin/frame.php
rename to settings/templates/settings/frame.php
index 2b234f4cd9..80737bc6f9 100644
--- a/settings/templates/admin/frame.php
+++ b/settings/templates/settings/frame.php
@@ -30,9 +30,39 @@ script('files', 'jquery.fileupload');
+ getURLGenerator()->linkToRoute('settings.AdminSettings.index', ['section' => $form['anchor']]);
$class = 'nav-icon-' . $form['anchor'];
$sectionName = $form['section-name'];
diff --git a/settings/templates/settings/personal/personal.info.php b/settings/templates/settings/personal/personal.info.php
new file mode 100644
index 0000000000..db14a4de98
--- /dev/null
+++ b/settings/templates/settings/personal/personal.info.php
@@ -0,0 +1,316 @@
+
+ *
+ * @author Arthur Schiwon
+ *
+ * @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 .
+ *
+ */
+
+/** @var \OCP\IL10N $l */
+/** @var array $_ */
+
+script('settings', [
+ 'usersettings',
+ 'federationsettingsview',
+ 'federationscopemenu',
+ 'settings/personalInfo',
+]);
+vendor_script('strengthify/jquery.strengthify');
+vendor_style('strengthify/strengthify');
+vendor_script('jcrop/js/jquery.Jcrop');
+vendor_style('jcrop/css/jquery.Jcrop');
+
+?>
+
+
+
80): ?> class="quota-warning" >
+
+
+ t('You are using %s of %s',
+ [$_['usage'], $_['total_space']]));?>
+
+ t('You are using %s of %s (%s %%)',
+ [$_['usage'], $_['total_space'], $_['usage_relative']]));?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
t('Groups')); ?>
+
t('You are member of the following groups:')); ?>
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/settings/templates/settings/personal/security.php b/settings/templates/settings/personal/security.php
new file mode 100644
index 0000000000..3a324bf8d2
--- /dev/null
+++ b/settings/templates/settings/personal/security.php
@@ -0,0 +1,68 @@
+
+ *
+ * @author Arthur Schiwon
+ *
+ * @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 .
+ *
+ */
+
+script('settings', [
+ 'authtoken',
+ 'authtoken_collection',
+ 'authtoken_view',
+ 'settings/authtoken-init'
+]);
+
+?>
+
+
+
+
t('Security'));?>
+
t('Web, desktop and mobile clients currently logged in to your account.'));?>
+
+
+
+
t('Device'));?>
+
t('Last activity'));?>
+
+
+
+
+
+
+
+
+
+
+
+
+ t('Use the credentials below to configure your app or device.')); ?>
+ t('For security reasons this password will only be shown once.')); ?>
+
+
+ t('Username')); ?>
+
+
+
+ t('Password')); ?>
+
+
+
+
+
+
diff --git a/settings/templates/settings/personal/sync-clients.php b/settings/templates/settings/personal/sync-clients.php
new file mode 100644
index 0000000000..ac76ef4f59
--- /dev/null
+++ b/settings/templates/settings/personal/sync-clients.php
@@ -0,0 +1,59 @@
+
+ *
+ * @author Arthur Schiwon
+ *
+ * @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 .
+ *
+ */
+
+/** @var array $_ */
+
+?>
+
+
+ ',
+ '',
+ ],
+ $l->t('If you want to support the project {contributeopen}join development{linkclose} or {contributeopen}spread the word{linkclose}!'))); ?>
+
diff --git a/tests/Settings/Controller/AdminSettingsControllerTest.php b/tests/Settings/Controller/AdminSettingsControllerTest.php
index 6c93bca0d6..51357f67a2 100644
--- a/tests/Settings/Controller/AdminSettingsControllerTest.php
+++ b/tests/Settings/Controller/AdminSettingsControllerTest.php
@@ -22,7 +22,6 @@
*/
namespace Tests\Settings\Controller;
-
use OC\Settings\Admin\TipsTricks;
use OC\Settings\Controller\AdminSettingsController;
use OCP\AppFramework\Http\TemplateResponse;
@@ -31,6 +30,13 @@ use OCP\IRequest;
use OCP\Settings\IManager;
use Test\TestCase;
+/**
+ * Class AdminSettingsControllerTest
+ *
+ * @group DB
+ *
+ * @package Tests\Settings\Controller
+ */
class AdminSettingsControllerTest extends TestCase {
/** @var AdminSettingsController */
private $adminSettingsController;
@@ -38,8 +44,10 @@ class AdminSettingsControllerTest extends TestCase {
private $request;
/** @var INavigationManager */
private $navigationManager;
- /** @var IManager */
+ /** @var IManager|\PHPUnit_Framework_MockObject_MockObject */
private $settingsManager;
+ /** @var string */
+ private $adminUid = 'lololo';
public function setUp() {
parent::setUp();
@@ -54,6 +62,16 @@ class AdminSettingsControllerTest extends TestCase {
$this->navigationManager,
$this->settingsManager
);
+
+ $user = \OC::$server->getUserManager()->createUser($this->adminUid, 'olo');
+ \OC_User::setUserId($user->getUID());
+ \OC::$server->getGroupManager()->createGroup('admin')->addUser($user);
+ }
+
+ public function tearDown() {
+ \OC::$server->getUserManager()->get($this->adminUid)->delete();
+
+ parent::tearDown();
}
public function testIndex() {
@@ -61,12 +79,17 @@ class AdminSettingsControllerTest extends TestCase {
->expects($this->once())
->method('getAdminSections')
->willReturn([]);
+ $this->settingsManager
+ ->expects($this->once())
+ ->method('getPersonalSections')
+ ->willReturn([]);
$this->settingsManager
->expects($this->once())
->method('getAdminSettings')
->with('test')
->willReturn([5 => new TipsTricks($this->getMockBuilder('\OCP\IConfig')->getMock())]);
- $expected = new TemplateResponse('settings', 'admin/frame', ['forms' => [], 'content' => '']);
+
+ $expected = new TemplateResponse('settings', 'settings/frame', ['forms' => ['personal' => [], 'admin' => []], 'content' => '']);
$this->assertEquals($expected, $this->adminSettingsController->index('test'));
}
}
diff --git a/tests/acceptance/features/access-levels.feature b/tests/acceptance/features/access-levels.feature
index 57998899a5..8017029667 100644
--- a/tests/acceptance/features/access-levels.feature
+++ b/tests/acceptance/features/access-levels.feature
@@ -1,11 +1,10 @@
Feature: access-levels
- Scenario: regular users can not see admin-level items in the Settings menu
+ Scenario: regular users cannot see admin-level items in the Settings menu
Given I am logged in
When I open the Settings menu
Then I see that the Settings menu is shown
- And I see that the "Personal" item in the Settings menu is shown
- And I see that the "Admin" item in the Settings menu is not shown
+ And I see that the "Settings" item in the Settings menu is shown
And I see that the "Users" item in the Settings menu is not shown
And I see that the "Help" item in the Settings menu is shown
And I see that the "Log out" item in the Settings menu is shown
@@ -14,8 +13,19 @@ Feature: access-levels
Given I am logged in as the admin
When I open the Settings menu
Then I see that the Settings menu is shown
- And I see that the "Personal" item in the Settings menu is shown
- And I see that the "Admin" item in the Settings menu is shown
+ And I see that the "Settings" item in the Settings menu is shown
And I see that the "Users" item in the Settings menu is shown
And I see that the "Help" item in the Settings menu is shown
And I see that the "Log out" item in the Settings menu is shown
+
+ Scenario: regular users cannot see admin-level items on the Settings page
+ Given I am logged in
+ When I visit the settings page
+ Then I see that the "Personal" settings panel is shown
+ And I see that the "Administration" settings panel is not shown
+
+ Scenario: admin users can see admin-level items on the Settings page
+ Given I am logged in as the admin
+ When I visit the settings page
+ Then I see that the "Personal" settings panel is shown
+ And I see that the "Administration" settings panel is shown
diff --git a/tests/acceptance/features/bootstrap/SettingsMenuContext.php b/tests/acceptance/features/bootstrap/SettingsMenuContext.php
index 1ff5d94e98..401575c78f 100644
--- a/tests/acceptance/features/bootstrap/SettingsMenuContext.php
+++ b/tests/acceptance/features/bootstrap/SettingsMenuContext.php
@@ -66,6 +66,15 @@ class SettingsMenuContext implements Context, ActorAwareInterface {
describedAs($itemText . " item in Settings menu");
}
+ /**
+ * @param string $itemText
+ * @return Locator
+ */
+ private static function settingsPanelFor($itemText) {
+ return Locator::forThe()->xpath("//div[@id = 'app-navigation']//ul//li[@class = 'settings-caption' and normalize-space() = '$itemText']")->
+ describedAs($itemText . " item in Settings panel");
+ }
+
/**
* @When I open the Settings menu
*/
@@ -82,6 +91,14 @@ class SettingsMenuContext implements Context, ActorAwareInterface {
$this->actor->find(self::usersMenuItem(), 2)->click();
}
+ /**
+ * @When I visit the settings page
+ */
+ public function iVisitTheSettingsPage() {
+ $this->iOpenTheSettingsMenu();
+ $this->actor->find(self::menuItemFor('Settings'), 2)->click();
+ }
+
/**
* @When I log out
*/
@@ -120,4 +137,25 @@ class SettingsMenuContext implements Context, ActorAwareInterface {
}
}
+ /**
+ * @Then I see that the :itemText settings panel is shown
+ */
+ public function iSeeThatTheItemSettingsPanelIsShown($itemText) {
+ PHPUnit_Framework_Assert::assertTrue(
+ $this->actor->find(self::settingsPanelFor($itemText), 10)->isVisible()
+ );
+ }
+
+ /**
+ * @Then I see that the :itemText settings panel is not shown
+ */
+ public function iSeeThatTheItemSettingsPanelIsNotShown($itemText) {
+ try {
+ PHPUnit_Framework_Assert::assertFalse(
+ $this->actor->find(self::settingsPanelFor($itemText), 10)->isVisible()
+ );
+ } catch (NoSuchElementException $exception) {
+ }
+ }
+
}
diff --git a/tests/acceptance/features/core/ElementWrapper.php b/tests/acceptance/features/core/ElementWrapper.php
index 6b730903f6..f6ce176817 100644
--- a/tests/acceptance/features/core/ElementWrapper.php
+++ b/tests/acceptance/features/core/ElementWrapper.php
@@ -119,7 +119,7 @@ class ElementWrapper {
/**
* Returns whether the wrapped element is visible or not.
*
- * @return boolbean true if the wrapped element is visible, false otherwise.
+ * @return bool true if the wrapped element is visible, false otherwise.
*/
public function isVisible() {
$commandCallback = function() {
diff --git a/tests/lib/Settings/Admin/AdditionalTest.php b/tests/lib/Settings/Admin/AdditionalTest.php
index 420a7110c1..84c63f3aeb 100644
--- a/tests/lib/Settings/Admin/AdditionalTest.php
+++ b/tests/lib/Settings/Admin/AdditionalTest.php
@@ -97,7 +97,7 @@ class AdditionalTest extends TestCase {
$expected = new TemplateResponse(
'settings',
- 'admin/additional-mail',
+ 'settings/admin/additional-mail',
[
'sendmail_is_available' => (bool) \OC_Helper::findBinaryPath('sendmail'),
'mail_domain' => 'mx.nextcloud.com',
diff --git a/tests/lib/Settings/Admin/EncryptionTest.php b/tests/lib/Settings/Admin/EncryptionTest.php
index a282b059c9..a5f483863e 100644
--- a/tests/lib/Settings/Admin/EncryptionTest.php
+++ b/tests/lib/Settings/Admin/EncryptionTest.php
@@ -81,7 +81,7 @@ class EncryptionTest extends TestCase {
->willReturn(['entry']);
$expected = new TemplateResponse(
'settings',
- 'admin/encryption',
+ 'settings/admin/encryption',
[
'encryptionEnabled' => $enabled,
'encryptionReady' => $enabled,
@@ -116,7 +116,7 @@ class EncryptionTest extends TestCase {
->willReturn(['entry', 'entry']);
$expected = new TemplateResponse(
'settings',
- 'admin/encryption',
+ 'settings/admin/encryption',
[
'encryptionEnabled' => $enabled,
'encryptionReady' => $enabled,
diff --git a/tests/lib/Settings/Admin/ServerTest.php b/tests/lib/Settings/Admin/ServerTest.php
index f876ae8513..a71aef0178 100644
--- a/tests/lib/Settings/Admin/ServerTest.php
+++ b/tests/lib/Settings/Admin/ServerTest.php
@@ -123,7 +123,7 @@ class ServerTest extends TestCase {
$envPath = getenv('PATH');
$expected = new TemplateResponse(
'settings',
- 'admin/server',
+ 'settings/admin/server',
[
// Diagnosis
'readOnlyConfigEnabled' => \OC_Helper::isReadOnlyConfigEnabled(),
diff --git a/tests/lib/Settings/Admin/SharingTest.php b/tests/lib/Settings/Admin/SharingTest.php
index 0bf0355968..d9aa14fece 100644
--- a/tests/lib/Settings/Admin/SharingTest.php
+++ b/tests/lib/Settings/Admin/SharingTest.php
@@ -112,7 +112,7 @@ class SharingTest extends TestCase {
$expected = new TemplateResponse(
'settings',
- 'admin/sharing',
+ 'settings/admin/sharing',
[
'allowGroupSharing' => 'yes',
'allowLinks' => 'yes',
@@ -205,7 +205,7 @@ class SharingTest extends TestCase {
$expected = new TemplateResponse(
'settings',
- 'admin/sharing',
+ 'settings/admin/sharing',
[
'allowGroupSharing' => 'yes',
'allowLinks' => 'yes',
diff --git a/tests/lib/Settings/Admin/TipsTricksTest.php b/tests/lib/Settings/Admin/TipsTricksTest.php
index 0e8857b56d..cbecd51ed5 100644
--- a/tests/lib/Settings/Admin/TipsTricksTest.php
+++ b/tests/lib/Settings/Admin/TipsTricksTest.php
@@ -52,7 +52,7 @@ class TipsTrickTest extends TestCase {
$expected = new TemplateResponse(
'settings',
- 'admin/tipstricks',
+ 'settings/admin/tipstricks',
[
'databaseOverload' => true,
],
@@ -71,7 +71,7 @@ class TipsTrickTest extends TestCase {
$expected = new TemplateResponse(
'settings',
- 'admin/tipstricks',
+ 'settings/admin/tipstricks',
[
'databaseOverload' => false,
],
diff --git a/tests/lib/Settings/ManagerTest.php b/tests/lib/Settings/ManagerTest.php
index 07f7e71fec..6a13b737c8 100644
--- a/tests/lib/Settings/ManagerTest.php
+++ b/tests/lib/Settings/ManagerTest.php
@@ -23,18 +23,23 @@
namespace Tests\Settings;
+use OC\Accounts\AccountManager;
use OC\Settings\Admin\Sharing;
use OC\Settings\Manager;
use OC\Settings\Mapper;
+use OC\Settings\Personal\Security;
use OC\Settings\Section;
+use OCP\App\IAppManager;
use OCP\Encryption\IManager;
use OCP\IConfig;
use OCP\IDBConnection;
+use OCP\IGroupManager;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
use OCP\IURLGenerator;
use OCP\IUserManager;
+use OCP\L10N\IFactory;
use OCP\Lock\ILockingProvider;
use Test\TestCase;
@@ -61,6 +66,16 @@ class ManagerTest extends TestCase {
private $mapper;
/** @var IURLGenerator|\PHPUnit_Framework_MockObject_MockObject */
private $url;
+ /** @var AccountManager|\PHPUnit_Framework_MockObject_MockObject */
+ private $accountManager;
+ /** @var IGroupManager|\PHPUnit_Framework_MockObject_MockObject */
+ private $groupManager;
+ /** @var IFactory|\PHPUnit_Framework_MockObject_MockObject */
+ private $l10nFactory;
+ /** @var \OC_Defaults|\PHPUnit_Framework_MockObject_MockObject */
+ private $defaults;
+ /** @var IAppManager */
+ private $appManager;
public function setUp() {
parent::setUp();
@@ -75,6 +90,11 @@ class ManagerTest extends TestCase {
$this->request = $this->createMock(IRequest::class);
$this->mapper = $this->createMock(Mapper::class);
$this->url = $this->createMock(IURLGenerator::class);
+ $this->accountManager = $this->createMock(AccountManager::class);
+ $this->groupManager = $this->createMock(IGroupManager::class);
+ $this->l10nFactory = $this->createMock(IFactory::class);
+ $this->defaults = $this->createMock(\OC_Defaults::class);
+ $this->appManager = $this->createMock(IAppManager::class);
$this->manager = new Manager(
$this->logger,
@@ -86,21 +106,40 @@ class ManagerTest extends TestCase {
$this->lockingProvider,
$this->request,
$this->mapper,
- $this->url
+ $this->url,
+ $this->accountManager,
+ $this->groupManager,
+ $this->l10nFactory,
+ $this->defaults,
+ $this->appManager
);
}
- public function testSetupSettingsUpdate() {
+ public function settingsTypeProvider() {
+ return [
+ ['admin', 'admin_settings'],
+ ['personal', 'personal_settings'],
+ ];
+ }
+
+ /**
+ * @dataProvider settingsTypeProvider
+ * @param string $type
+ * @param string $table
+ */
+ public function testSetupSettingsUpdate($type, $table) {
+ $className = 'OCA\Files\Settings\Admin';
+
$this->mapper->expects($this->any())
->method('has')
- ->with('admin_settings', 'OCA\Files\Settings\Admin')
+ ->with($table, $className)
->will($this->returnValue(true));
$this->mapper->expects($this->once())
->method('update')
- ->with('admin_settings',
+ ->with($table,
'class',
- 'OCA\Files\Settings\Admin', [
+ $className, [
'section' => 'additional',
'priority' => 5
]);
@@ -108,19 +147,24 @@ class ManagerTest extends TestCase {
->method('add');
$this->manager->setupSettings([
- 'admin' => 'OCA\Files\Settings\Admin',
+ $type => $className,
]);
}
- public function testSetupSettingsAdd() {
+ /**
+ * @dataProvider settingsTypeProvider
+ * @param string $type
+ * @param string $table
+ */
+ public function testSetupSettingsAdd($type, $table) {
$this->mapper->expects($this->any())
->method('has')
- ->with('admin_settings', 'OCA\Files\Settings\Admin')
+ ->with($table, 'OCA\Files\Settings\Admin')
->will($this->returnValue(false));
$this->mapper->expects($this->once())
->method('add')
- ->with('admin_settings', [
+ ->with($table, [
'class' => 'OCA\Files\Settings\Admin',
'section' => 'additional',
'priority' => 5
@@ -130,7 +174,7 @@ class ManagerTest extends TestCase {
->method('update');
$this->manager->setupSettings([
- 'admin' => 'OCA\Files\Settings\Admin',
+ $type => 'OCA\Files\Settings\Admin',
]);
}
@@ -167,6 +211,34 @@ class ManagerTest extends TestCase {
], $this->manager->getAdminSections());
}
+ public function testGetPersonalSections() {
+ $this->l10n
+ ->expects($this->any())
+ ->method('t')
+ ->will($this->returnArgument(0));
+
+ $this->mapper->expects($this->once())
+ ->method('getPersonalSectionsFromDB')
+ ->will($this->returnValue([
+ ['class' => \OCA\WorkflowEngine\Settings\Section::class, 'priority' => 90]
+ ]));
+
+ $this->url->expects($this->exactly(3))
+ ->method('imagePath')
+ ->willReturnMap([
+ ['core', 'actions/info.svg', '1'],
+ ['settings', 'password.svg', '2'],
+ ['settings', 'change.svg', '3'],
+ ]);
+
+ $this->assertArraySubset([
+ 0 => [new Section('personal-info', 'Personal info', 0, '1')],
+ 5 => [new Section('security', 'Security', 0, '2')],
+ 15 => [new Section('sync-clients', 'Sync clients', 0, '3')],
+ 90 => [\OC::$server->query(\OCA\WorkflowEngine\Settings\Section::class)],
+ ], $this->manager->getPersonalSections());
+ }
+
public function testGetAdminSectionsEmptySection() {
$this->l10n
->expects($this->any())
@@ -198,6 +270,31 @@ class ManagerTest extends TestCase {
], $this->manager->getAdminSections());
}
+ public function testGetPersonalSectionsEmptySection() {
+ $this->l10n
+ ->expects($this->any())
+ ->method('t')
+ ->will($this->returnArgument(0));
+
+ $this->mapper->expects($this->once())
+ ->method('getPersonalSectionsFromDB')
+ ->will($this->returnValue([]));
+
+ $this->url->expects($this->exactly(3))
+ ->method('imagePath')
+ ->willReturnMap([
+ ['core', 'actions/info.svg', '1'],
+ ['settings', 'password.svg', '2'],
+ ['settings', 'change.svg', '3'],
+ ]);
+
+ $this->assertArraySubset([
+ 0 => [new Section('personal-info', 'Personal info', 0, '1')],
+ 5 => [new Section('security', 'Security', 0, '2')],
+ 15 => [new Section('sync-clients', 'Sync clients', 0, '3')],
+ ], $this->manager->getPersonalSections());
+ }
+
public function testGetAdminSettings() {
$this->mapper->expects($this->any())
->method('getAdminSettingsFromDB')
@@ -207,4 +304,14 @@ class ManagerTest extends TestCase {
0 => [new Sharing($this->config)],
], $this->manager->getAdminSettings('sharing'));
}
+
+ public function testGetPersonalSettings() {
+ $this->mapper->expects($this->any())
+ ->method('getPersonalSettingsFromDB')
+ ->will($this->returnValue([]));
+
+ $this->assertEquals([
+ 10 => [new Security()],
+ ], $this->manager->getPersonalSettings('security'));
+ }
}
diff --git a/version.php b/version.php
index e237770c82..d9e26eafce 100644
--- a/version.php
+++ b/version.php
@@ -26,7 +26,7 @@
// between betas, final and RCs. This is _not_ the public version number. Reset minor/patchlevel
// when updating major/minor version number.
-$OC_Version = array(13, 0, 0, 0);
+$OC_Version = array(13, 0, 0, 1);
// The human readable string
$OC_VersionString = '13.0.0 alpha';