Admin   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 42
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getForm() 0 10 1
A getSection() 0 3 1
A getPriority() 0 3 1
1
<?php
2
declare(strict_types=1);
3
/**
4
 * @copyright Copyright (c) 2016 Joas Schilling <[email protected]>
5
 *
6
 * @author Joas Schilling <[email protected]>
7
 *
8
 * @license GNU AGPL version 3 or any later version
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU Affero General Public License as
12
 * published by the Free Software Foundation, either version 3 of the
13
 * License, or (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU Affero General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU Affero General Public License
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 *
23
 */
24
25
namespace OCA\AnnouncementCenter\Settings;
26
27
use OCP\AppFramework\Http\TemplateResponse;
28
use OCP\IConfig;
29
use OCP\Settings\ISettings;
30
31
class Admin implements ISettings {
32
33
	/** @var IConfig */
34
	protected $config;
35
36 8
	public function __construct(IConfig $config) {
37 8
		$this->config = $config;
38 8
	}
39
40
	/**
41
	 * @return TemplateResponse
42
	 */
43 5
	public function getForm(): TemplateResponse {
44 5
		$adminGroups = $this->config->getAppValue('announcementcenter', 'admin_groups', '["admin"]');
45 5
		$adminGroups = implode('|', json_decode($adminGroups, true));
46 5
		return new TemplateResponse('announcementcenter', 'admin', [
47 5
			'adminGroups' => $adminGroups,
48 5
			'createActivities' => $this->config->getAppValue('announcementcenter', 'create_activities', 'yes') === 'yes',
49 5
			'createNotifications' => $this->config->getAppValue('announcementcenter', 'create_notifications', 'yes') === 'yes',
50 5
			'allowComments' => $this->config->getAppValue('announcementcenter', 'allow_comments', 'yes') === 'yes',
51 5
		], 'blank');
52
	}
53
54
	/**
55
	 * @return string the section ID, e.g. 'sharing'
56
	 */
57 1
	public function getSection(): string {
58 1
		return 'additional';
59
	}
60
61
	/**
62
	 * @return int whether the form should be rather on the top or bottom of
63
	 * the admin section. The forms are arranged in ascending order of the
64
	 * priority values. It is required to return a value between 0 and 100.
65
	 *
66
	 * E.g.: 70
67
	 */
68 1
	public function getPriority(): int {
69 1
		return 55;
70
	}
71
72
}
73