Completed
Pull Request — master (#451)
by Maxence
02:07
created

SettingsController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 60
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getSettings() 0 18 1
A setSettings() 0 18 1
1
<?php
2
3
namespace OCA\Circles\Controller;
4
5
use OCA\Circles\Service\ConfigService;
6
use OCA\Circles\Service\MiscService;
7
use OCP\AppFramework\Controller;
8
use OCP\IRequest;
9
10
11
class SettingsController extends Controller {
12
13
	/** @var ConfigService */
14
	private $configService;
15
16
	/** @var MiscService */
17
	private $miscService;
18
19
	public function __construct(
20
		$appName, IRequest $request, ConfigService $configService, MiscService $miscService
21
	) {
22
		parent::__construct($appName, $request);
23
		$this->configService = $configService;
24
		$this->miscService = $miscService;
25
	}
26
27
28
	/**
29
	 * @NoCSRFRequired
30
	 */
31
	public function getSettings() {
32
		$params = [
33
			'membersLimit'          => $this->configService->getAppValue(
34
				ConfigService::CIRCLES_MEMBERS_LIMIT
35
			),
36
			'allowLinkedGroups'     => $this->configService->getAppValue(
37
				ConfigService::CIRCLES_ALLOW_LINKED_GROUPS
38
			),
39
			'allowFederatedCircles' => $this->configService->getAppValue(
40
				ConfigService::CIRCLES_ALLOW_FEDERATED_CIRCLES
41
			),
42
			'skipInvitationStep'    => $this->configService->getAppValue(
43
				ConfigService::CIRCLES_SKIP_INVITATION_STEP
44
			)
45
		];
46
47
		return $params;
48
	}
49
50
51
	public function setSettings(
52
		$members_limit, $allow_linked_groups, $allow_federated_circles, $skip_invitation_to_closed_circles
53
	) {
54
		$this->configService->setAppValue(
55
			ConfigService::CIRCLES_MEMBERS_LIMIT, $members_limit
56
		);
57
		$this->configService->setAppValue(
58
			ConfigService::CIRCLES_ALLOW_LINKED_GROUPS, $allow_linked_groups
59
		);
60
		$this->configService->setAppValue(
61
			ConfigService::CIRCLES_ALLOW_FEDERATED_CIRCLES, $allow_federated_circles
62
		);
63
		$this->configService->setAppValue(
64
			ConfigService::CIRCLES_SKIP_INVITATION_STEP, $skip_invitation_to_closed_circles
65
		);
66
67
		return $this->getSettings();
68
	}
69
70
}
71