1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @copyright Copyright (c) 2016 Julius Härtl <[email protected]> |
4
|
|
|
* |
5
|
|
|
* @author Julius Härtl <[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\Deck\Controller; |
25
|
|
|
|
26
|
|
|
use OCA\Deck\Service\CardService; |
27
|
|
|
use OCP\IRequest; |
28
|
|
|
use OCP\AppFramework\Controller; |
29
|
|
|
|
30
|
|
|
class CardController extends Controller { |
31
|
|
|
|
32
|
|
|
private $userId; |
33
|
|
|
private $cardService; |
34
|
|
|
|
35
|
|
|
public function __construct($appName, IRequest $request, CardService $cardService, $userId) { |
36
|
|
|
parent::__construct($appName, $request); |
37
|
|
|
$this->userId = $userId; |
38
|
|
|
$this->cardService = $cardService; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @NoAdminRequired |
43
|
|
|
* @param $cardId |
44
|
|
|
* @return \OCP\AppFramework\Db\Entity |
45
|
|
|
*/ |
46
|
|
|
public function read($cardId) { |
47
|
|
|
return $this->cardService->find($cardId); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @NoAdminRequired |
52
|
|
|
* @param $cardId |
53
|
|
|
* @param $stackId |
54
|
|
|
* @param $order |
55
|
|
|
* @return array |
56
|
|
|
*/ |
57
|
|
|
public function reorder($cardId, $stackId, $order) { |
58
|
|
|
return $this->cardService->reorder((int)$cardId, (int)$stackId, (int)$order); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @NoAdminRequired |
63
|
|
|
* @param $cardId |
64
|
|
|
* @param $title |
65
|
|
|
* @return \OCP\AppFramework\Db\Entity |
66
|
|
|
*/ |
67
|
|
|
public function rename($cardId, $title) { |
68
|
|
|
return $this->cardService->rename($cardId, $title); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @NoAdminRequired |
73
|
|
|
* @param $title |
74
|
|
|
* @param $stackId |
75
|
|
|
* @param $type |
76
|
|
|
* @param int $order |
77
|
|
|
* @return \OCP\AppFramework\Db\Entity |
78
|
|
|
*/ |
79
|
|
|
public function create($title, $stackId, $type = 'plain', $order = 999) { |
80
|
|
|
return $this->cardService->create($title, $stackId, $type, $order, $this->userId); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @NoAdminRequired |
85
|
|
|
* @param $id |
86
|
|
|
* @param $title |
87
|
|
|
* @param $stackId |
88
|
|
|
* @param $type |
89
|
|
|
* @param $order |
90
|
|
|
* @param $description |
91
|
|
|
* @param $duedate |
92
|
|
|
* @param $deletedAt |
93
|
|
|
* @return \OCP\AppFramework\Db\Entity |
94
|
|
|
*/ |
95
|
|
|
public function update($id, $title, $stackId, $type, $order, $description, $duedate, $deletedAt) { |
96
|
|
|
return $this->cardService->update($id, $title, $stackId, $type, $order, $description, $this->userId, $duedate, $deletedAt); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @NoAdminRequired |
101
|
|
|
* @param $cardId |
102
|
|
|
* @return \OCP\AppFramework\Db\Entity |
103
|
|
|
*/ |
104
|
|
|
public function delete($cardId) { |
105
|
|
|
return $this->cardService->delete($cardId); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @NoAdminRequired |
110
|
|
|
* @param $boardId |
111
|
|
|
* @return \OCP\AppFramework\Db\Entity |
112
|
|
|
*/ |
113
|
|
|
public function deleted($boardId) { |
114
|
|
|
return $this->cardService->fetchDeleted($boardId); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @NoAdminRequired |
119
|
|
|
* @param $cardId |
120
|
|
|
* @return \OCP\AppFramework\Db\Entity |
121
|
|
|
*/ |
122
|
|
|
public function archive($cardId) { |
123
|
|
|
return $this->cardService->archive($cardId); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @NoAdminRequired |
128
|
|
|
* @param $cardId |
129
|
|
|
* @return \OCP\AppFramework\Db\Entity |
130
|
|
|
*/ |
131
|
|
|
public function unarchive($cardId) { |
132
|
|
|
return $this->cardService->unarchive($cardId); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @NoAdminRequired |
137
|
|
|
* @param $cardId |
138
|
|
|
* @param $labelId |
139
|
|
|
*/ |
140
|
|
|
public function assignLabel($cardId, $labelId) { |
141
|
|
|
$this->cardService->assignLabel($cardId, $labelId); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @NoAdminRequired |
146
|
|
|
* @param $cardId |
147
|
|
|
* @param $labelId |
148
|
|
|
*/ |
149
|
|
|
public function removeLabel($cardId, $labelId) { |
150
|
|
|
$this->cardService->removeLabel($cardId, $labelId); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @NoAdminRequired |
155
|
|
|
*/ |
156
|
|
|
public function assignUser($cardId, $userId) { |
157
|
|
|
return $this->cardService->assignUser($cardId, $userId); |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* @NoAdminRequired |
162
|
|
|
*/ |
163
|
|
|
public function unassignUser($cardId, $userId) { |
164
|
|
|
return $this->cardService->unassignUser($cardId, $userId); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
|
168
|
|
|
|
169
|
|
|
} |
170
|
|
|
|