Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'apps/settings/lib/Settings')
-rw-r--r--apps/settings/lib/Settings/Admin/Mail.php91
-rw-r--r--apps/settings/lib/Settings/Admin/Overview.php66
-rw-r--r--apps/settings/lib/Settings/Admin/Security.php109
-rw-r--r--apps/settings/lib/Settings/Admin/Server.php77
-rw-r--r--apps/settings/lib/Settings/Admin/Sharing.php137
-rw-r--r--apps/settings/lib/Settings/Personal/Additional.php59
-rw-r--r--apps/settings/lib/Settings/Personal/PersonalInfo.php280
-rw-r--r--apps/settings/lib/Settings/Personal/Security.php128
-rw-r--r--apps/settings/lib/Settings/Personal/Security/Authtokens.php107
-rw-r--r--apps/settings/lib/Settings/Personal/ServerDevNotice.php54
10 files changed, 1108 insertions, 0 deletions
diff --git a/apps/settings/lib/Settings/Admin/Mail.php b/apps/settings/lib/Settings/Admin/Mail.php
new file mode 100644
index 00000000000..a630bd07d27
--- /dev/null
+++ b/apps/settings/lib/Settings/Admin/Mail.php
@@ -0,0 +1,91 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
+ * @author Joas Schilling <coding@schilljs.com>
+ * @author Lukas Reschke <lukas@statuscode.ch>
+ *
+ * @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\Settings\Admin;
+
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\IConfig;
+use OCP\Settings\ISettings;
+
+class Mail implements ISettings {
+ /** @var IConfig */
+ private $config;
+
+ /**
+ * @param IConfig $config
+ */
+ public function __construct(IConfig $config) {
+ $this->config = $config;
+ }
+
+ /**
+ * @return TemplateResponse
+ */
+ public function getForm() {
+ $parameters = [
+ // Mail
+ 'sendmail_is_available' => (bool) \OC_Helper::findBinaryPath('sendmail'),
+ 'mail_domain' => $this->config->getSystemValue('mail_domain', ''),
+ 'mail_from_address' => $this->config->getSystemValue('mail_from_address', ''),
+ 'mail_smtpmode' => $this->config->getSystemValue('mail_smtpmode', ''),
+ 'mail_smtpsecure' => $this->config->getSystemValue('mail_smtpsecure', ''),
+ 'mail_smtphost' => $this->config->getSystemValue('mail_smtphost', ''),
+ 'mail_smtpport' => $this->config->getSystemValue('mail_smtpport', ''),
+ 'mail_smtpauthtype' => $this->config->getSystemValue('mail_smtpauthtype', ''),
+ 'mail_smtpauth' => $this->config->getSystemValue('mail_smtpauth', false),
+ 'mail_smtpname' => $this->config->getSystemValue('mail_smtpname', ''),
+ 'mail_smtppassword' => $this->config->getSystemValue('mail_smtppassword', ''),
+ 'mail_sendmailmode' => $this->config->getSystemValue('mail_sendmailmode', 'smtp'),
+ ];
+
+ if ($parameters['mail_smtppassword'] !== '') {
+ $parameters['mail_smtppassword'] = '********';
+ }
+
+ if ($parameters['mail_smtpmode'] === '' || $parameters['mail_smtpmode'] === 'php') {
+ $parameters['mail_smtpmode'] = 'smtp';
+ }
+
+ return new TemplateResponse('settings', 'settings/admin/additional-mail', $parameters, '');
+ }
+
+ /**
+ * @return string the section ID, e.g. 'sharing'
+ */
+ public function getSection() {
+ return 'server';
+ }
+
+ /**
+ * @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 10;
+ }
+}
diff --git a/apps/settings/lib/Settings/Admin/Overview.php b/apps/settings/lib/Settings/Admin/Overview.php
new file mode 100644
index 00000000000..52847d8037c
--- /dev/null
+++ b/apps/settings/lib/Settings/Admin/Overview.php
@@ -0,0 +1,66 @@
+<?php
+/**
+ * @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
+ *
+ * @author Julius Härtl <jus@bitgrid.net>
+ *
+ * @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\Settings\Admin;
+
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\IConfig;
+use OCP\Settings\ISettings;
+
+class Overview implements ISettings {
+ /** @var IConfig */
+ private $config;
+
+ public function __construct(IConfig $config) {
+ $this->config = $config;
+ }
+
+ /**
+ * @return TemplateResponse
+ */
+ public function getForm() {
+ $parameters = [
+ 'checkForWorkingWellKnownSetup' => $this->config->getSystemValue('check_for_working_wellknown_setup', true),
+ ];
+
+ return new TemplateResponse('settings', 'settings/admin/overview', $parameters, '');
+ }
+
+ /**
+ * @return string the section ID, e.g. 'sharing'
+ */
+ public function getSection() {
+ return 'overview';
+ }
+
+ /**
+ * @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 10;
+ }
+}
diff --git a/apps/settings/lib/Settings/Admin/Security.php b/apps/settings/lib/Settings/Admin/Security.php
new file mode 100644
index 00000000000..b78f6a88dff
--- /dev/null
+++ b/apps/settings/lib/Settings/Admin/Security.php
@@ -0,0 +1,109 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
+ * @author Lukas Reschke <lukas@statuscode.ch>
+ * @author Robin Appelman <robin@icewind.nl>
+ *
+ * @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\Settings\Admin;
+
+use OC\Authentication\TwoFactorAuth\MandatoryTwoFactor;
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\Encryption\IManager;
+use OCP\IInitialStateService;
+use OCP\IUserManager;
+use OCP\Settings\ISettings;
+
+class Security implements ISettings {
+
+ /** @var IManager */
+ private $manager;
+
+ /** @var IUserManager */
+ private $userManager;
+
+ /** @var MandatoryTwoFactor */
+ private $mandatoryTwoFactor;
+
+ /** @var IInitialStateService */
+ private $initialState;
+
+ public function __construct(IManager $manager,
+ IUserManager $userManager,
+ MandatoryTwoFactor $mandatoryTwoFactor,
+ IInitialStateService $initialState) {
+ $this->manager = $manager;
+ $this->userManager = $userManager;
+ $this->mandatoryTwoFactor = $mandatoryTwoFactor;
+ $this->initialState = $initialState;
+ }
+
+ /**
+ * @return TemplateResponse
+ */
+ public function getForm() {
+ $encryptionModules = $this->manager->getEncryptionModules();
+ $defaultEncryptionModuleId = $this->manager->getDefaultEncryptionModuleId();
+ $encryptionModuleList = [];
+ foreach ($encryptionModules as $module) {
+ $encryptionModuleList[$module['id']]['displayName'] = $module['displayName'];
+ $encryptionModuleList[$module['id']]['default'] = false;
+ if ($module['id'] === $defaultEncryptionModuleId) {
+ $encryptionModuleList[$module['id']]['default'] = true;
+ }
+ }
+
+ $this->initialState->provideInitialState(
+ 'settings',
+ 'mandatory2FAState',
+ $this->mandatoryTwoFactor->getState()
+ );
+
+ $parameters = [
+ // Encryption API
+ 'encryptionEnabled' => $this->manager->isEnabled(),
+ 'encryptionReady' => $this->manager->isReady(),
+ 'externalBackendsEnabled' => count($this->userManager->getBackends()) > 1,
+ // Modules
+ 'encryptionModules' => $encryptionModuleList,
+ ];
+
+ return new TemplateResponse('settings', 'settings/admin/security', $parameters, '');
+ }
+
+ /**
+ * @return string the section ID, e.g. 'sharing'
+ */
+ 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
+ */
+ public function getPriority() {
+ return 10;
+ }
+}
diff --git a/apps/settings/lib/Settings/Admin/Server.php b/apps/settings/lib/Settings/Admin/Server.php
new file mode 100644
index 00000000000..956d246479f
--- /dev/null
+++ b/apps/settings/lib/Settings/Admin/Server.php
@@ -0,0 +1,77 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
+ * @author Joas Schilling <coding@schilljs.com>
+ * @author Lukas Reschke <lukas@statuscode.ch>
+ * @author Morris Jobke <hey@morrisjobke.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\Settings\Admin;
+
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\IConfig;
+use OCP\Settings\ISettings;
+
+class Server implements ISettings {
+ /** @var IConfig */
+ private $config;
+
+ /**
+ * @param IConfig $config
+ */
+ public function __construct(IConfig $config) {
+ $this->config = $config;
+ }
+
+ /**
+ * @return TemplateResponse
+ */
+ public function getForm() {
+ $parameters = [
+ // Background jobs
+ 'backgroundjobs_mode' => $this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax'),
+ 'lastcron' => $this->config->getAppValue('core', 'lastcron', false),
+ 'cronErrors' => $this->config->getAppValue('core', 'cronErrors'),
+ 'cli_based_cron_possible' => function_exists('posix_getpwuid'),
+ 'cli_based_cron_user' => function_exists('posix_getpwuid') ? posix_getpwuid(fileowner(\OC::$configDir . 'config.php'))['name'] : '',
+ ];
+
+ return new TemplateResponse('settings', 'settings/admin/server', $parameters, '');
+ }
+
+ /**
+ * @return string the section ID, e.g. 'sharing'
+ */
+ public function getSection(): string {
+ return 'server';
+ }
+
+ /**
+ * @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(): int {
+ return 0;
+ }
+}
diff --git a/apps/settings/lib/Settings/Admin/Sharing.php b/apps/settings/lib/Settings/Admin/Sharing.php
new file mode 100644
index 00000000000..18b1f26d9a2
--- /dev/null
+++ b/apps/settings/lib/Settings/Admin/Sharing.php
@@ -0,0 +1,137 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
+ * @author Bjoern Schiessle <bjoern@schiessle.org>
+ * @author Lukas Reschke <lukas@statuscode.ch>
+ * @author Morris Jobke <hey@morrisjobke.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\Settings\Admin;
+
+use OC\Share\Share;
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\Constants;
+use OCP\IConfig;
+use OCP\IL10N;
+use OCP\L10N\IFactory;
+use OCP\Settings\ISettings;
+use OCP\Share\IManager;
+use OCP\Util;
+
+class Sharing implements ISettings {
+ /** @var IConfig */
+ private $config;
+
+ /** @var IL10N */
+ private $l;
+
+ /** @var IManager */
+ private $shareManager;
+
+ /**
+ * @param IConfig $config
+ */
+ public function __construct(IConfig $config, IFactory $l, IManager $shareManager) {
+ $this->config = $config;
+ $this->l = $l->get('lib');
+ $this->shareManager = $shareManager;
+ }
+
+ /**
+ * @return TemplateResponse
+ */
+ public function getForm() {
+ $excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
+ $excludeGroupsList = !is_null(json_decode($excludedGroups))
+ ? implode('|', json_decode($excludedGroups, true)) : '';
+
+ $parameters = [
+ // Built-In Sharing
+ 'allowGroupSharing' => $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes'),
+ 'allowLinks' => $this->config->getAppValue('core', 'shareapi_allow_links', 'yes'),
+ 'allowPublicUpload' => $this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes'),
+ 'allowResharing' => $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes'),
+ 'allowShareDialogUserEnumeration' => $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes'),
+ 'enforceLinkPassword' => Util::isPublicLinkPasswordRequired(),
+ 'onlyShareWithGroupMembers' => $this->shareManager->shareWithGroupMembersOnly(),
+ 'shareAPIEnabled' => $this->config->getAppValue('core', 'shareapi_enabled', 'yes'),
+ 'shareDefaultExpireDateSet' => $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no'),
+ 'shareExpireAfterNDays' => $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'),
+ 'shareEnforceExpireDate' => $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no'),
+ 'shareExcludeGroups' => $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes',
+ 'shareExcludedGroupsList' => $excludeGroupsList,
+ 'publicShareDisclaimerText' => $this->config->getAppValue('core', 'shareapi_public_link_disclaimertext', null),
+ 'enableLinkPasswordByDefault' => $this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no'),
+ 'shareApiDefaultPermissions' => $this->config->getAppValue('core', 'shareapi_default_permissions', Constants::PERMISSION_ALL),
+ 'shareApiDefaultPermissionsCheckboxes' => $this->getSharePermissionList(),
+ ];
+
+ return new TemplateResponse('settings', 'settings/admin/sharing', $parameters, '');
+ }
+
+ /**
+ * get share permission list for template
+ *
+ * @return array
+ */
+ private function getSharePermissionList() {
+ return [
+ [
+ 'id' => 'cancreate',
+ 'label' => $this->l->t('Create'),
+ 'value' => Constants::PERMISSION_CREATE
+ ],
+ [
+ 'id' => 'canupdate',
+ 'label' => $this->l->t('Change'),
+ 'value' => Constants::PERMISSION_UPDATE
+ ],
+ [
+ 'id' => 'candelete',
+ 'label' => $this->l->t('Delete'),
+ 'value' => Constants::PERMISSION_DELETE
+ ],
+ [
+ 'id' => 'canshare',
+ 'label' => $this->l->t('Share'),
+ 'value' => Constants::PERMISSION_SHARE
+ ],
+ ];
+ }
+
+ /**
+ * @return string the section ID, e.g. 'sharing'
+ */
+ 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
+ */
+ public function getPriority() {
+ return 0;
+ }
+}
diff --git a/apps/settings/lib/Settings/Personal/Additional.php b/apps/settings/lib/Settings/Personal/Additional.php
new file mode 100644
index 00000000000..9fea58301cf
--- /dev/null
+++ b/apps/settings/lib/Settings/Personal/Additional.php
@@ -0,0 +1,59 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 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\Settings\Personal;
+
+
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\Settings\ISettings;
+
+class Additional implements ISettings {
+
+ /**
+ * @return TemplateResponse returns the instance with all parameters set, ready to be rendered
+ * @since 9.1
+ */
+ public function getForm() {
+ return new TemplateResponse('settings', 'settings/empty');
+ }
+
+ /**
+ * @return string the section ID, e.g. 'sharing'
+ * @since 9.1
+ */
+ public function getSection() {
+ return 'additional';
+ }
+
+ /**
+ * @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 '5';
+ }
+}
diff --git a/apps/settings/lib/Settings/Personal/PersonalInfo.php b/apps/settings/lib/Settings/Personal/PersonalInfo.php
new file mode 100644
index 00000000000..b0c4d6faf48
--- /dev/null
+++ b/apps/settings/lib/Settings/Personal/PersonalInfo.php
@@ -0,0 +1,280 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
+ * @author Morris Jobke <hey@morrisjobke.de>
+ * @author Thomas Citharel <tcit@tcit.fr>
+ *
+ * @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\Settings\Personal;
+
+use OC\Accounts\AccountManager;
+use OCA\FederatedFileSharing\AppInfo\Application;
+use OCP\App\IAppManager;
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\Files\FileInfo;
+use OCP\IConfig;
+use OCP\IGroup;
+use OCP\IGroupManager;
+use OCP\IL10N;
+use OCP\IUser;
+use OCP\IUserManager;
+use OCP\L10N\IFactory;
+use OCP\Settings\ISettings;
+
+class PersonalInfo implements ISettings {
+
+ /** @var IConfig */
+ private $config;
+ /** @var IUserManager */
+ private $userManager;
+ /** @var AccountManager */
+ private $accountManager;
+ /** @var IGroupManager */
+ private $groupManager;
+ /** @var IAppManager */
+ private $appManager;
+ /** @var IFactory */
+ private $l10nFactory;
+ /** @var IL10N */
+ private $l;
+
+ /**
+ * @param IConfig $config
+ * @param IUserManager $userManager
+ * @param IGroupManager $groupManager
+ * @param AccountManager $accountManager
+ * @param IFactory $l10nFactory
+ * @param IL10N $l
+ */
+ public function __construct(
+ IConfig $config,
+ IUserManager $userManager,
+ IGroupManager $groupManager,
+ AccountManager $accountManager,
+ IAppManager $appManager,
+ IFactory $l10nFactory,
+ IL10N $l
+ ) {
+ $this->config = $config;
+ $this->userManager = $userManager;
+ $this->accountManager = $accountManager;
+ $this->groupManager = $groupManager;
+ $this->appManager = $appManager;
+ $this->l10nFactory = $l10nFactory;
+ $this->l = $l;
+ }
+
+ /**
+ * @return TemplateResponse returns the instance with all parameters set, ready to be rendered
+ * @since 9.1
+ */
+ public function getForm() {
+ $federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing');
+ $lookupServerUploadEnabled = false;
+ if($federatedFileSharingEnabled) {
+ $federatedFileSharing = new Application();
+ $shareProvider = $federatedFileSharing->getFederatedShareProvider();
+ $lookupServerUploadEnabled = $shareProvider->isLookupServerUploadEnabled();
+ }
+
+ $uid = \OC_User::getUser();
+ $user = $this->userManager->get($uid);
+ $userData = $this->accountManager->getUser($user);
+
+ $storageInfo = \OC_Helper::getStorageInfo('/');
+ if ($storageInfo['quota'] === FileInfo::SPACE_UNLIMITED) {
+ $totalSpace = $this->l->t('Unlimited');
+ } else {
+ $totalSpace = \OC_Helper::humanFileSize($storageInfo['total']);
+ }
+
+ $languageParameters = $this->getLanguages($user);
+ $localeParameters = $this->getLocales($user);
+ $messageParameters = $this->getMessageParameters($userData);
+
+ $parameters = [
+ 'total_space' => $totalSpace,
+ 'usage' => \OC_Helper::humanFileSize($storageInfo['used']),
+ 'usage_relative' => round($storageInfo['relative']),
+ 'quota' => $storageInfo['quota'],
+ 'avatarChangeSupported' => $user->canChangeAvatar(),
+ 'lookupServerUploadEnabled' => $lookupServerUploadEnabled,
+ 'avatarScope' => $userData[AccountManager::PROPERTY_AVATAR]['scope'],
+ 'displayNameChangeSupported' => $user->canChangeDisplayName(),
+ 'displayName' => $userData[AccountManager::PROPERTY_DISPLAYNAME]['value'],
+ 'displayNameScope' => $userData[AccountManager::PROPERTY_DISPLAYNAME]['scope'],
+ 'email' => $userData[AccountManager::PROPERTY_EMAIL]['value'],
+ 'emailScope' => $userData[AccountManager::PROPERTY_EMAIL]['scope'],
+ 'emailVerification' => $userData[AccountManager::PROPERTY_EMAIL]['verified'],
+ 'phone' => $userData[AccountManager::PROPERTY_PHONE]['value'],
+ 'phoneScope' => $userData[AccountManager::PROPERTY_PHONE]['scope'],
+ 'address' => $userData[AccountManager::PROPERTY_ADDRESS]['value'],
+ 'addressScope' => $userData[AccountManager::PROPERTY_ADDRESS]['scope'],
+ 'website' => $userData[AccountManager::PROPERTY_WEBSITE]['value'],
+ 'websiteScope' => $userData[AccountManager::PROPERTY_WEBSITE]['scope'],
+ 'websiteVerification' => $userData[AccountManager::PROPERTY_WEBSITE]['verified'],
+ 'twitter' => $userData[AccountManager::PROPERTY_TWITTER]['value'],
+ 'twitterScope' => $userData[AccountManager::PROPERTY_TWITTER]['scope'],
+ 'twitterVerification' => $userData[AccountManager::PROPERTY_TWITTER]['verified'],
+ 'groups' => $this->getGroups($user),
+ ] + $messageParameters + $languageParameters + $localeParameters;
+
+
+ return new TemplateResponse('settings', 'settings/personal/personal.info', $parameters, '');
+ }
+
+ /**
+ * @return string the section ID, e.g. 'sharing'
+ * @since 9.1
+ */
+ public function getSection() {
+ return 'personal-info';
+ }
+
+ /**
+ * @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 10;
+ }
+
+ /**
+ * returns a sorted list of the user's group GIDs
+ *
+ * @param IUser $user
+ * @return array
+ */
+ private function getGroups(IUser $user) {
+ $groups = array_map(
+ function(IGroup $group) {
+ return $group->getDisplayName();
+ },
+ $this->groupManager->getUserGroups($user)
+ );
+ sort($groups);
+
+ return $groups;
+ }
+
+ /**
+ * returns the user language, common language and other languages in an
+ * associative array
+ *
+ * @param IUser $user
+ * @return array
+ */
+ private function getLanguages(IUser $user) {
+ $forceLanguage = $this->config->getSystemValue('force_language', false);
+ if($forceLanguage !== false) {
+ return [];
+ }
+
+ $uid = $user->getUID();
+
+ $userConfLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage());
+ $languages = $this->l10nFactory->getLanguages();
+
+ // associate the user language with the proper array
+ $userLangIndex = array_search($userConfLang, array_column($languages['commonlanguages'], 'code'));
+ $userLang = $languages['commonlanguages'][$userLangIndex];
+ // search in the other languages
+ if ($userLangIndex === false) {
+ $userLangIndex = array_search($userConfLang, array_column($languages['languages'], 'code'));
+ $userLang = $languages['languages'][$userLangIndex];
+ }
+ // if user language is not available but set somehow: show the actual code as name
+ if (!is_array($userLang)) {
+ $userLang = [
+ 'code' => $userConfLang,
+ 'name' => $userConfLang,
+ ];
+ }
+
+ return array_merge(
+ array('activelanguage' => $userLang),
+ $languages
+ );
+ }
+
+ private function getLocales(IUser $user) {
+ $forceLanguage = $this->config->getSystemValue('force_locale', false);
+ if($forceLanguage !== false) {
+ return [];
+ }
+
+ $uid = $user->getUID();
+
+ $userLocaleString = $this->config->getUserValue($uid, 'core', 'locale', $this->l10nFactory->findLocale());
+
+ $userLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage());
+
+ $localeCodes = $this->l10nFactory->findAvailableLocales();
+
+ $userLocale = array_filter($localeCodes, function($value) use ($userLocaleString) {
+ return $userLocaleString === $value['code'];
+ });
+
+ if (!empty($userLocale))
+ {
+ $userLocale = reset($userLocale);
+ }
+
+ $localesForLanguage = array_filter($localeCodes, function($localeCode) use ($userLang) {
+ return 0 === strpos($localeCode['code'], $userLang);
+ });
+
+ return [
+ 'activelocaleLang' => $userLocaleString,
+ 'activelocale' => $userLocale,
+ 'locales' => $localeCodes,
+ 'localesForLanguage' => $localesForLanguage,
+ ];
+ }
+
+ /**
+ * @param array $userData
+ * @return array
+ */
+ private function getMessageParameters(array $userData) {
+ $needVerifyMessage = [AccountManager::PROPERTY_EMAIL, AccountManager::PROPERTY_WEBSITE, AccountManager::PROPERTY_TWITTER];
+ $messageParameters = [];
+ foreach ($needVerifyMessage as $property) {
+ switch ($userData[$property]['verified']) {
+ case AccountManager::VERIFIED:
+ $message = $this->l->t('Verifying');
+ break;
+ case AccountManager::VERIFICATION_IN_PROGRESS:
+ $message = $this->l->t('Verifying …');
+ break;
+ default:
+ $message = $this->l->t('Verify');
+ }
+ $messageParameters[$property . 'Message'] = $message;
+ }
+ return $messageParameters;
+ }
+
+}
diff --git a/apps/settings/lib/Settings/Personal/Security.php b/apps/settings/lib/Settings/Personal/Security.php
new file mode 100644
index 00000000000..c4c4cd0375c
--- /dev/null
+++ b/apps/settings/lib/Settings/Personal/Security.php
@@ -0,0 +1,128 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 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\Settings\Personal;
+
+
+use function array_filter;
+use function array_map;
+use function is_null;
+use OC\Authentication\Exceptions\InvalidTokenException;
+use OC\Authentication\Token\INamedToken;
+use OC\Authentication\Token\IProvider as IAuthTokenProvider;
+use OC\Authentication\Token\IToken;
+use OC\Authentication\TwoFactorAuth\Manager as TwoFactorManager;
+use OC\Authentication\TwoFactorAuth\ProviderLoader;
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\Authentication\TwoFactorAuth\IProvider;
+use OCP\Authentication\TwoFactorAuth\IProvidesPersonalSettings;
+use OCP\IInitialStateService;
+use OCP\ISession;
+use OCP\IUserManager;
+use OCP\IUserSession;
+use OCP\Session\Exceptions\SessionNotAvailableException;
+use OCP\Settings\ISettings;
+use OCP\IConfig;
+
+class Security implements ISettings {
+
+ /** @var IInitialStateService */
+ private $initialStateService;
+
+ /** @var IUserManager */
+ private $userManager;
+
+ /** @var ProviderLoader */
+ private $providerLoader;
+
+ /** @var IUserSession */
+ private $userSession;
+
+ /** @var string|null */
+ private $uid;
+
+ /** @var IConfig */
+ private $config;
+
+ public function __construct(IInitialStateService $initialStateService,
+ IUserManager $userManager,
+ ProviderLoader $providerLoader,
+ IUserSession $userSession,
+ IConfig $config,
+ ?string $UserId) {
+ $this->initialStateService = $initialStateService;
+ $this->userManager = $userManager;
+ $this->providerLoader = $providerLoader;
+ $this->userSession = $userSession;
+ $this->uid = $UserId;
+ $this->config = $config;
+ }
+
+ public function getForm(): TemplateResponse {
+ $user = $this->userManager->get($this->uid);
+ $passwordChangeSupported = false;
+ if ($user !== null) {
+ $passwordChangeSupported = $user->canChangePassword();
+ }
+
+ $this->initialStateService->provideInitialState(
+ 'settings',
+ 'can_create_app_token',
+ $this->userSession->getImpersonatingUserID() === null
+ );
+
+ return new TemplateResponse('settings', 'settings/personal/security', [
+ 'passwordChangeSupported' => $passwordChangeSupported,
+ 'twoFactorProviderData' => $this->getTwoFactorProviderData(),
+ 'themedark' => $this->config->getUserValue($this->uid, 'accessibility', 'theme', false)
+ ]);
+
+ }
+
+ public function getSection(): string {
+ return 'security';
+ }
+
+ public function getPriority(): int {
+ return 10;
+ }
+
+ private function getTwoFactorProviderData(): array {
+ $user = $this->userSession->getUser();
+ if (is_null($user)) {
+ // Actually impossible, but still …
+ return [];
+ }
+
+ return [
+ 'providers' => array_map(function (IProvidesPersonalSettings $provider) use ($user) {
+ return [
+ 'provider' => $provider,
+ 'settings' => $provider->getPersonalSettings($user)
+ ];
+ }, array_filter($this->providerLoader->getProviders($user), function (IProvider $provider) {
+ return $provider instanceof IProvidesPersonalSettings;
+ }))
+ ];
+ }
+}
diff --git a/apps/settings/lib/Settings/Personal/Security/Authtokens.php b/apps/settings/lib/Settings/Personal/Security/Authtokens.php
new file mode 100644
index 00000000000..a0c76e88de0
--- /dev/null
+++ b/apps/settings/lib/Settings/Personal/Security/Authtokens.php
@@ -0,0 +1,107 @@
+<?php
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @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\Settings\Personal\Security;
+
+use function array_map;
+use OC\Authentication\Exceptions\InvalidTokenException;
+use OC\Authentication\Token\INamedToken;
+use OC\Authentication\Token\IProvider as IAuthTokenProvider;
+use OC\Authentication\Token\IToken;
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\IInitialStateService;
+use OCP\ISession;
+use OCP\Session\Exceptions\SessionNotAvailableException;
+use OCP\Settings\ISettings;
+
+class Authtokens implements ISettings {
+
+ /** @var IAuthTokenProvider */
+ private $tokenProvider;
+
+ /** @var ISession */
+ private $session;
+
+ /** @var IInitialStateService */
+ private $initialStateService;
+
+ /** @var string|null */
+ private $uid;
+
+ public function __construct(IAuthTokenProvider $tokenProvider,
+ ISession $session,
+ IInitialStateService $initialStateService,
+ ?string $UserId) {
+ $this->tokenProvider = $tokenProvider;
+ $this->session = $session;
+ $this->initialStateService = $initialStateService;
+ $this->uid = $UserId;
+ }
+
+ public function getForm(): TemplateResponse {
+ $this->initialStateService->provideInitialState(
+ 'settings',
+ 'app_tokens',
+ $this->getAppTokens()
+ );
+
+ return new TemplateResponse('settings', 'settings/personal/security/authtokens');
+ }
+
+ public function getSection(): string {
+ return 'security';
+ }
+
+ public function getPriority(): int {
+ return 100;
+ }
+
+ private function getAppTokens(): array {
+ $tokens = $this->tokenProvider->getTokenByUser($this->uid);
+
+ try {
+ $sessionId = $this->session->getId();
+ } catch (SessionNotAvailableException $ex) {
+ return [];
+ }
+ try {
+ $sessionToken = $this->tokenProvider->getToken($sessionId);
+ } catch (InvalidTokenException $ex) {
+ return [];
+ }
+
+ return array_map(function (IToken $token) use ($sessionToken) {
+ $data = $token->jsonSerialize();
+ $data['canDelete'] = true;
+ $data['canRename'] = $token instanceof INamedToken;
+ if ($sessionToken->getId() === $token->getId()) {
+ $data['canDelete'] = false;
+ $data['canRename'] = false;
+ $data['current'] = true;
+ }
+ return $data;
+ }, $tokens);
+ }
+
+}
diff --git a/apps/settings/lib/Settings/Personal/ServerDevNotice.php b/apps/settings/lib/Settings/Personal/ServerDevNotice.php
new file mode 100644
index 00000000000..800bec992a2
--- /dev/null
+++ b/apps/settings/lib/Settings/Personal/ServerDevNotice.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * @copyright 2016, Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @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\Settings\Personal;
+
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\Settings\ISettings;
+
+class ServerDevNotice implements ISettings {
+ /**
+ * @return TemplateResponse
+ */
+ public function getForm() {
+ return new TemplateResponse('settings', 'settings/personal/development.notice');
+ }
+
+ /**
+ * @return string the section ID, e.g. 'sharing'
+ */
+ public function getSection() {
+ return 'personal-info';
+ }
+
+ /**
+ * @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 1000;
+ }
+}