Skip to content

Commit b545639

Browse files
authored
Merge pull request #1545 from nextcloud/enh/dav-calendars
2 parents cc788da + e460879 commit b545639

19 files changed

Lines changed: 832 additions & 146 deletions

appinfo/info.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,9 @@
6464
<provider>OCA\Deck\Activity\DeckProvider</provider>
6565
</providers>
6666
</activity>
67-
6867
<fulltextsearch>
6968
<provider min-version="16">OCA\Deck\Provider\DeckProvider</provider>
7069
</fulltextsearch>
71-
7270
<navigations>
7371
<navigation>
7472
<name>Deck</name>
@@ -77,5 +75,9 @@
7775
<order>10</order>
7876
</navigation>
7977
</navigations>
80-
78+
<sabre>
79+
<calendar-plugins>
80+
<plugin>OCA\Deck\DAV\CalendarPlugin</plugin>
81+
</calendar-plugins>
82+
</sabre>
8183
</info>

appinfo/routes.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
'routes' => [
2727
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
2828

29-
['name' => 'Config#get', 'url' => '/config', 'verb' => 'GET'],
30-
['name' => 'Config#setValue', 'url' => '/config/{key}', 'verb' => 'POST'],
31-
3229
// boards
3330
['name' => 'board#index', 'url' => '/boards', 'verb' => 'GET'],
3431
['name' => 'board#create', 'url' => '/boards', 'verb' => 'POST'],
@@ -125,17 +122,17 @@
125122
['name' => 'attachment_api#delete', 'url' => '/api/v1.0/boards/{boardId}/stacks/{stackId}/cards/{cardId}/attachments/{attachmentId}', 'verb' => 'DELETE'],
126123
['name' => 'attachment_api#restore', 'url' => '/api/v1.0/boards/{boardId}/stacks/{stackId}/cards/{cardId}/attachments/{attachmentId}/restore', 'verb' => 'PUT'],
127124

128-
129-
130125
['name' => 'board_api#preflighted_cors', 'url' => '/api/v1.0/{path}','verb' => 'OPTIONS', 'requirements' => ['path' => '.+']],
131126
],
132127
'ocs' => [
128+
['name' => 'Config#get', 'url' => '/api/v1.0/config', 'verb' => 'GET'],
129+
['name' => 'Config#setValue', 'url' => '/api/v1.0/config/{key}', 'verb' => 'POST'],
130+
133131
['name' => 'comments_api#list', 'url' => '/api/v1.0/cards/{cardId}/comments', 'verb' => 'GET'],
134132
['name' => 'comments_api#create', 'url' => '/api/v1.0/cards/{cardId}/comments', 'verb' => 'POST'],
135133
['name' => 'comments_api#update', 'url' => '/api/v1.0/cards/{cardId}/comments/{commentId}', 'verb' => 'PUT'],
136134
['name' => 'comments_api#delete', 'url' => '/api/v1.0/cards/{cardId}/comments/{commentId}', 'verb' => 'DELETE'],
137135

138-
// dashboard
139136
['name' => 'overview_api#upcomingCards', 'url' => '/api/v1.0/overview/upcoming', 'verb' => 'GET'],
140137
]
141138
];

lib/Controller/ConfigController.php

Lines changed: 12 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -23,90 +23,42 @@
2323

2424
namespace OCA\Deck\Controller;
2525

26+
use OCA\Deck\Service\ConfigService;
2627
use OCP\AppFramework\Http\DataResponse;
2728
use OCP\AppFramework\Http\NotFoundResponse;
28-
use OCP\IConfig;
29-
use OCP\IGroup;
30-
use OCP\IGroupManager;
29+
use OCP\AppFramework\OCSController;
3130
use OCP\IRequest;
32-
use OCP\AppFramework\Controller;
3331

34-
class ConfigController extends Controller {
35-
private $config;
36-
private $userId;
37-
private $groupManager;
32+
class ConfigController extends OCSController {
33+
private $configService;
3834

3935
public function __construct(
4036
$AppName,
4137
IRequest $request,
42-
IConfig $config,
43-
IGroupManager $groupManager,
44-
$userId
38+
ConfigService $configService
4539
) {
4640
parent::__construct($AppName, $request);
4741

48-
$this->userId = $userId;
49-
$this->groupManager = $groupManager;
50-
$this->config = $config;
42+
$this->configService = $configService;
5143
}
5244

5345
/**
5446
* @NoCSRFRequired
47+
* @NoAdminRequired
5548
*/
56-
public function get() {
57-
$data = [
58-
'groupLimit' => $this->getGroupLimit(),
59-
];
60-
return new DataResponse($data);
49+
public function get(): DataResponse {
50+
return new DataResponse($this->configService->getAll());
6151
}
6252

6353
/**
6454
* @NoCSRFRequired
55+
* @NoAdminRequired
6556
*/
66-
public function setValue($key, $value) {
67-
switch ($key) {
68-
case 'groupLimit':
69-
$result = $this->setGroupLimit($value);
70-
break;
71-
}
57+
public function setValue(string $key, $value) {
58+
$result = $this->configService->set($key, $value);
7259
if ($result === null) {
7360
return new NotFoundResponse();
7461
}
7562
return new DataResponse($result);
7663
}
77-
78-
private function setGroupLimit($value) {
79-
$groups = [];
80-
foreach ($value as $group) {
81-
$groups[] = $group['id'];
82-
}
83-
$data = implode(',', $groups);
84-
$this->config->setAppValue($this->appName, 'groupLimit', $data);
85-
return $groups;
86-
}
87-
88-
private function getGroupLimitList() {
89-
$value = $this->config->getAppValue($this->appName, 'groupLimit', '');
90-
$groups = explode(',', $value);
91-
if ($value === '') {
92-
return [];
93-
}
94-
return $groups;
95-
}
96-
97-
private function getGroupLimit() {
98-
$groups = $this->getGroupLimitList();
99-
$groups = array_map(function ($groupId) {
100-
/** @var IGroup $groups */
101-
$group = $this->groupManager->get($groupId);
102-
if ($group === null) {
103-
return null;
104-
}
105-
return [
106-
'id' => $group->getGID(),
107-
'displayname' => $group->getDisplayName(),
108-
];
109-
}, $groups);
110-
return array_filter($groups);
111-
}
11264
}

lib/Controller/PageController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,33 @@
2424
namespace OCA\Deck\Controller;
2525

2626
use OCA\Deck\AppInfo\Application;
27+
use OCA\Deck\Service\ConfigService;
2728
use OCA\Deck\Service\PermissionService;
2829
use OCP\AppFramework\Http\ContentSecurityPolicy;
2930
use OCP\IInitialStateService;
3031
use OCP\IRequest;
3132
use OCP\AppFramework\Http\TemplateResponse;
3233
use OCP\AppFramework\Controller;
33-
use OCP\IL10N;
3434

3535
class PageController extends Controller {
3636
private $permissionService;
3737
private $userId;
3838
private $l10n;
3939
private $initialState;
40+
private $configService;
4041

4142
public function __construct(
4243
$AppName,
4344
IRequest $request,
4445
PermissionService $permissionService,
4546
IInitialStateService $initialStateService,
46-
IL10N $l10n,
47-
$userId
47+
ConfigService $configService
4848
) {
4949
parent::__construct($AppName, $request);
5050

51-
$this->userId = $userId;
5251
$this->permissionService = $permissionService;
5352
$this->initialState = $initialStateService;
54-
$this->l10n = $l10n;
53+
$this->configService = $configService;
5554
}
5655

5756
/**
@@ -64,6 +63,7 @@ public function __construct(
6463
public function index() {
6564
$this->initialState->provideInitialState(Application::APP_ID, 'maxUploadSize', (int)\OCP\Util::uploadLimit());
6665
$this->initialState->provideInitialState(Application::APP_ID, 'canCreate', $this->permissionService->canCreate());
66+
$this->initialState->provideInitialState(Application::APP_ID, 'config', $this->configService->getAll());
6767

6868
$response = new TemplateResponse('deck', 'main');
6969

0 commit comments

Comments
 (0)