|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* @copyright Copyright (c) 2020, Roeland Jago Douma <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* @author Roeland Jago Douma <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* @license GNU AGPL version 3 or any later version |
|
11
|
|
|
* |
|
12
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
13
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
14
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
15
|
|
|
* License, or (at your option) any later version. |
|
16
|
|
|
* |
|
17
|
|
|
* This program is distributed in the hope that it will be useful, |
|
18
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20
|
|
|
* GNU Affero General Public License for more details. |
|
21
|
|
|
* |
|
22
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
23
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
24
|
|
|
* |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
namespace OCA\Accessibility\Service; |
|
28
|
|
|
|
|
29
|
|
|
use OCA\Accessibility\AppInfo\Application; |
|
30
|
|
|
use OCP\AppFramework\Services\InitialStateProvider; |
|
31
|
|
|
use OCP\IConfig; |
|
32
|
|
|
use OCP\IUserSession; |
|
33
|
|
|
|
|
34
|
|
|
class JSDataService extends InitialStateProvider { |
|
35
|
|
|
/** @var IUserSession */ |
|
36
|
|
|
private $userSession; |
|
37
|
|
|
/** @var IConfig */ |
|
38
|
|
|
private $config; |
|
39
|
|
|
|
|
40
|
|
|
public function __construct( |
|
41
|
|
|
IUserSession $userSession, |
|
42
|
|
|
IConfig $config |
|
43
|
|
|
) { |
|
44
|
|
|
$this->userSession = $userSession; |
|
45
|
|
|
$this->config = $config; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function getKey(): string { |
|
49
|
|
|
return 'data'; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function getData() { |
|
53
|
|
|
$user = $this->userSession->getUser(); |
|
54
|
|
|
|
|
55
|
|
|
if ($user === null) { |
|
56
|
|
|
$theme = false; |
|
57
|
|
|
$highcontrast = false; |
|
58
|
|
|
} else { |
|
59
|
|
|
$theme = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'theme', false); |
|
60
|
|
|
$highcontrast = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'highcontrast', false) !== false; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
return [ |
|
64
|
|
|
'theme' => $theme, |
|
65
|
|
|
'highcontrast' => $highcontrast, |
|
66
|
|
|
]; |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|