Completed
Push — master ( 586935...49b771 )
by Joas
14:13 queued 03:42
created

AdminController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 2
c 3
b 0
f 2
lcom 1
cbo 0
dl 0
loc 31
ccs 0
cts 15
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A index() 0 9 1
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016, Joas Schilling <[email protected]>
4
 *
5
 * @author Joas Schilling <[email protected]>
6
 *
7
 * @license GNU AGPL version 3 or any later version
8
 *
9
 * This program is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License as
11
 * published by the Free Software Foundation, either version 3 of the
12
 * License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU Affero General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Affero General Public License
20
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 */
23
24
namespace OCA\AnnouncementCenter\Controller;
25
26
use OCP\AppFramework\Controller;
27
use OCP\AppFramework\Http\TemplateResponse;
28
use OCP\IConfig;
29
use OCP\IRequest;
30
31
class AdminController extends Controller {
32
33
	/** @var IConfig */
34
	protected $config;
35
36
	/**
37
	 * @param string $appName
38
	 * @param IRequest $request
39
	 * @param IConfig $config
40
	 */
41
	public function __construct($appName,
42
								IRequest $request,
43
								IConfig $config) {
44
		parent::__construct($appName, $request);
45
46
		$this->config = $config;
47
	}
48
49
	/**
50
	 * @return TemplateResponse
51
	 */
52
	public function index() {
53
		$adminGroups = $this->config->getAppValue('announcementcenter', 'admin_groups', '["admin"]');
54
		$adminGroups = implode('|', json_decode($adminGroups, true));
55
		return new TemplateResponse('announcementcenter', 'admin', [
56
			'adminGroups' => $adminGroups,
57
			'createActivities' => $this->config->getAppValue('announcementcenter', 'create_activities', 'yes') === 'yes',
58
			'createNotifications' => $this->config->getAppValue('announcementcenter', 'create_notifications', 'yes') === 'yes',
59
		], 'blank');
60
	}
61
}
62