Passed
Pull Request — master (#1272)
by René
03:46
created

SystemController::validateEmailAddress()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 5
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
1
<?php
2
/**
3
 * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <[email protected]>
4
 *
5
 * @author René Gieling <[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\Polls\Controller;
25
26
use OCP\AppFramework\Controller;
27
use OCP\AppFramework\Http;
28
use OCP\AppFramework\Http\DataResponse;
29
use OCA\Polls\Service\SystemService;
30
31
use OCP\IRequest;
32
33
class SystemController extends Controller {
34
35
	/** @var SystemService */
36
	private $systemService;
37
38
	/**
39
	 * SystemController constructor.
40
	 * @param string $appName
41
	 * @param IRequest $request
42
	 * @param SystemService $systemService
43
	 */
44
45
	public function __construct(
46
		string $appName,
47
		IRequest $request,
48
		SystemService $systemService
49
	) {
50
		parent::__construct($appName, $request);
51
		$this->systemService = $systemService;
52
	}
53
54
	/**
55
	 * Get a combined list of NC users, groups and contacts
56
	 * @NoAdminRequired
57
	 * @param string $query
58
	 * @param bool $getGroups - search in groups
59
	 * @param bool $getUsers - search in site users
60
	 * @param bool $getContacts - search in contacs
61
	 * @param bool $getContactGroups - search in contacs
62
	 * @param array $skipGroups - group names to skip in return array
63
	 * @param array $skipUsers - user names to skip in return array
64
	 * @return DataResponse
65
	 */
66
	public function getSiteUsersAndGroups(
67
		$query = '',
68
		$getGroups = true,
69
		$getUsers = true,
70
		$getContacts = true,
71
		$getContactGroups = true,
72
		$getMail = false,
73
		$skipGroups = [],
74
		$skipUsers = []
75
	) {
76
		return new DataResponse(['siteusers' => $this->systemService->getSiteUsersAndGroups(
77
			$query, $getGroups, $getUsers, $getContacts, $getContactGroups, $getMail, $skipGroups, $skipUsers)], Http::STATUS_OK);
78
	}
79
}
80