summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2017-06-29 20:02:09 +0200
committerGitHub <noreply@github.com>2017-06-29 20:02:09 +0200
commit72d3bfcf56c40e24cbd706dfddb627d21ad8ad54 (patch)
tree3f565f387f05dd52fed8fa3e297bf776cee194df /lib
parent57c5a15e418dac9491403aba8266a97b7fadc064 (diff)
parent010a3c09f2c589f15dc885694fdb0f7febdb25d8 (diff)
downloadnextcloud-server-72d3bfcf56c40e24cbd706dfddb627d21ad8ad54.tar.gz
nextcloud-server-72d3bfcf56c40e24cbd706dfddb627d21ad8ad54.zip
Merge pull request #4890 from nextcloud/unify-settings
Unify settings
Diffstat (limited to 'lib')
-rw-r--r--lib/composer/composer/autoload_classmap.php6
-rw-r--r--lib/composer/composer/autoload_static.php6
-rw-r--r--lib/private/NavigationManager.php22
-rw-r--r--lib/private/Server.php8
-rw-r--r--lib/private/Settings/Admin/Additional.php2
-rw-r--r--lib/private/Settings/Admin/Encryption.php2
-rw-r--r--lib/private/Settings/Admin/Server.php2
-rw-r--r--lib/private/Settings/Admin/ServerDevNotice.php2
-rw-r--r--lib/private/Settings/Admin/Sharing.php2
-rw-r--r--lib/private/Settings/Admin/TipsTricks.php2
-rw-r--r--lib/private/Settings/Manager.php236
-rw-r--r--lib/private/Settings/Mapper.php75
-rw-r--r--lib/private/Settings/Personal/Additional.php59
-rw-r--r--lib/private/Settings/Personal/PersonalInfo.php284
-rw-r--r--lib/private/Settings/Personal/Security.php59
-rw-r--r--lib/private/Settings/Personal/SyncClients.php85
-rw-r--r--lib/public/Settings/IManager.php27
17 files changed, 810 insertions, 69 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 33b96d29ac6..db03e49009c 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -806,10 +806,12 @@ return array(
'OC\\Settings\\Controller\\CertificateController' => $baseDir . '/settings/Controller/CertificateController.php',
'OC\\Settings\\Controller\\ChangePasswordController' => $baseDir . '/settings/Controller/ChangePasswordController.php',
'OC\\Settings\\Controller\\CheckSetupController' => $baseDir . '/settings/Controller/CheckSetupController.php',
+ 'OC\\Settings\\Controller\\CommonSettingsTrait' => $baseDir . '/settings/Controller/CommonSettingsTrait.php',
'OC\\Settings\\Controller\\EncryptionController' => $baseDir . '/settings/Controller/EncryptionController.php',
'OC\\Settings\\Controller\\GroupsController' => $baseDir . '/settings/Controller/GroupsController.php',
'OC\\Settings\\Controller\\LogSettingsController' => $baseDir . '/settings/Controller/LogSettingsController.php',
'OC\\Settings\\Controller\\MailSettingsController' => $baseDir . '/settings/Controller/MailSettingsController.php',
+ 'OC\\Settings\\Controller\\PersonalSettingsController' => $baseDir . '/settings/Controller/PersonalSettingsController.php',
'OC\\Settings\\Controller\\SecuritySettingsController' => $baseDir . '/settings/Controller/SecuritySettingsController.php',
'OC\\Settings\\Controller\\UsersController' => $baseDir . '/settings/Controller/UsersController.php',
'OC\\Settings\\Hooks' => $baseDir . '/settings/Hooks.php',
@@ -817,6 +819,10 @@ return array(
'OC\\Settings\\Manager' => $baseDir . '/lib/private/Settings/Manager.php',
'OC\\Settings\\Mapper' => $baseDir . '/lib/private/Settings/Mapper.php',
'OC\\Settings\\Middleware\\SubadminMiddleware' => $baseDir . '/settings/Middleware/SubadminMiddleware.php',
+ 'OC\\Settings\\Personal\\Additional' => $baseDir . '/lib/private/Settings/Personal/Additional.php',
+ 'OC\\Settings\\Personal\\PersonalInfo' => $baseDir . '/lib/private/Settings/Personal/PersonalInfo.php',
+ 'OC\\Settings\\Personal\\Security' => $baseDir . '/lib/private/Settings/Personal/Security.php',
+ 'OC\\Settings\\Personal\\SyncClients' => $baseDir . '/lib/private/Settings/Personal/SyncClients.php',
'OC\\Settings\\RemoveOrphaned' => $baseDir . '/lib/private/Settings/RemoveOrphaned.php',
'OC\\Settings\\Section' => $baseDir . '/lib/private/Settings/Section.php',
'OC\\Setup' => $baseDir . '/lib/private/Setup.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index 6f93d83c316..65b3b9a3cfd 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -836,10 +836,12 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\Settings\\Controller\\CertificateController' => __DIR__ . '/../../..' . '/settings/Controller/CertificateController.php',
'OC\\Settings\\Controller\\ChangePasswordController' => __DIR__ . '/../../..' . '/settings/Controller/ChangePasswordController.php',
'OC\\Settings\\Controller\\CheckSetupController' => __DIR__ . '/../../..' . '/settings/Controller/CheckSetupController.php',
+ 'OC\\Settings\\Controller\\CommonSettingsTrait' => __DIR__ . '/../../..' . '/settings/Controller/CommonSettingsTrait.php',
'OC\\Settings\\Controller\\EncryptionController' => __DIR__ . '/../../..' . '/settings/Controller/EncryptionController.php',
'OC\\Settings\\Controller\\GroupsController' => __DIR__ . '/../../..' . '/settings/Controller/GroupsController.php',
'OC\\Settings\\Controller\\LogSettingsController' => __DIR__ . '/../../..' . '/settings/Controller/LogSettingsController.php',
'OC\\Settings\\Controller\\MailSettingsController' => __DIR__ . '/../../..' . '/settings/Controller/MailSettingsController.php',
+ 'OC\\Settings\\Controller\\PersonalSettingsController' => __DIR__ . '/../../..' . '/settings/Controller/PersonalSettingsController.php',
'OC\\Settings\\Controller\\SecuritySettingsController' => __DIR__ . '/../../..' . '/settings/Controller/SecuritySettingsController.php',
'OC\\Settings\\Controller\\UsersController' => __DIR__ . '/../../..' . '/settings/Controller/UsersController.php',
'OC\\Settings\\Hooks' => __DIR__ . '/../../..' . '/settings/Hooks.php',
@@ -847,6 +849,10 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\Settings\\Manager' => __DIR__ . '/../../..' . '/lib/private/Settings/Manager.php',
'OC\\Settings\\Mapper' => __DIR__ . '/../../..' . '/lib/private/Settings/Mapper.php',
'OC\\Settings\\Middleware\\SubadminMiddleware' => __DIR__ . '/../../..' . '/settings/Middleware/SubadminMiddleware.php',
+ 'OC\\Settings\\Personal\\Additional' => __DIR__ . '/../../..' . '/lib/private/Settings/Personal/Additional.php',
+ 'OC\\Settings\\Personal\\PersonalInfo' => __DIR__ . '/../../..' . '/lib/private/Settings/Personal/PersonalInfo.php',
+ 'OC\\Settings\\Personal\\Security' => __DIR__ . '/../../..' . '/lib/private/Settings/Personal/Security.php',
+ 'OC\\Settings\\Personal\\SyncClients' => __DIR__ . '/../../..' . '/lib/private/Settings/Personal/SyncClients.php',
'OC\\Settings\\RemoveOrphaned' => __DIR__ . '/../../..' . '/lib/private/Settings/RemoveOrphaned.php',
'OC\\Settings\\Section' => __DIR__ . '/../../..' . '/lib/private/Settings/Section.php',
'OC\\Setup' => __DIR__ . '/../../..' . '/lib/private/Setup.php',
diff --git a/lib/private/NavigationManager.php b/lib/private/NavigationManager.php
index 300c24ff940..16552005931 100644
--- a/lib/private/NavigationManager.php
+++ b/lib/private/NavigationManager.php
@@ -177,14 +177,14 @@ class NavigationManager implements INavigationManager {
]);
}
- // Personal settings
+ // Personal and (if applicable) admin settings
$this->add([
'type' => 'settings',
- 'id' => 'personal',
+ 'id' => 'settings',
'order' => 1,
- 'href' => $this->urlGenerator->linkToRoute('settings_personal'),
- 'name' => $l->t('Personal'),
- 'icon' => $this->urlGenerator->imagePath('settings', 'personal.svg'),
+ 'href' => $this->urlGenerator->linkToRoute('settings.PersonalSettings.index'),
+ 'name' => $l->t('Settings'),
+ 'icon' => $this->urlGenerator->imagePath('settings', 'admin.svg'),
]);
// Logout
@@ -211,18 +211,6 @@ class NavigationManager implements INavigationManager {
'icon' => $this->urlGenerator->imagePath('settings', 'users.svg'),
]);
}
-
- if ($this->isAdmin()) {
- // Admin settings
- $this->add([
- 'type' => 'settings',
- 'id' => 'admin',
- 'order' => 2,
- 'href' => $this->urlGenerator->linkToRoute('settings.AdminSettings.index'),
- 'name' => $l->t('Admin'),
- 'icon' => $this->urlGenerator->imagePath('settings', 'admin.svg'),
- ]);
- }
}
if ($this->appManager === 'null') {
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 489683aa127..d10da38d299 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -42,6 +42,7 @@
namespace OC;
use bantu\IniGetWrapper\IniGetWrapper;
+use OC\Accounts\AccountManager;
use OC\App\AppManager;
use OC\App\AppStore\Bundles\BundleFetcher;
use OC\App\AppStore\Fetcher\AppFetcher;
@@ -970,7 +971,12 @@ class Server extends ServerContainer implements IServerContainer {
$c->getLockingProvider(),
$c->getRequest(),
new \OC\Settings\Mapper($c->getDatabaseConnection()),
- $c->getURLGenerator()
+ $c->getURLGenerator(),
+ $c->query(AccountManager::class),
+ $c->getGroupManager(),
+ $c->getL10NFactory(),
+ $c->getThemingDefaults(),
+ $c->getAppManager()
);
return $manager;
});
diff --git a/lib/private/Settings/Admin/Additional.php b/lib/private/Settings/Admin/Additional.php
index ffa0de68488..57bb382c1fa 100644
--- a/lib/private/Settings/Admin/Additional.php
+++ b/lib/private/Settings/Admin/Additional.php
@@ -61,7 +61,7 @@ class Additional implements ISettings {
$parameters['mail_smtppassword'] = '********';
}
- return new TemplateResponse('settings', 'admin/additional-mail', $parameters, '');
+ return new TemplateResponse('settings', 'settings/admin/additional-mail', $parameters, '');
}
/**
diff --git a/lib/private/Settings/Admin/Encryption.php b/lib/private/Settings/Admin/Encryption.php
index 63020c6bce7..7ee4bafbfeb 100644
--- a/lib/private/Settings/Admin/Encryption.php
+++ b/lib/private/Settings/Admin/Encryption.php
@@ -68,7 +68,7 @@ class Encryption implements ISettings {
'encryptionModules' => $encryptionModuleList,
];
- return new TemplateResponse('settings', 'admin/encryption', $parameters, '');
+ return new TemplateResponse('settings', 'settings/admin/encryption', $parameters, '');
}
/**
diff --git a/lib/private/Settings/Admin/Server.php b/lib/private/Settings/Admin/Server.php
index 5443336669f..994d927aff0 100644
--- a/lib/private/Settings/Admin/Server.php
+++ b/lib/private/Settings/Admin/Server.php
@@ -137,7 +137,7 @@ class Server implements ISettings {
'cli_based_cron_user' => function_exists('posix_getpwuid') ? posix_getpwuid(fileowner(\OC::$configDir . 'config.php'))['name'] : '',
];
- return new TemplateResponse('settings', 'admin/server', $parameters, '');
+ return new TemplateResponse('settings', 'settings/admin/server', $parameters, '');
}
/**
diff --git a/lib/private/Settings/Admin/ServerDevNotice.php b/lib/private/Settings/Admin/ServerDevNotice.php
index 39897d5c612..017113fd9ca 100644
--- a/lib/private/Settings/Admin/ServerDevNotice.php
+++ b/lib/private/Settings/Admin/ServerDevNotice.php
@@ -30,7 +30,7 @@ class ServerDevNotice implements ISettings {
* @return TemplateResponse
*/
public function getForm() {
- return new TemplateResponse('settings', 'admin/server.development.notice');
+ return new TemplateResponse('settings', 'settings/admin/server.development.notice');
}
/**
diff --git a/lib/private/Settings/Admin/Sharing.php b/lib/private/Settings/Admin/Sharing.php
index 8f57f77b20a..997a4d66581 100644
--- a/lib/private/Settings/Admin/Sharing.php
+++ b/lib/private/Settings/Admin/Sharing.php
@@ -67,7 +67,7 @@ class Sharing implements ISettings {
'enableLinkPasswordByDefault' => $this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no'),
];
- return new TemplateResponse('settings', 'admin/sharing', $parameters, '');
+ return new TemplateResponse('settings', 'settings/admin/sharing', $parameters, '');
}
/**
diff --git a/lib/private/Settings/Admin/TipsTricks.php b/lib/private/Settings/Admin/TipsTricks.php
index fd0fd595844..0df690dbbeb 100644
--- a/lib/private/Settings/Admin/TipsTricks.php
+++ b/lib/private/Settings/Admin/TipsTricks.php
@@ -48,7 +48,7 @@ class TipsTricks implements ISettings {
'databaseOverload' => $databaseOverload,
];
- return new TemplateResponse('settings', 'admin/tipstricks', $parameters, '');
+ return new TemplateResponse('settings', 'settings/admin/tipstricks', $parameters, '');
}
/**
diff --git a/lib/private/Settings/Manager.php b/lib/private/Settings/Manager.php
index d40dfd1e417..db147e05eb9 100644
--- a/lib/private/Settings/Manager.php
+++ b/lib/private/Settings/Manager.php
@@ -23,24 +23,25 @@
namespace OC\Settings;
+use OC\Accounts\AccountManager;
+use OCP\App\IAppManager;
use OCP\AppFramework\QueryException;
use OCP\Encryption\IManager as EncryptionManager;
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 OCP\Settings\ISettings;
use OCP\Settings\IManager;
use OCP\Settings\ISection;
class Manager implements IManager {
- const TABLE_ADMIN_SETTINGS = 'admin_settings';
- const TABLE_ADMIN_SECTIONS = 'admin_sections';
-
/** @var ILogger */
private $log;
/** @var IDBConnection */
@@ -61,6 +62,16 @@ class Manager implements IManager {
private $request;
/** @var IURLGenerator */
private $url;
+ /** @var AccountManager */
+ private $accountManager;
+ /** @var IGroupManager */
+ private $groupManager;
+ /** @var IFactory */
+ private $l10nFactory;
+ /** @var \OC_Defaults */
+ private $defaults;
+ /** @var IAppManager */
+ private $appManager;
/**
* @param ILogger $log
@@ -73,6 +84,10 @@ class Manager implements IManager {
* @param IRequest $request
* @param Mapper $mapper
* @param IURLGenerator $url
+ * @param AccountManager $accountManager
+ * @param IGroupManager $groupManager
+ * @param IFactory $l10nFactory
+ * @param \OC_Defaults $defaults
*/
public function __construct(
ILogger $log,
@@ -84,7 +99,12 @@ class Manager implements IManager {
ILockingProvider $lockingProvider,
IRequest $request,
Mapper $mapper,
- IURLGenerator $url
+ IURLGenerator $url,
+ AccountManager $accountManager,
+ IGroupManager $groupManager,
+ IFactory $l10nFactory,
+ \OC_Defaults $defaults,
+ IAppManager $appManager
) {
$this->log = $log;
$this->dbc = $dbc;
@@ -96,6 +116,11 @@ class Manager implements IManager {
$this->lockingProvider = $lockingProvider;
$this->request = $request;
$this->url = $url;
+ $this->accountManager = $accountManager;
+ $this->groupManager = $groupManager;
+ $this->l10nFactory = $l10nFactory;
+ $this->defaults = $defaults;
+ $this->appManager = $appManager;
}
/**
@@ -103,10 +128,17 @@ class Manager implements IManager {
*/
public function setupSettings(array $settings) {
if (isset($settings[IManager::KEY_ADMIN_SECTION])) {
- $this->setupAdminSection($settings[IManager::KEY_ADMIN_SECTION]);
+ $this->setupSectionEntry($settings[IManager::KEY_ADMIN_SECTION], 'admin');
}
if (isset($settings[IManager::KEY_ADMIN_SETTINGS])) {
- $this->setupAdminSettings($settings[IManager::KEY_ADMIN_SETTINGS]);
+ $this->setupSettingsEntry($settings[IManager::KEY_ADMIN_SETTINGS], 'admin');
+ }
+
+ if (isset($settings[IManager::KEY_PERSONAL_SECTION])) {
+ $this->setupSectionEntry($settings[IManager::KEY_PERSONAL_SECTION], 'personal');
+ }
+ if (isset($settings[IManager::KEY_PERSONAL_SETTINGS])) {
+ $this->setupSettingsEntry($settings[IManager::KEY_PERSONAL_SETTINGS], 'personal');
}
}
@@ -122,15 +154,22 @@ class Manager implements IManager {
$appInfo = \OC_App::getAppInfo($appId); // hello static legacy
if (isset($appInfo['settings'][IManager::KEY_ADMIN_SECTION])) {
- $this->mapper->remove(self::TABLE_ADMIN_SECTIONS, trim($appInfo['settings'][IManager::KEY_ADMIN_SECTION], '\\'));
+ $this->mapper->remove(Mapper::TABLE_ADMIN_SECTIONS, trim($appInfo['settings'][IManager::KEY_ADMIN_SECTION], '\\'));
}
if (isset($appInfo['settings'][IManager::KEY_ADMIN_SETTINGS])) {
- $this->mapper->remove(self::TABLE_ADMIN_SETTINGS, trim($appInfo['settings'][IManager::KEY_ADMIN_SETTINGS], '\\'));
+ $this->mapper->remove(Mapper::TABLE_ADMIN_SETTINGS, trim($appInfo['settings'][IManager::KEY_ADMIN_SETTINGS], '\\'));
+ }
+
+ if (isset($appInfo['settings'][IManager::KEY_PERSONAL_SECTION])) {
+ $this->mapper->remove(Mapper::TABLE_PERSONAL_SECTIONS, trim($appInfo['settings'][IManager::KEY_PERSONAL_SECTION], '\\'));
+ }
+ if (isset($appInfo['settings'][IManager::KEY_PERSONAL_SETTINGS])) {
+ $this->mapper->remove(Mapper::TABLE_PERSONAL_SETTINGS, trim($appInfo['settings'][IManager::KEY_PERSONAL_SETTINGS], '\\'));
}
}
public function checkForOrphanedClassNames() {
- $tables = [self::TABLE_ADMIN_SECTIONS, self::TABLE_ADMIN_SETTINGS];
+ $tables = [Mapper::TABLE_ADMIN_SECTIONS, Mapper::TABLE_ADMIN_SETTINGS, Mapper::TABLE_PERSONAL_SECTIONS, Mapper::TABLE_PERSONAL_SETTINGS];
foreach ($tables as $table) {
$classes = $this->mapper->getClasses($table);
foreach ($classes as $className) {
@@ -145,10 +184,11 @@ class Manager implements IManager {
/**
* @param string $sectionClassName
+ * @param string $type either 'admin' or 'personal'
*/
- private function setupAdminSection($sectionClassName) {
+ private function setupSectionEntry($sectionClassName, $type) {
if (!class_exists($sectionClassName)) {
- $this->log->debug('Could not find admin section class ' . $sectionClassName);
+ $this->log->debug('Could not find ' . ucfirst($type) . ' section class ' . $sectionClassName);
return;
}
try {
@@ -160,37 +200,38 @@ class Manager implements IManager {
if (!$section instanceof ISection) {
$this->log->error(
- 'Admin section instance must implement \OCP\ISection. Invalid class: {class}',
+ ucfirst($type) .' section instance must implement \OCP\ISection. Invalid class: {class}',
['class' => $sectionClassName]
);
return;
}
- if (!$this->hasAdminSection(get_class($section))) {
- $this->addAdminSection($section);
+ $table = $this->getSectionTableForType($type);
+ if(!$this->hasSection(get_class($section), $table)) {
+ $this->addSection($section, $table);
} else {
- $this->updateAdminSection($section);
+ $this->updateSection($section, $table);
}
}
- private function addAdminSection(ISection $section) {
- $this->mapper->add(self::TABLE_ADMIN_SECTIONS, [
+ private function addSection(ISection $section, $table) {
+ $this->mapper->add($table, [
'id' => $section->getID(),
'class' => get_class($section),
'priority' => $section->getPriority(),
]);
}
- private function addAdminSettings(ISettings $settings) {
- $this->mapper->add(self::TABLE_ADMIN_SETTINGS, [
+ private function addSettings(ISettings $settings, $table) {
+ $this->mapper->add($table, [
'class' => get_class($settings),
'section' => $settings->getSection(),
'priority' => $settings->getPriority(),
]);
}
- private function updateAdminSettings(ISettings $settings) {
+ private function updateSettings(ISettings $settings, $table) {
$this->mapper->update(
- self::TABLE_ADMIN_SETTINGS,
+ $table,
'class',
get_class($settings),
[
@@ -200,9 +241,9 @@ class Manager implements IManager {
);
}
- private function updateAdminSection(ISection $section) {
+ private function updateSection(ISection $section, $table) {
$this->mapper->update(
- self::TABLE_ADMIN_SECTIONS,
+ $table,
'class',
get_class($section),
[
@@ -214,23 +255,24 @@ class Manager implements IManager {
/**
* @param string $className
+ * @param string $table
* @return bool
*/
- private function hasAdminSection($className) {
- return $this->mapper->has(self::TABLE_ADMIN_SECTIONS, $className);
+ private function hasSection($className, $table) {
+ return $this->mapper->has($table, $className);
}
/**
* @param string $className
* @return bool
*/
- private function hasAdminSettings($className) {
- return $this->mapper->has(self::TABLE_ADMIN_SETTINGS, $className);
+ private function hasSettings($className, $table) {
+ return $this->mapper->has($table, $className);
}
- private function setupAdminSettings($settingsClassName) {
+ private function setupSettingsEntry($settingsClassName, $type) {
if (!class_exists($settingsClassName)) {
- $this->log->debug('Could not find admin section class ' . $settingsClassName);
+ $this->log->debug('Could not find ' . $type . ' section class ' . $settingsClassName);
return;
}
@@ -244,16 +286,35 @@ class Manager implements IManager {
if (!$settings instanceof ISettings) {
$this->log->error(
- 'Admin section instance must implement \OCP\Settings\ISection. Invalid class: {class}',
+ ucfirst($type) . ' section instance must implement \OCP\Settings\ISettings. Invalid class: {class}',
['class' => $settingsClassName]
);
return;
}
- if (!$this->hasAdminSettings(get_class($settings))) {
- $this->addAdminSettings($settings);
+ $table = $this->getSettingsTableForType($type);
+ if (!$this->hasSettings(get_class($settings), $table)) {
+ $this->addSettings($settings, $table);
} else {
- $this->updateAdminSettings($settings);
+ $this->updateSettings($settings, $table);
+ }
+ }
+
+ private function getSectionTableForType($type) {
+ if($type === 'admin') {
+ return Mapper::TABLE_ADMIN_SECTIONS;
+ } else if($type === 'personal') {
+ return Mapper::TABLE_PERSONAL_SECTIONS;
}
+ throw new \InvalidArgumentException('"admin" or "personal" expected');
+ }
+
+ private function getSettingsTableForType($type) {
+ if($type === 'admin') {
+ return Mapper::TABLE_ADMIN_SETTINGS;
+ } else if($type === 'personal') {
+ return Mapper::TABLE_PERSONAL_SETTINGS;
+ }
+ throw new \InvalidArgumentException('"admin" or "personal" expected');
}
private function query($className) {
@@ -338,6 +399,47 @@ class Manager implements IManager {
}
/**
+ * @param string $section
+ * @return ISection[]
+ */
+ private function getBuiltInPersonalSettings($section) {
+ $forms = [];
+ try {
+ if ($section === 'personal-info') {
+ /** @var ISettings $form */
+ $form = new Personal\PersonalInfo(
+ $this->config,
+ $this->userManager,
+ $this->groupManager,
+ $this->accountManager,
+ $this->appManager,
+ $this->l10nFactory,
+ $this->l
+ );
+ $forms[$form->getPriority()] = [$form];
+ }
+ if($section === 'security') {
+ /** @var ISettings $form */
+ $form = new Personal\Security();
+ $forms[$form->getPriority()] = [$form];
+ }
+ if($section === 'sync-clients') {
+ /** @var ISettings $form */
+ $form = new Personal\SyncClients($this->config, $this->defaults);
+ $forms[$form->getPriority()] = [$form];
+ }
+ if ($section === 'additional') {
+ /** @var ISettings $form */
+ $form = new Personal\Additional($this->config);
+ $forms[$form->getPriority()] = [$form];
+ }
+ } catch (QueryException $e) {
+ // skip
+ }
+ return $forms;
+ }
+
+ /**
* @inheritdoc
*/
public function getAdminSettings($section) {
@@ -358,4 +460,72 @@ class Manager implements IManager {
ksort($settings);
return $settings;
}
+
+ /**
+ * @inheritdoc
+ */
+ public function getPersonalSections() {
+ $sections = [
+ 0 => [new Section('personal-info', $this->l->t('Personal info'), 0, $this->url->imagePath('core', 'actions/info.svg'))],
+ 5 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('settings', 'password.svg'))],
+ 15 => [new Section('sync-clients', $this->l->t('Sync clients'), 0, $this->url->imagePath('settings', 'change.svg'))],
+ ];
+
+ $legacyForms = \OC_App::getForms('personal');
+ if(count($legacyForms) > 0 && $this->hasLegacyPersonalSettingsToRender($legacyForms)) {
+ $sections[98] = [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))];
+ }
+
+ $rows = $this->mapper->getPersonalSectionsFromDB();
+
+ foreach ($rows as $row) {
+ if (!isset($sections[$row['priority']])) {
+ $sections[$row['priority']] = [];
+ }
+ try {
+ $sections[$row['priority']][] = $this->query($row['class']);
+ } catch (QueryException $e) {
+ // skip
+ }
+ }
+
+ ksort($sections);
+
+ return $sections;
+ }
+
+ /**
+ * @param $forms
+ * @return bool
+ */
+ private function hasLegacyPersonalSettingsToRender($forms) {
+ foreach ($forms as $form) {
+ if(trim($form) !== '') {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getPersonalSettings($section) {
+ $settings = $this->getBuiltInPersonalSettings($section);
+ $dbRows = $this->mapper->getPersonalSettingsFromDB($section);
+
+ foreach ($dbRows as $row) {
+ if (!isset($settings[$row['priority']])) {
+ $settings[$row['priority']] = [];
+ }
+ try {
+ $settings[$row['priority']][] = $this->query($row['class']);
+ } catch (QueryException $e) {
+ // skip
+ }
+ }
+
+ ksort($settings);
+ return $settings;
+ }
}
diff --git a/lib/private/Settings/Mapper.php b/lib/private/Settings/Mapper.php
index 2525f2c9854..3219a812cd5 100644
--- a/lib/private/Settings/Mapper.php
+++ b/lib/private/Settings/Mapper.php
@@ -28,6 +28,8 @@ use OCP\IDBConnection;
class Mapper {
const TABLE_ADMIN_SETTINGS = 'admin_settings';
const TABLE_ADMIN_SECTIONS = 'admin_sections';
+ const TABLE_PERSONAL_SETTINGS = 'personal_settings';
+ const TABLE_PERSONAL_SECTIONS = 'personal_sections';
/** @var IDBConnection */
private $dbc;
@@ -46,9 +48,30 @@ class Mapper {
* @return array[] [['class' => string, 'priority' => int], ...]
*/
public function getAdminSettingsFromDB($section) {
+ return $this->getSettingsFromDB(self::TABLE_ADMIN_SETTINGS, $section);
+ }
+
+ /**
+ * Get the configured personal settings from the database for the provided section
+ *
+ * @param string $section
+ * @return array[] [['class' => string, 'priority' => int], ...]
+ */
+ public function getPersonalSettingsFromDB($section) {
+ return $this->getSettingsFromDB(self::TABLE_PERSONAL_SETTINGS, $section);
+ }
+
+ /**
+ * Get the configured settings from the database for the provided table and section
+ *
+ * @param $table
+ * @param $section
+ * @return array
+ */
+ private function getSettingsFromDB($table, $section) {
$query = $this->dbc->getQueryBuilder();
$query->select(['class', 'priority'])
- ->from(self::TABLE_ADMIN_SETTINGS)
+ ->from($table)
->where($query->expr()->eq('section', $this->dbc->getQueryBuilder()->createParameter('section')))
->setParameter('section', $section);
@@ -62,11 +85,39 @@ class Mapper {
* @return array[] [['class' => string, 'priority' => int], ...]
*/
public function getAdminSectionsFromDB() {
+ return $this->getSectionsFromDB('admin');
+ }
+
+ /**
+ * Get the configured admin sections from the database
+ *
+ * @return array[] [['class' => string, 'priority' => int], ...]
+ */
+ public function getPersonalSectionsFromDB() {
+ return $this->getSectionsFromDB('personal');
+ }
+
+ /**
+ * Get the configured sections from the database by table
+ *
+ * @param string $type either 'personal' or 'admin'
+ * @return array[] [['class' => string, 'priority' => int], ...]
+ */
+ public function getSectionsFromDB($type) {
+ if($type === 'admin') {
+ $sectionsTable = self::TABLE_ADMIN_SECTIONS;
+ $settingsTable = self::TABLE_ADMIN_SETTINGS;
+ } else if($type === 'personal') {
+ $sectionsTable = self::TABLE_PERSONAL_SECTIONS;
+ $settingsTable = self::TABLE_PERSONAL_SETTINGS;
+ } else {
+ throw new \InvalidArgumentException('"admin" or "personal" expected');
+ }
$query = $this->dbc->getQueryBuilder();
$query->selectDistinct('s.class')
->addSelect('s.priority')
- ->from(self::TABLE_ADMIN_SECTIONS, 's')
- ->from(self::TABLE_ADMIN_SETTINGS, 'f')
+ ->from($sectionsTable, 's')
+ ->from($settingsTable, 'f')
->where($query->expr()->eq('s.id', 'f.section'));
$result = $query->execute();
return array_map(function ($row) {
@@ -76,7 +127,7 @@ class Mapper {
}
/**
- * @param string $table Mapper::TABLE_ADMIN_SECTIONS or Mapper::TABLE_ADMIN_SETTINGS
+ * @param string $table one of the Mapper::TABLE_* constants
* @param array $values
*/
public function add($table, array $values) {
@@ -91,7 +142,7 @@ class Mapper {
/**
* returns the registered classes in the given table
*
- * @param $table Mapper::TABLE_ADMIN_SECTIONS or Mapper::TABLE_ADMIN_SETTINGS
+ * @param string $table one of the Mapper::TABLE_* constants
* @return string[]
*/
public function getClasses($table) {
@@ -110,7 +161,7 @@ class Mapper {
/**
* Check if a class is configured in the database
*
- * @param string $table Mapper::TABLE_ADMIN_SECTIONS or Mapper::TABLE_ADMIN_SETTINGS
+ * @param string $table one of the Mapper::TABLE_* constants
* @param string $className
* @return bool
*/
@@ -131,8 +182,8 @@ class Mapper {
/**
* deletes an settings or admin entry from the given table
*
- * @param $table Mapper::TABLE_ADMIN_SECTIONS or Mapper::TABLE_ADMIN_SETTINGS
- * @param $className
+ * @param string $table one of the Mapper::TABLE_* constants
+ * @param string $className
*/
public function remove($table, $className) {
$query = $this->dbc->getQueryBuilder();
@@ -143,10 +194,10 @@ class Mapper {
}
/**
- * @param $table Mapper::TABLE_ADMIN_SECTIONS or Mapper::TABLE_ADMIN_SETTINGS
- * @param $idCol
- * @param $id
- * @param $values
+ * @param string $table one of the Mapper::TABLE_* constants
+ * @param string $idCol
+ * @param string $id
+ * @param array $values
*/
public function update($table, $idCol, $id, $values) {
$query = $this->dbc->getQueryBuilder();
diff --git a/lib/private/Settings/Personal/Additional.php b/lib/private/Settings/Personal/Additional.php
new file mode 100644
index 00000000000..b2bb26dc6bf
--- /dev/null
+++ b/lib/private/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 OC\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/lib/private/Settings/Personal/PersonalInfo.php b/lib/private/Settings/Personal/PersonalInfo.php
new file mode 100644
index 00000000000..fb1f388c599
--- /dev/null
+++ b/lib/private/Settings/Personal/PersonalInfo.php
@@ -0,0 +1,284 @@
+<?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 OC\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;
+
+ const COMMON_LANGUAGE_CODES = [
+ 'en', 'es', 'fr', 'de', 'de_DE', 'ja', 'ar', 'ru', 'nl', 'it',
+ 'pt_BR', 'pt_PT', 'da', 'fi_FI', 'nb_NO', 'sv', 'tr', 'zh_CN', 'ko'
+ ];
+
+ /** @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);
+ $messageParameters = $this->getMessageParameters($userData);
+
+ $parameters = [
+ 'total_space' => $totalSpace,
+ 'usage' => \OC_Helper::humanFileSize($storageInfo['used']),
+ 'usage_relative' => $storageInfo['relative'],
+ 'quota' => $storageInfo['quota'],
+ 'avatarChangeSupported' => \OC_User::canUserChangeAvatar($uid),
+ 'lookupServerUploadEnabled' => $lookupServerUploadEnabled,
+ 'avatarScope' => $userData[AccountManager::PROPERTY_AVATAR]['scope'],
+ 'displayNameChangeSupported' => \OC_User::canUserChangeDisplayName($uid),
+ '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),
+ 'passwordChangeSupported' => \OC_User::canUserChangePassword($uid),
+ ] + $messageParameters + $languageParameters;
+
+
+ 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->getGID();
+ },
+ $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();
+
+ $userLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage());
+ $languageCodes = $this->l10nFactory->findAvailableLanguages();
+
+ $commonLanguages = [];
+ $languages = [];
+
+ foreach($languageCodes as $lang) {
+ $l = \OC::$server->getL10N('settings', $lang);
+ // TRANSLATORS this is the language name for the language switcher in the personal settings and should be the localized version
+ $potentialName = (string) $l->t('__language_name__');
+ if($l->getLanguageCode() === $lang && substr($potentialName, 0, 1) !== '_') {//first check if the language name is in the translation file
+ $ln = array('code' => $lang, 'name' => $potentialName);
+ } elseif ($lang === 'en') {
+ $ln = ['code' => $lang, 'name' => 'English (US)'];
+ }else{//fallback to language code
+ $ln=array('code'=>$lang, 'name'=>$lang);
+ }
+
+ // put appropriate languages into appropriate arrays, to print them sorted
+ // used language -> common languages -> divider -> other languages
+ if ($lang === $userLang) {
+ $userLang = $ln;
+ } elseif (in_array($lang, self::COMMON_LANGUAGE_CODES)) {
+ $commonLanguages[array_search($lang, self::COMMON_LANGUAGE_CODES)]=$ln;
+ } else {
+ $languages[]=$ln;
+ }
+ }
+
+ // if user language is not available but set somehow: show the actual code as name
+ if (!is_array($userLang)) {
+ $userLang = [
+ 'code' => $userLang,
+ 'name' => $userLang,
+ ];
+ }
+
+ ksort($commonLanguages);
+
+ // sort now by displayed language not the iso-code
+ usort( $languages, function ($a, $b) {
+ if ($a['code'] === $a['name'] && $b['code'] !== $b['name']) {
+ // If a doesn't have a name, but b does, list b before a
+ return 1;
+ }
+ if ($a['code'] !== $a['name'] && $b['code'] === $b['name']) {
+ // If a does have a name, but b doesn't, list a before b
+ return -1;
+ }
+ // Otherwise compare the names
+ return strcmp($a['name'], $b['name']);
+ });
+
+ return [
+ 'activelanguage' => $userLang,
+ 'commonlanguages' => $commonLanguages,
+ 'languages' => $languages
+ ];
+ }
+
+ /**
+ * @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/lib/private/Settings/Personal/Security.php b/lib/private/Settings/Personal/Security.php
new file mode 100644
index 00000000000..ecbd1199d11
--- /dev/null
+++ b/lib/private/Settings/Personal/Security.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 OC\Settings\Personal;
+
+
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\Settings\ISettings;
+
+class Security 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/personal/security');
+ }
+
+ /**
+ * @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 10;
+ }
+}
diff --git a/lib/private/Settings/Personal/SyncClients.php b/lib/private/Settings/Personal/SyncClients.php
new file mode 100644
index 00000000000..c4efcb63fe5
--- /dev/null
+++ b/lib/private/Settings/Personal/SyncClients.php
@@ -0,0 +1,85 @@
+<?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 OC\Settings\Personal;
+
+
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\IConfig;
+use OCP\Settings\ISettings;
+
+class SyncClients implements ISettings {
+
+ /** @var IConfig */
+ private $config;
+ /** @var \OC_Defaults */
+ private $defaults;
+
+ public function __construct(IConfig $config, \OC_Defaults $defaults) {
+ $this->config = $config;
+ $this->defaults = $defaults;
+ }
+
+ /**
+ * @return TemplateResponse returns the instance with all parameters set, ready to be rendered
+ * @since 9.1
+ */
+ public function getForm() {
+ $parameters = [ 'clients' => $this->getClientLinks() ];
+ return new TemplateResponse('settings', 'settings/personal/sync-clients', $parameters);
+ }
+
+ /**
+ * @return string the section ID, e.g. 'sharing'
+ * @since 9.1
+ */
+ public function getSection() {
+ return 'sync-clients';
+ }
+
+ /**
+ * @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 20;
+ }
+
+ /**
+ * returns an array containing links to the various clients
+ *
+ * @return array
+ */
+ private function getClientLinks() {
+ $clients = [
+ 'desktop' => $this->config->getSystemValue('customclient_desktop', $this->defaults->getSyncClientUrl()),
+ 'android' => $this->config->getSystemValue('customclient_android', $this->defaults->getAndroidClientUrl()),
+ 'ios' => $this->config->getSystemValue('customclient_ios', $this->defaults->getiOSClientUrl())
+ ];
+ return $clients;
+ }
+}
diff --git a/lib/public/Settings/IManager.php b/lib/public/Settings/IManager.php
index a406915ad09..7a24eab3896 100644
--- a/lib/public/Settings/IManager.php
+++ b/lib/public/Settings/IManager.php
@@ -38,6 +38,16 @@ interface IManager {
const KEY_ADMIN_SECTION = 'admin-section';
/**
+ * @since 13.0.0
+ */
+ const KEY_PERSONAL_SETTINGS = 'personal';
+
+ /**
+ * @since 13.0.0
+ */
+ const KEY_PERSONAL_SECTION = 'personal-section';
+
+ /**
* sets up settings according to data specified by an apps info.xml, within
* the <settings> element.
*
@@ -88,6 +98,14 @@ interface IManager {
public function getAdminSections();
/**
+ * returns a list of the personal sections
+ *
+ * @return array array of ISection[] where key is the priority
+ * @since 13.0.0
+ */
+ public function getPersonalSections();
+
+ /**
* returns a list of the admin settings
*
* @param string $section the section id for which to load the settings
@@ -95,4 +113,13 @@ interface IManager {
* @since 9.1.0
*/
public function getAdminSettings($section);
+
+ /**
+ * returns a list of the personal settings
+ *
+ * @param string $section the section id for which to load the settings
+ * @return array array of IPersonal[] where key is the priority
+ * @since 13.0.0
+ */
+ public function getPersonalSettings($section);
}