|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @copyright Copyright (c) 2018 Matthias Held <[email protected]> |
|
5
|
|
|
* @author Matthias Held <[email protected]> |
|
6
|
|
|
* @license GNU AGPL version 3 or any later version |
|
7
|
|
|
* |
|
8
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
9
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
10
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
11
|
|
|
* License, or (at your option) any later version. |
|
12
|
|
|
* |
|
13
|
|
|
* This program is distributed in the hope that it will be useful, |
|
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16
|
|
|
* GNU Affero General Public License for more details. |
|
17
|
|
|
* |
|
18
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
19
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
namespace OCA\RansomwareDetection\Controller; |
|
23
|
|
|
|
|
24
|
|
|
use OCA\RansomwareDetection\AppInfo\Application; |
|
25
|
|
|
use OCA\RansomwareDetection\Model\Settings; |
|
26
|
|
|
use OCP\AppFramework\Http; |
|
|
|
|
|
|
27
|
|
|
use OCP\AppFramework\Http\JSONResponse; |
|
|
|
|
|
|
28
|
|
|
use OCP\AppFramework\Controller; |
|
|
|
|
|
|
29
|
|
|
use OCP\IConfig; |
|
|
|
|
|
|
30
|
|
|
use OCP\IUserSession; |
|
|
|
|
|
|
31
|
|
|
use OCP\IRequest; |
|
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
class SettingsController extends Controller |
|
34
|
|
|
{ |
|
35
|
|
|
/** @var IConfig */ |
|
36
|
|
|
protected $config; |
|
37
|
|
|
|
|
38
|
|
|
/** @var IUserSession */ |
|
39
|
|
|
protected $userSession; |
|
40
|
|
|
|
|
41
|
|
|
/** @var int */ |
|
42
|
|
|
private $userId; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @param string $appName |
|
46
|
|
|
* @param IRequest $request |
|
47
|
|
|
* @param IUserSession $userSession |
|
48
|
|
|
* @param IConfig $config |
|
49
|
|
|
* @param string $userId |
|
50
|
|
|
*/ |
|
51
|
|
|
public function __construct( |
|
52
|
|
|
$appName, |
|
53
|
|
|
IRequest $request, |
|
54
|
|
|
IUserSession $userSession, |
|
55
|
|
|
IConfig $config, |
|
56
|
|
|
$userId |
|
57
|
|
|
) { |
|
58
|
|
|
parent::__construct($appName, $request); |
|
59
|
|
|
|
|
60
|
|
|
$this->config = $config; |
|
61
|
|
|
$this->userSession = $userSession; |
|
62
|
|
|
$this->userId = $userId; |
|
|
|
|
|
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Get settings. |
|
67
|
|
|
* |
|
68
|
|
|
* @NoCSRFRequired |
|
69
|
|
|
* @NoAdminRequired |
|
70
|
|
|
* |
|
71
|
|
|
* @return JSONResponse |
|
72
|
|
|
*/ |
|
73
|
|
|
public function findAll() { |
|
74
|
|
|
$debug = $this->config->getAppValue(Application::APP_ID, 'debug', 0); |
|
75
|
|
|
$color = $this->config->getUserValue($this->userId, Application::APP_ID, 'color_mode', 0); |
|
76
|
|
|
$settings = new Settings($debug, $color); |
|
77
|
|
|
|
|
78
|
|
|
return new JSONResponse($settings, Http::STATUS_OK); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Set settings. |
|
83
|
|
|
* |
|
84
|
|
|
* @NoCSRFRequired |
|
85
|
|
|
* @NoAdminRequired |
|
86
|
|
|
* |
|
87
|
|
|
* @return JSONResponse |
|
88
|
|
|
*/ |
|
89
|
|
|
public function update($color, $debug) { |
|
90
|
|
|
$this->config->setUserValue($this->userId, Application::APP_ID, 'color_mode', $color); |
|
91
|
|
|
|
|
92
|
|
|
return new JSONResponse(null, Http::STATUS_OK); |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths