@@ 142-156 (lines=15) @@ | ||
139 | return $data; |
|
140 | } |
|
141 | ||
142 | public function lockPost(Request $request, $id) |
|
143 | { |
|
144 | if (!$this->canAdministrate() && !$this->canModerate()) { |
|
145 | return response('Unauthorised', 401); |
|
146 | } |
|
147 | ||
148 | $post = $this->postExists($id); |
|
149 | if (!$post) { |
|
150 | return response('Post not found', 404); |
|
151 | } |
|
152 | ||
153 | $post->locked = 1; |
|
154 | $post->save(); |
|
155 | return response('Post Locked', 200); |
|
156 | } |
|
157 | ||
158 | public function unlockPost(Request $request, $id) |
|
159 | { |
|
@@ 158-172 (lines=15) @@ | ||
155 | return response('Post Locked', 200); |
|
156 | } |
|
157 | ||
158 | public function unlockPost(Request $request, $id) |
|
159 | { |
|
160 | if (!$this->canAdministrate() && !$this->canModerate()) { |
|
161 | return response('Unauthorised', 401); |
|
162 | } |
|
163 | ||
164 | $post = $this->postExists($id); |
|
165 | if (!$post) { |
|
166 | return response('Post not found', 404); |
|
167 | } |
|
168 | ||
169 | $post->locked = 0; |
|
170 | $post->save(); |
|
171 | return response('Post Unlocked', 200); |
|
172 | } |
|
173 | ||
174 | public function stickyPost(Request $request, $id) |
|
175 | { |
|
@@ 174-188 (lines=15) @@ | ||
171 | return response('Post Unlocked', 200); |
|
172 | } |
|
173 | ||
174 | public function stickyPost(Request $request, $id) |
|
175 | { |
|
176 | if (!$this->canAdministrate() && !$this->canModerate()) { |
|
177 | return response('Unauthorised', 401); |
|
178 | } |
|
179 | ||
180 | $post = $this->postExists($id); |
|
181 | if (!$post) { |
|
182 | return response('Post not found', 404); |
|
183 | } |
|
184 | ||
185 | $post->sticky = 1; |
|
186 | $post->save(); |
|
187 | return response('Post Unlocked', 200); |
|
188 | } |
|
189 | ||
190 | public function unstickyPost(Request $request, $id) |
|
191 | { |
|
@@ 190-204 (lines=15) @@ | ||
187 | return response('Post Unlocked', 200); |
|
188 | } |
|
189 | ||
190 | public function unstickyPost(Request $request, $id) |
|
191 | { |
|
192 | if (!$this->canAdministrate() && !$this->canModerate()) { |
|
193 | return response('Unauthorised', 401); |
|
194 | } |
|
195 | ||
196 | $post = $this->postExists($id); |
|
197 | if (!$post) { |
|
198 | return response('Post not found', 404); |
|
199 | } |
|
200 | ||
201 | $post->sticky = 0; |
|
202 | $post->save(); |
|
203 | return response('Post Unlocked', 200); |
|
204 | } |
|
205 | ||
206 | private function postExists($post_id) |
|
207 | { |
|
@@ 216-229 (lines=14) @@ | ||
213 | } |
|
214 | } |
|
215 | ||
216 | public function postDelete($forum_id, $post_id) |
|
217 | { |
|
218 | if (!$this->canAdministrate() && !$this->canModerate()) { |
|
219 | return response('Unauthorised', 401); |
|
220 | } |
|
221 | ||
222 | $post = $this->postExists($post_id); |
|
223 | if (!$post) { |
|
224 | return response('Post not found', 404); |
|
225 | } |
|
226 | ||
227 | $post->delete(); |
|
228 | return response('Post Deleted', 200); |
|
229 | } |
|
230 | ||
231 | public function forumDelete(Request $request) |
|
232 | { |
|
@@ 258-273 (lines=16) @@ | ||
255 | } |
|
256 | } |
|
257 | ||
258 | public function forumCategoryDelete(Request $request) |
|
259 | { |
|
260 | if (!$this->canAdministrate() && !$this->canModerate()) { |
|
261 | return response('Unauthorised', 401); |
|
262 | } |
|
263 | ||
264 | $cat_id = $request->input('category_id'); |
|
265 | ||
266 | $cat = $this->forumCategoryExists($cat_id); |
|
267 | if (!$cat) { |
|
268 | return response('Forum Category not found', 404); |
|
269 | } |
|
270 | ||
271 | $cat->delete(); |
|
272 | return response('Forum Category Deleted', 200); |
|
273 | } |
|
274 | ||
275 | private function forumCategoryExists(Request $request, $id) |
|
276 | { |
|
@@ 231-246 (lines=16) @@ | ||
228 | return response('Post Deleted', 200); |
|
229 | } |
|
230 | ||
231 | public function forumDelete(Request $request) |
|
232 | { |
|
233 | if (!$this->canAdministrate() && !$this->canModerate()) { |
|
234 | return response('Unauthorised', 401); |
|
235 | } |
|
236 | ||
237 | $forum_id = $request->input('forum_id'); |
|
238 | ||
239 | $forum = $this->forumExists($forum_id); |
|
240 | if (!$forum) { |
|
241 | return response('Forum not found', 404); |
|
242 | } |
|
243 | ||
244 | $forum->delete(); |
|
245 | return response('Forum Deleted', 200); |
|
246 | } |
|
247 | ||
248 | private function forumExists($id) |
|
249 | { |