-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathSystemController.php
More file actions
65 lines (59 loc) · 1.82 KB
/
Copy pathSystemController.php
File metadata and controls
65 lines (59 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2017 Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Polls\Controller;
use OCA\Polls\Service\SystemService;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\OpenAPI;
use OCP\AppFramework\Http\JSONResponse;
use OCP\IRequest;
/**
* @psalm-api
*/
class SystemController extends BaseController {
public function __construct(
string $appName,
IRequest $request,
private SystemService $systemService,
) {
parent::__construct($appName, $request);
}
/**
* Get a combined list of NC users, groups and contacts
* @param string $query Search string
*/
#[NoAdminRequired]
#[OpenAPI(OpenAPI::SCOPE_IGNORE)]
#[FrontpageRoute(verb: 'GET', url: '/search/users/{query}')]
public function userSearch(string $query, string $types): JSONResponse {
$types = array_map('intval', explode(',', $types));
// $types = explode(',', $types);
return new JSONResponse([
'siteusers' => $this->systemService->getSiteUsersAndGroups($query, $types),
'types' => $types
], Http::STATUS_OK);
}
/**
* Get a combined list of all NC groups
*/
#[OpenAPI(OpenAPI::SCOPE_IGNORE)]
#[FrontpageRoute(verb: 'GET', url: '/groups')]
public function groupAll(): JSONResponse {
return new JSONResponse(['groups' => $this->systemService->getGroups()], Http::STATUS_OK);
}
/**
* Get a combined list of NC groups matching $query
* @param string $query Search string
*/
#[OpenAPI(OpenAPI::SCOPE_IGNORE)]
#[FrontpageRoute(verb: 'GET', url: '/groups/{query}')]
public function groupSearch(string $query = ''): JSONResponse {
return new JSONResponse(['groups' => $this->systemService->getGroups(
$query)], Http::STATUS_OK);
}
}