Issues (195)

lib/Settings/Personal.php (3 issues)

Labels
Severity
1
<?php
2
3
/**
4
 * @copyright Copyright (c) 2017 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\Settings;
23
24
use OCP\Settings\ISettings;
0 ignored issues
show
The type OCP\Settings\ISettings was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
25
use OCA\RansomwareDetection\AppInfo\Application;
26
use OCP\AppFramework\Http\TemplateResponse;
0 ignored issues
show
The type OCP\AppFramework\Http\TemplateResponse was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
27
use OCP\IConfig;
0 ignored issues
show
The type OCP\IConfig was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
28
29
class Personal implements ISettings
30
{
31
    /** @var IConfig */
32
    protected $config;
33
34
    /** @var string */
35
    protected $userId;
36
37
    /**
38
     * @param IConfig      $config
39
     * @param string       $userId
40
     */
41
    public function __construct(
42
        IConfig $config,
43
        $userId
44
    ) {
45
        $this->config = $config;
46
        $this->userId = $userId;
47
    }
48
49
    /**
50
     * @return TemplateResponse returns the instance with all parameters set, ready to be rendered
51
     *
52
     * @since 9.1
53
     */
54
    public function getForm()
55
    {
56
        $colorMode = $this->config->getUserValue($this->userId, Application::APP_ID, 'color_mode', 0);
57
58
        if (intval($colorMode) === 0) {
59
            $colorActive = ['code' => 0, 'name' => 'Normal'];
60
            $color = ['code' => 1, 'name' => 'Color blind'];
61
        } else {
62
            $colorActive = ['code' => 1, 'name' => 'Color blind'];
63
            $color = ['code' => 0, 'name' => 'Normal'];
64
        }
65
66
        return new TemplateResponse(Application::APP_ID, 'personal', [
67
            'color_active' => $colorActive,
68
            'color' => $color,
69
        ], '');
70
    }
71
72
    /**
73
     * @return string the section ID, e.g. 'ransomware_detection'
74
     *
75
     * @since 9.1
76
     */
77
    public function getSection()
78
    {
79
        return Application::APP_ID;
80
    }
81
82
    /**
83
     * @return int whether the form should be rather on the top or bottom of
84
     *             the admin section. The forms are arranged in ascending order of the
85
     *             priority values. It is required to return a value between 0 and 100.
86
     *
87
     * E.g.: 70
88
     *
89
     * @since 9.1
90
     */
91
    public function getPriority()
92
    {
93
        return 40;
94
    }
95
}
96