2020-04-09 09:55:45 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @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\SideMenu\Settings;
|
|
|
|
|
2020-09-24 14:26:25 +02:00
|
|
|
use OCA\SideMenu\AppInfo\Application;
|
|
|
|
use OCA\SideMenu\Service\AppRepository;
|
|
|
|
use OCA\SideMenu\Service\ConfigProxy;
|
2020-05-11 22:51:27 +02:00
|
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
2020-04-09 09:55:45 +02:00
|
|
|
use OCP\IL10N;
|
2020-05-11 22:51:27 +02:00
|
|
|
use OCP\ILogger;
|
|
|
|
use OCP\IUserSession;
|
2020-09-24 14:26:25 +02:00
|
|
|
use OCP\Settings\ISettings;
|
2020-04-09 09:55:45 +02:00
|
|
|
|
2020-05-11 22:51:27 +02:00
|
|
|
class Personal implements ISettings
|
2020-04-09 09:55:45 +02:00
|
|
|
{
|
2020-05-11 22:51:27 +02:00
|
|
|
/**
|
|
|
|
* @var IL10N
|
|
|
|
*/
|
2020-04-09 09:55:45 +02:00
|
|
|
private $l;
|
|
|
|
|
2020-05-11 22:51:27 +02:00
|
|
|
/**
|
|
|
|
* @var ILogger
|
|
|
|
*/
|
|
|
|
private $logger;
|
|
|
|
|
|
|
|
/**
|
2020-09-24 14:26:25 +02:00
|
|
|
* @var ConfigProxy
|
2020-05-11 22:51:27 +02:00
|
|
|
*/
|
|
|
|
private $config;
|
2020-04-09 09:55:45 +02:00
|
|
|
|
|
|
|
/**
|
2020-05-11 22:51:27 +02:00
|
|
|
* @var IUserSession
|
2020-04-09 09:55:45 +02:00
|
|
|
*/
|
2020-05-11 22:51:27 +02:00
|
|
|
private $userSession;
|
|
|
|
|
2020-08-12 15:59:51 +02:00
|
|
|
/**
|
|
|
|
* @var AppRepository
|
|
|
|
*/
|
|
|
|
private $appRepository;
|
|
|
|
|
2020-09-24 14:26:25 +02:00
|
|
|
public function __construct(IL10N $l, ILogger $logger, ConfigProxy $config, IUserSession $userSession, AppRepository $appRepository)
|
2020-04-09 09:55:45 +02:00
|
|
|
{
|
|
|
|
$this->l = $l;
|
2020-05-11 22:51:27 +02:00
|
|
|
$this->logger = $logger;
|
|
|
|
$this->config = $config;
|
|
|
|
$this->userSession = $userSession;
|
2020-08-12 15:59:51 +02:00
|
|
|
$this->appRepository = $appRepository;
|
2020-04-09 09:55:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-05-11 22:51:27 +02:00
|
|
|
* @return TemplateResponse
|
2020-04-09 09:55:45 +02:00
|
|
|
*/
|
2020-05-11 22:51:27 +02:00
|
|
|
public function getForm()
|
2020-04-09 09:55:45 +02:00
|
|
|
{
|
2020-05-11 22:51:27 +02:00
|
|
|
$user = $this->userSession->getUser();
|
|
|
|
|
|
|
|
$parameters = [
|
2020-09-24 14:26:25 +02:00
|
|
|
'force' => $this->config->getAppValueBool('force', '0'),
|
2020-10-19 13:44:07 +02:00
|
|
|
'enabled' => $this->config->getUserValue(
|
|
|
|
$user,
|
|
|
|
'enabled',
|
|
|
|
$this->config->getAppValue('default-enabled', '1')
|
|
|
|
),
|
2020-09-24 14:26:25 +02:00
|
|
|
'top-menu-apps' => $this->config->getUserValueArray($user, 'top-menu-apps', '[]'),
|
2022-01-12 12:40:17 +01:00
|
|
|
'top-side-menu-apps' => $this->config->getUserValueArray($user, 'top-side-menu-apps', '[]'),
|
2020-09-24 14:26:25 +02:00
|
|
|
'target-blank-mode' => $this->config->getUserValue($user, 'target-blank-mode', '1'),
|
|
|
|
'target-blank-apps' => $this->config->getUserValueArray($user, 'target-blank-apps', '[]'),
|
2020-08-12 15:59:51 +02:00
|
|
|
'apps' => $this->appRepository->getVisibleApps(),
|
2020-05-11 22:51:27 +02:00
|
|
|
];
|
|
|
|
|
2020-09-21 11:28:55 +02:00
|
|
|
return new TemplateResponse(Application::APP_ID, 'settings/personal-form', $parameters, '');
|
2020-04-09 09:55:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-05-11 22:51:27 +02:00
|
|
|
* @return string the section ID, e.g. 'sharing'
|
2020-04-09 09:55:45 +02:00
|
|
|
*/
|
2020-05-11 22:51:27 +02:00
|
|
|
public function getSection()
|
2020-04-09 09:55:45 +02:00
|
|
|
{
|
2020-09-21 11:28:55 +02:00
|
|
|
return Application::APP_ID;
|
2020-04-09 09:55:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return int whether the form should be rather on the top or bottom of
|
2020-09-24 14:26:25 +02:00
|
|
|
* 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.
|
2020-04-09 09:55:45 +02:00
|
|
|
*
|
|
|
|
* E.g.: 70
|
|
|
|
*/
|
|
|
|
public function getPriority()
|
|
|
|
{
|
|
|
|
return 70;
|
|
|
|
}
|
|
|
|
}
|