2016-08-09 00:31:26 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
|
|
|
|
*
|
|
|
|
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
|
|
|
* @author Lukas Reschke <lukas@statuscode.ch>
|
|
|
|
* @author Marius Blüm <marius@lineone.io>
|
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
|
|
|
* @author Robin Appelman <robin@icewind.nl>
|
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2016-08-09 00:31:26 +03:00
|
|
|
*
|
|
|
|
* @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;
|
|
|
|
|
2017-05-16 03:46:42 +03:00
|
|
|
use OC\Accounts\AccountManager;
|
2017-06-16 16:00:15 +03:00
|
|
|
use OCP\App\IAppManager;
|
2016-08-09 00:31:26 +03:00
|
|
|
use OCP\AppFramework\QueryException;
|
|
|
|
use OCP\Encryption\IManager as EncryptionManager;
|
|
|
|
use OCP\IConfig;
|
|
|
|
use OCP\IDBConnection;
|
2017-05-16 03:46:42 +03:00
|
|
|
use OCP\IGroupManager;
|
2016-08-09 00:31:26 +03:00
|
|
|
use OCP\IL10N;
|
|
|
|
use OCP\ILogger;
|
2017-03-17 15:34:23 +03:00
|
|
|
use OCP\IRequest;
|
2017-01-19 12:37:17 +03:00
|
|
|
use OCP\IURLGenerator;
|
2016-08-09 00:31:26 +03:00
|
|
|
use OCP\IUserManager;
|
2017-05-16 03:46:42 +03:00
|
|
|
use OCP\L10N\IFactory;
|
2016-08-12 17:52:20 +03:00
|
|
|
use OCP\Lock\ILockingProvider;
|
2016-08-11 15:48:21 +03:00
|
|
|
use OCP\Settings\ISettings;
|
2016-08-09 00:31:26 +03:00
|
|
|
use OCP\Settings\IManager;
|
|
|
|
use OCP\Settings\ISection;
|
2018-01-10 11:02:01 +03:00
|
|
|
use OCP\Util;
|
2016-08-09 00:31:26 +03:00
|
|
|
|
|
|
|
class Manager implements IManager {
|
|
|
|
/** @var ILogger */
|
|
|
|
private $log;
|
|
|
|
/** @var IDBConnection */
|
|
|
|
private $dbc;
|
|
|
|
/** @var IL10N */
|
|
|
|
private $l;
|
|
|
|
/** @var IConfig */
|
|
|
|
private $config;
|
|
|
|
/** @var EncryptionManager */
|
|
|
|
private $encryptionManager;
|
|
|
|
/** @var IUserManager */
|
|
|
|
private $userManager;
|
2016-08-12 17:52:20 +03:00
|
|
|
/** @var ILockingProvider */
|
|
|
|
private $lockingProvider;
|
2017-03-17 15:34:23 +03:00
|
|
|
/** @var IRequest */
|
|
|
|
private $request;
|
2017-01-19 12:37:17 +03:00
|
|
|
/** @var IURLGenerator */
|
|
|
|
private $url;
|
2017-05-16 03:46:42 +03:00
|
|
|
/** @var AccountManager */
|
|
|
|
private $accountManager;
|
|
|
|
/** @var IGroupManager */
|
|
|
|
private $groupManager;
|
|
|
|
/** @var IFactory */
|
|
|
|
private $l10nFactory;
|
2017-06-16 16:00:15 +03:00
|
|
|
/** @var IAppManager */
|
|
|
|
private $appManager;
|
2016-08-12 17:52:20 +03:00
|
|
|
|
2016-08-15 17:24:56 +03:00
|
|
|
/**
|
|
|
|
* @param ILogger $log
|
|
|
|
* @param IDBConnection $dbc
|
|
|
|
* @param IL10N $l
|
|
|
|
* @param IConfig $config
|
|
|
|
* @param EncryptionManager $encryptionManager
|
|
|
|
* @param IUserManager $userManager
|
|
|
|
* @param ILockingProvider $lockingProvider
|
2017-03-17 15:34:23 +03:00
|
|
|
* @param IRequest $request
|
2017-01-19 12:37:17 +03:00
|
|
|
* @param IURLGenerator $url
|
2017-05-16 03:46:42 +03:00
|
|
|
* @param AccountManager $accountManager
|
|
|
|
* @param IGroupManager $groupManager
|
|
|
|
* @param IFactory $l10nFactory
|
2018-01-29 15:14:56 +03:00
|
|
|
* @param IAppManager $appManager
|
2016-08-15 17:24:56 +03:00
|
|
|
*/
|
2016-08-09 00:31:26 +03:00
|
|
|
public function __construct(
|
|
|
|
ILogger $log,
|
|
|
|
IDBConnection $dbc,
|
|
|
|
IL10N $l,
|
|
|
|
IConfig $config,
|
|
|
|
EncryptionManager $encryptionManager,
|
2016-08-12 17:52:20 +03:00
|
|
|
IUserManager $userManager,
|
2016-12-28 18:58:02 +03:00
|
|
|
ILockingProvider $lockingProvider,
|
2017-03-17 15:34:23 +03:00
|
|
|
IRequest $request,
|
2017-05-16 03:46:42 +03:00
|
|
|
IURLGenerator $url,
|
|
|
|
AccountManager $accountManager,
|
|
|
|
IGroupManager $groupManager,
|
|
|
|
IFactory $l10nFactory,
|
2017-06-16 16:00:15 +03:00
|
|
|
IAppManager $appManager
|
2016-08-09 00:31:26 +03:00
|
|
|
) {
|
|
|
|
$this->log = $log;
|
|
|
|
$this->dbc = $dbc;
|
|
|
|
$this->l = $l;
|
|
|
|
$this->config = $config;
|
|
|
|
$this->encryptionManager = $encryptionManager;
|
|
|
|
$this->userManager = $userManager;
|
2016-08-12 17:52:20 +03:00
|
|
|
$this->lockingProvider = $lockingProvider;
|
2017-03-17 15:34:23 +03:00
|
|
|
$this->request = $request;
|
2017-01-19 12:37:17 +03:00
|
|
|
$this->url = $url;
|
2017-05-16 03:46:42 +03:00
|
|
|
$this->accountManager = $accountManager;
|
|
|
|
$this->groupManager = $groupManager;
|
|
|
|
$this->l10nFactory = $l10nFactory;
|
2017-06-16 16:00:15 +03:00
|
|
|
$this->appManager = $appManager;
|
2016-08-09 00:31:26 +03:00
|
|
|
}
|
|
|
|
|
2018-01-29 15:14:56 +03:00
|
|
|
/** @var array */
|
|
|
|
protected $sectionClasses = [];
|
|
|
|
|
|
|
|
/** @var array */
|
|
|
|
protected $sections = [];
|
|
|
|
|
2016-08-09 00:31:26 +03:00
|
|
|
/**
|
2018-01-29 15:14:56 +03:00
|
|
|
* @param string $type 'admin' or 'personal'
|
|
|
|
* @param string $section Class must implement OCP\Settings\ISection
|
|
|
|
* @return void
|
2016-08-09 00:31:26 +03:00
|
|
|
*/
|
2018-01-29 15:14:56 +03:00
|
|
|
public function registerSection(string $type, string $section) {
|
|
|
|
$this->sectionClasses[$section] = $type;
|
2016-08-09 00:31:26 +03:00
|
|
|
}
|
|
|
|
|
2016-08-15 21:03:19 +03:00
|
|
|
/**
|
2018-01-29 15:14:56 +03:00
|
|
|
* @param string $type 'admin' or 'personal'
|
|
|
|
* @return ISection[]
|
2016-08-15 21:03:19 +03:00
|
|
|
*/
|
2018-01-29 15:14:56 +03:00
|
|
|
protected function getSections(string $type): array {
|
|
|
|
if (!isset($this->sections[$type])) {
|
|
|
|
$this->sections[$type] = [];
|
2017-05-19 13:11:07 +03:00
|
|
|
}
|
|
|
|
|
2018-01-29 15:14:56 +03:00
|
|
|
foreach ($this->sectionClasses as $class => $sectionType) {
|
|
|
|
try {
|
|
|
|
/** @var ISection $section */
|
|
|
|
$section = \OC::$server->query($class);
|
|
|
|
} catch (QueryException $e) {
|
2018-04-25 16:22:28 +03:00
|
|
|
$this->log->logException($e, ['level' => ILogger::INFO]);
|
2018-01-29 15:14:56 +03:00
|
|
|
continue;
|
2017-10-04 17:35:10 +03:00
|
|
|
}
|
2016-08-15 21:03:19 +03:00
|
|
|
|
2018-01-29 15:14:56 +03:00
|
|
|
if (!$section instanceof ISection) {
|
2018-04-25 16:22:28 +03:00
|
|
|
$this->log->logException(new \InvalidArgumentException('Invalid settings section registered'), ['level' => ILogger::INFO]);
|
2018-01-29 15:14:56 +03:00
|
|
|
continue;
|
2016-08-16 01:52:41 +03:00
|
|
|
}
|
|
|
|
|
2018-01-29 15:14:56 +03:00
|
|
|
$this->sections[$sectionType][$section->getID()] = $section;
|
2016-08-09 00:31:26 +03:00
|
|
|
|
2018-01-29 15:14:56 +03:00
|
|
|
unset($this->sectionClasses[$class]);
|
2016-08-09 00:31:26 +03:00
|
|
|
}
|
|
|
|
|
2018-01-29 15:14:56 +03:00
|
|
|
return $this->sections[$type];
|
2016-08-09 00:31:26 +03:00
|
|
|
}
|
|
|
|
|
2018-01-29 15:14:56 +03:00
|
|
|
/** @var array */
|
|
|
|
protected $settingClasses = [];
|
2016-08-09 00:31:26 +03:00
|
|
|
|
2018-01-29 15:14:56 +03:00
|
|
|
/** @var array */
|
|
|
|
protected $settings = [];
|
2016-08-11 02:41:18 +03:00
|
|
|
|
|
|
|
/**
|
2018-01-29 15:14:56 +03:00
|
|
|
* @param string $type 'admin' or 'personal'
|
|
|
|
* @param string $setting Class must implement OCP\Settings\ISetting
|
|
|
|
* @return void
|
2016-08-11 02:41:18 +03:00
|
|
|
*/
|
2018-01-29 15:14:56 +03:00
|
|
|
public function registerSetting(string $type, string $setting) {
|
|
|
|
$this->settingClasses[$setting] = $type;
|
2016-08-11 02:41:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-01-29 15:14:56 +03:00
|
|
|
* @param string $type 'admin' or 'personal'
|
|
|
|
* @param string $section
|
|
|
|
* @return ISettings[]
|
2016-08-11 02:41:18 +03:00
|
|
|
*/
|
2018-01-29 15:14:56 +03:00
|
|
|
protected function getSettings(string $type, string $section): array {
|
|
|
|
if (!isset($this->settings[$type])) {
|
|
|
|
$this->settings[$type] = [];
|
2016-08-09 00:31:26 +03:00
|
|
|
}
|
2018-01-29 15:14:56 +03:00
|
|
|
if (!isset($this->settings[$type][$section])) {
|
|
|
|
$this->settings[$type][$section] = [];
|
2016-08-09 00:31:26 +03:00
|
|
|
}
|
|
|
|
|
2018-01-29 15:14:56 +03:00
|
|
|
foreach ($this->settingClasses as $class => $settingsType) {
|
|
|
|
try {
|
|
|
|
/** @var ISettings $setting */
|
|
|
|
$setting = \OC::$server->query($class);
|
|
|
|
} catch (QueryException $e) {
|
2018-04-25 16:22:28 +03:00
|
|
|
$this->log->logException($e, ['level' => ILogger::INFO]);
|
2018-01-29 15:14:56 +03:00
|
|
|
continue;
|
|
|
|
}
|
2016-08-09 00:31:26 +03:00
|
|
|
|
2018-01-29 15:14:56 +03:00
|
|
|
if (!$setting instanceof ISettings) {
|
2018-04-25 16:22:28 +03:00
|
|
|
$this->log->logException(new \InvalidArgumentException('Invalid settings setting registered'), ['level' => ILogger::INFO]);
|
2018-01-29 15:14:56 +03:00
|
|
|
continue;
|
|
|
|
}
|
2017-05-19 13:11:07 +03:00
|
|
|
|
2018-01-29 15:14:56 +03:00
|
|
|
if (!isset($this->settings[$settingsType][$setting->getSection()])) {
|
|
|
|
$this->settings[$settingsType][$setting->getSection()] = [];
|
|
|
|
}
|
|
|
|
$this->settings[$settingsType][$setting->getSection()][] = $setting;
|
2017-05-19 13:11:07 +03:00
|
|
|
|
2018-01-29 15:14:56 +03:00
|
|
|
unset($this->settingClasses[$class]);
|
2016-08-09 00:31:26 +03:00
|
|
|
}
|
2018-01-29 15:14:56 +03:00
|
|
|
|
|
|
|
return $this->settings[$type][$section];
|
2016-08-09 00:31:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-08-15 17:24:56 +03:00
|
|
|
* @inheritdoc
|
2016-08-09 00:31:26 +03:00
|
|
|
*/
|
2018-01-29 15:14:56 +03:00
|
|
|
public function getAdminSections(): array {
|
2016-08-09 00:31:26 +03:00
|
|
|
// built-in sections
|
|
|
|
$sections = [
|
2018-03-29 18:12:03 +03:00
|
|
|
0 => [new Section('overview', $this->l->t('Overview'), 0, $this->url->imagePath('settings', 'admin.svg'))],
|
2018-04-09 22:49:03 +03:00
|
|
|
1 => [new Section('server', $this->l->t('Basic settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))],
|
2017-01-19 12:37:17 +03:00
|
|
|
5 => [new Section('sharing', $this->l->t('Sharing'), 0, $this->url->imagePath('core', 'actions/share.svg'))],
|
2017-03-14 04:44:10 +03:00
|
|
|
10 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('core', 'actions/password.svg'))],
|
2017-01-19 12:37:17 +03:00
|
|
|
45 => [new Section('encryption', $this->l->t('Encryption'), 0, $this->url->imagePath('core', 'actions/password.svg'))],
|
|
|
|
98 => [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))],
|
|
|
|
99 => [new Section('tips-tricks', $this->l->t('Tips & tricks'), 0, $this->url->imagePath('settings', 'help.svg'))],
|
2016-08-09 00:31:26 +03:00
|
|
|
];
|
|
|
|
|
2018-01-29 15:14:56 +03:00
|
|
|
$appSections = $this->getSections('admin');
|
2016-08-19 18:52:33 +03:00
|
|
|
|
2018-01-29 15:14:56 +03:00
|
|
|
foreach ($appSections as $section) {
|
|
|
|
/** @var ISection $section */
|
|
|
|
if (!isset($sections[$section->getPriority()])) {
|
|
|
|
$sections[$section->getPriority()] = [];
|
2016-08-09 00:31:26 +03:00
|
|
|
}
|
2018-01-29 15:14:56 +03:00
|
|
|
|
|
|
|
$sections[$section->getPriority()][] = $section;
|
2016-08-09 00:31:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
ksort($sections);
|
2016-12-28 18:58:02 +03:00
|
|
|
|
2016-08-09 00:31:26 +03:00
|
|
|
return $sections;
|
|
|
|
}
|
|
|
|
|
2016-12-28 18:58:02 +03:00
|
|
|
/**
|
|
|
|
* @param string $section
|
|
|
|
* @return ISection[]
|
|
|
|
*/
|
2018-01-29 15:14:56 +03:00
|
|
|
private function getBuiltInAdminSettings($section): array {
|
2016-08-09 00:31:26 +03:00
|
|
|
$forms = [];
|
2018-01-29 15:14:56 +03:00
|
|
|
|
2018-03-29 18:12:03 +03:00
|
|
|
if ($section === 'overview') {
|
2018-01-29 15:14:56 +03:00
|
|
|
/** @var ISettings $form */
|
2018-03-29 18:12:03 +03:00
|
|
|
$form = new Admin\Overview($this->dbc, $this->request, $this->config, $this->lockingProvider, $this->l);
|
2018-01-29 15:14:56 +03:00
|
|
|
$forms[$form->getPriority()] = [$form];
|
|
|
|
$form = new Admin\ServerDevNotice();
|
|
|
|
$forms[$form->getPriority()] = [$form];
|
|
|
|
}
|
2018-03-29 18:12:03 +03:00
|
|
|
if ($section === 'server') {
|
|
|
|
/** @var ISettings $form */
|
|
|
|
$form = new Admin\Server($this->dbc, $this->request, $this->config, $this->lockingProvider, $this->l);
|
|
|
|
$forms[$form->getPriority()] = [$form];
|
2018-03-29 18:23:22 +03:00
|
|
|
$form = new Admin\Mail($this->config);
|
|
|
|
$forms[$form->getPriority()] = [$form];
|
2018-03-29 18:12:03 +03:00
|
|
|
}
|
2018-01-29 15:14:56 +03:00
|
|
|
if ($section === 'encryption') {
|
|
|
|
/** @var ISettings $form */
|
|
|
|
$form = new Admin\Encryption($this->encryptionManager, $this->userManager);
|
|
|
|
$forms[$form->getPriority()] = [$form];
|
2016-08-09 00:31:26 +03:00
|
|
|
}
|
2018-01-29 15:14:56 +03:00
|
|
|
if ($section === 'sharing') {
|
|
|
|
/** @var ISettings $form */
|
2017-12-01 13:35:01 +03:00
|
|
|
$form = new Admin\Sharing($this->config, $this->l);
|
2018-01-29 15:14:56 +03:00
|
|
|
$forms[$form->getPriority()] = [$form];
|
|
|
|
}
|
|
|
|
if ($section === 'tips-tricks') {
|
|
|
|
/** @var ISettings $form */
|
|
|
|
$form = new Admin\TipsTricks($this->config);
|
|
|
|
$forms[$form->getPriority()] = [$form];
|
|
|
|
}
|
|
|
|
|
2016-08-09 00:31:26 +03:00
|
|
|
return $forms;
|
|
|
|
}
|
|
|
|
|
2017-05-16 02:40:36 +03:00
|
|
|
/**
|
|
|
|
* @param string $section
|
|
|
|
* @return ISection[]
|
|
|
|
*/
|
2018-01-29 15:14:56 +03:00
|
|
|
private function getBuiltInPersonalSettings($section): array {
|
2017-05-16 02:40:36 +03:00
|
|
|
$forms = [];
|
2018-01-29 15:14:56 +03:00
|
|
|
|
|
|
|
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 === 'additional') {
|
|
|
|
/** @var ISettings $form */
|
|
|
|
$form = new Personal\Additional();
|
|
|
|
$forms[$form->getPriority()] = [$form];
|
2017-05-16 02:40:36 +03:00
|
|
|
}
|
2018-01-29 15:14:56 +03:00
|
|
|
|
2017-05-16 02:40:36 +03:00
|
|
|
return $forms;
|
|
|
|
}
|
|
|
|
|
2016-12-28 18:58:02 +03:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2018-01-29 15:14:56 +03:00
|
|
|
public function getAdminSettings($section): array {
|
2016-12-28 18:58:02 +03:00
|
|
|
$settings = $this->getBuiltInAdminSettings($section);
|
2018-01-29 15:14:56 +03:00
|
|
|
$appSettings = $this->getSettings('admin', $section);
|
2016-08-09 00:31:26 +03:00
|
|
|
|
2018-01-29 15:14:56 +03:00
|
|
|
foreach ($appSettings as $setting) {
|
|
|
|
if (!isset($settings[$setting->getPriority()])) {
|
|
|
|
$settings[$setting->getPriority()] = [];
|
2016-08-09 00:31:26 +03:00
|
|
|
}
|
2018-01-29 15:14:56 +03:00
|
|
|
$settings[$setting->getPriority()][] = $setting;
|
2016-08-09 00:31:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
ksort($settings);
|
|
|
|
return $settings;
|
|
|
|
}
|
2017-05-16 02:40:36 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2018-01-29 15:14:56 +03:00
|
|
|
public function getPersonalSections(): array {
|
2017-05-16 02:40:36 +03:00
|
|
|
$sections = [
|
|
|
|
0 => [new Section('personal-info', $this->l->t('Personal info'), 0, $this->url->imagePath('core', 'actions/info.svg'))],
|
2017-06-16 16:34:16 +03:00
|
|
|
5 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('settings', 'password.svg'))],
|
2018-05-24 16:06:28 +03:00
|
|
|
15 => [new Section('sync-clients', $this->l->t('Mobile & desktop'), 0, $this->url->imagePath('core', 'clients/phone.svg'))],
|
2017-05-16 02:40:36 +03:00
|
|
|
];
|
2017-05-19 18:34:57 +03:00
|
|
|
|
2017-06-22 16:19:01 +03:00
|
|
|
$legacyForms = \OC_App::getForms('personal');
|
2018-01-29 15:14:56 +03:00
|
|
|
if(!empty($legacyForms) && $this->hasLegacyPersonalSettingsToRender($legacyForms)) {
|
2017-06-22 16:19:01 +03:00
|
|
|
$sections[98] = [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))];
|
|
|
|
}
|
|
|
|
|
2018-01-29 15:14:56 +03:00
|
|
|
$appSections = $this->getSections('personal');
|
2017-05-19 18:34:57 +03:00
|
|
|
|
2018-01-29 15:14:56 +03:00
|
|
|
foreach ($appSections as $section) {
|
|
|
|
/** @var ISection $section */
|
|
|
|
if (!isset($sections[$section->getPriority()])) {
|
|
|
|
$sections[$section->getPriority()] = [];
|
2017-05-19 18:34:57 +03:00
|
|
|
}
|
2018-01-29 15:14:56 +03:00
|
|
|
|
|
|
|
$sections[$section->getPriority()][] = $section;
|
2017-05-19 18:34:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
ksort($sections);
|
|
|
|
|
2017-05-16 02:40:36 +03:00
|
|
|
return $sections;
|
|
|
|
}
|
|
|
|
|
2017-06-22 16:19:01 +03:00
|
|
|
/**
|
2018-01-29 15:14:56 +03:00
|
|
|
* @param string[] $forms
|
2017-06-22 16:19:01 +03:00
|
|
|
* @return bool
|
|
|
|
*/
|
2018-01-29 15:14:56 +03:00
|
|
|
private function hasLegacyPersonalSettingsToRender(array $forms): bool {
|
2017-06-22 16:19:01 +03:00
|
|
|
foreach ($forms as $form) {
|
|
|
|
if(trim($form) !== '') {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-05-16 02:40:36 +03:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2018-01-29 15:14:56 +03:00
|
|
|
public function getPersonalSettings($section): array {
|
2017-05-16 02:40:36 +03:00
|
|
|
$settings = $this->getBuiltInPersonalSettings($section);
|
2018-01-29 15:14:56 +03:00
|
|
|
$appSettings = $this->getSettings('personal', $section);
|
2017-05-19 18:34:57 +03:00
|
|
|
|
2018-01-29 15:14:56 +03:00
|
|
|
foreach ($appSettings as $setting) {
|
|
|
|
if (!isset($settings[$setting->getPriority()])) {
|
|
|
|
$settings[$setting->getPriority()] = [];
|
2017-05-19 18:34:57 +03:00
|
|
|
}
|
2018-01-29 15:14:56 +03:00
|
|
|
$settings[$setting->getPriority()][] = $setting;
|
2017-05-19 18:34:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
ksort($settings);
|
2017-05-16 02:40:36 +03:00
|
|
|
return $settings;
|
|
|
|
}
|
2016-08-09 00:31:26 +03:00
|
|
|
}
|