1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @copyright Copyright (c) 2018 Ryan Fletcher <[email protected]> |
4
|
|
|
* |
5
|
|
|
* @copyright Copyright (c) 2019, Alexandru Puiu ([email protected]) |
6
|
|
|
* |
7
|
|
|
* @author Ryan Fletcher <[email protected]> |
8
|
|
|
* |
9
|
|
|
* @license GNU AGPL version 3 or any later version |
10
|
|
|
* |
11
|
|
|
* This program is free software: you can redistribute it and/or modify |
12
|
|
|
* it under the terms of the GNU Affero General Public License as |
13
|
|
|
* published by the Free Software Foundation, either version 3 of the |
14
|
|
|
* License, or (at your option) any later version. |
15
|
|
|
* |
16
|
|
|
* This program is distributed in the hope that it will be useful, |
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19
|
|
|
* GNU Affero General Public License for more details. |
20
|
|
|
* |
21
|
|
|
* You should have received a copy of the GNU Affero General Public License |
22
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
23
|
|
|
* |
24
|
|
|
*/ |
25
|
|
|
|
26
|
|
|
namespace OCA\Deck\Controller; |
27
|
|
|
|
28
|
|
|
use OCP\AppFramework\ApiController; |
29
|
|
|
use OCP\AppFramework\Http; |
30
|
|
|
use OCP\AppFramework\Http\DataResponse; |
31
|
|
|
use OCP\IRequest; |
32
|
|
|
use OCA\Deck\Service\CardService; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Class BoardApiController |
36
|
|
|
* |
37
|
|
|
* @package OCA\Deck\Controller |
38
|
|
|
*/ |
39
|
|
|
class CardApiController extends ApiController { |
40
|
|
|
private $cardService; |
41
|
|
|
private $userId; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @param string $appName |
45
|
|
|
* @param IRequest $request |
46
|
|
|
* @param CardService $cardService |
47
|
|
|
* @param $userId |
48
|
|
|
*/ |
49
|
|
|
public function __construct($appName, IRequest $request, CardService $cardService, $userId) { |
50
|
|
|
parent::__construct($appName, $request); |
51
|
|
|
$this->cardService = $cardService; |
52
|
|
|
$this->userId = $userId; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @NoAdminRequired |
57
|
|
|
* @CORS |
58
|
|
|
* @NoCSRFRequired |
59
|
|
|
* |
60
|
|
|
* Get a specific card. |
61
|
|
|
*/ |
62
|
|
|
public function get() { |
63
|
|
|
$card = $this->cardService->find($this->request->getParam('cardId')); |
64
|
|
|
return new DataResponse($card, HTTP::STATUS_OK); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @NoAdminRequired |
69
|
|
|
* @CORS |
70
|
|
|
* @NoCSRFRequired |
71
|
|
|
* |
72
|
|
|
* @params $title |
73
|
|
|
* @params $type |
74
|
|
|
* @params $order |
75
|
|
|
* @params $description |
76
|
|
|
* |
77
|
|
|
* Get a specific card. |
78
|
|
|
*/ |
79
|
|
|
public function create($title, $type = 'plain', $order = 999, $description = '') { |
80
|
|
|
$card = $this->cardService->create($title, $this->request->getParam('stackId'), $type, $order, $this->userId, $description); |
81
|
|
|
return new DataResponse($card, HTTP::STATUS_OK); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @NoAdminRequired |
86
|
|
|
* @CORS |
87
|
|
|
* @NoCSRFRequired |
88
|
|
|
* |
89
|
|
|
* |
90
|
|
|
* Update a card |
91
|
|
|
*/ |
92
|
|
|
public function update($title, $type, $order = 0, $description = '', $owner, $duedate = null, $archived = null) { |
93
|
|
|
$card = $this->cardService->update($this->request->getParam('cardId'), $title, $this->request->getParam('stackId'), $type, $order, $description, $owner, $duedate, 0, $archived); |
94
|
|
|
return new DataResponse($card, HTTP::STATUS_OK); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @NoAdminRequired |
99
|
|
|
* @CORS |
100
|
|
|
* @NoCSRFRequired |
101
|
|
|
* |
102
|
|
|
* Delete a specific card. |
103
|
|
|
*/ |
104
|
|
|
public function delete() { |
105
|
|
|
$card = $this->cardService->delete($this->request->getParam('cardId')); |
106
|
|
|
return new DataResponse($card, HTTP::STATUS_OK); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @NoAdminRequired |
111
|
|
|
* @CORS |
112
|
|
|
* @NoCSRFRequired |
113
|
|
|
* |
114
|
|
|
* Assign a label to a card. |
115
|
|
|
*/ |
116
|
|
|
public function assignLabel($labelId) { |
117
|
|
|
$card = $this->cardService->assignLabel($this->request->getParam('cardId'), $labelId); |
|
|
|
|
118
|
|
|
return new DataResponse($card, HTTP::STATUS_OK); |
|
|
|
|
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @NoAdminRequired |
123
|
|
|
* @CORS |
124
|
|
|
* @NoCSRFRequired |
125
|
|
|
* |
126
|
|
|
* Assign a label to a card. |
127
|
|
|
*/ |
128
|
|
|
public function removeLabel($labelId) { |
129
|
|
|
$card = $this->cardService->removeLabel($this->request->getParam('cardId'), $labelId); |
|
|
|
|
130
|
|
|
return new DataResponse($card, HTTP::STATUS_OK); |
|
|
|
|
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @NoAdminRequired |
135
|
|
|
* @CORS |
136
|
|
|
* @NoCSRFRequired |
137
|
|
|
* |
138
|
|
|
* Unassign a user from a card |
139
|
|
|
*/ |
140
|
|
|
public function unassignUser($userId) { |
141
|
|
|
$card = $this->cardService->unassignUser($this->request->getParam('cardId'), $userId); |
142
|
|
|
return new DataResponse($card, HTTP::STATUS_OK); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @NoAdminRequired |
147
|
|
|
* @CORS |
148
|
|
|
* @NoCSRFRequired |
149
|
|
|
* |
150
|
|
|
* Assign a user to a card |
151
|
|
|
*/ |
152
|
|
|
public function assignUser($userId) { |
153
|
|
|
$card = $this->cardService->assignUser($this->request->getParam('cardId'), $userId);; |
154
|
|
|
return new DataResponse($card, HTTP::STATUS_OK); |
|
|
|
|
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* @NoAdminRequired |
159
|
|
|
* @CORS |
160
|
|
|
* @NoCSRFRequired |
161
|
|
|
* |
162
|
|
|
* Reorder cards |
163
|
|
|
*/ |
164
|
|
|
public function reorder($stackId, $order) { |
165
|
|
|
$card = $this->cardService->reorder($this->request->getParam('cardId'), $stackId, $order); |
166
|
|
|
return new DataResponse($card, HTTP::STATUS_OK); |
167
|
|
|
} |
168
|
|
|
} |
169
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.