@@ 219-232 (lines=14) @@ | ||
216 | /** |
|
217 | * Deletes a given {@link Comment} via the URL. |
|
218 | */ |
|
219 | public function delete() { |
|
220 | $comment = $this->getComment(); |
|
221 | if(!$comment) return $this->httpError(404); |
|
222 | if(!$comment->canDelete()) { |
|
223 | return Security::permissionFailure($this, 'You do not have permission to delete this comment'); |
|
224 | } |
|
225 | if(!$comment->getSecurityToken()->checkRequest($this->request)) return $this->httpError(400); |
|
226 | ||
227 | $comment->delete(); |
|
228 | ||
229 | return $this->request->isAjax() |
|
230 | ? true |
|
231 | : $this->redirectBack(); |
|
232 | } |
|
233 | ||
234 | /** |
|
235 | * Marks a given {@link Comment} as spam. Removes the comment from display |
|
@@ 237-247 (lines=11) @@ | ||
234 | /** |
|
235 | * Marks a given {@link Comment} as spam. Removes the comment from display |
|
236 | */ |
|
237 | public function spam() { |
|
238 | $comment = $this->getComment(); |
|
239 | if(!$comment) return $this->httpError(404); |
|
240 | if(!$comment->canEdit()) { |
|
241 | return Security::permissionFailure($this, 'You do not have permission to edit this comment'); |
|
242 | } |
|
243 | if(!$comment->getSecurityToken()->checkRequest($this->request)) return $this->httpError(400); |
|
244 | ||
245 | $comment->markSpam(); |
|
246 | return $this->renderChangedCommentState($comment); |
|
247 | } |
|
248 | ||
249 | /** |
|
250 | * Marks a given {@link Comment} as ham (not spam). |
|
@@ 252-262 (lines=11) @@ | ||
249 | /** |
|
250 | * Marks a given {@link Comment} as ham (not spam). |
|
251 | */ |
|
252 | public function ham() { |
|
253 | $comment = $this->getComment(); |
|
254 | if(!$comment) return $this->httpError(404); |
|
255 | if(!$comment->canEdit()) { |
|
256 | return Security::permissionFailure($this, 'You do not have permission to edit this comment'); |
|
257 | } |
|
258 | if(!$comment->getSecurityToken()->checkRequest($this->request)) return $this->httpError(400); |
|
259 | ||
260 | $comment->markApproved(); |
|
261 | return $this->renderChangedCommentState($comment); |
|
262 | } |
|
263 | ||
264 | /** |
|
265 | * Marks a given {@link Comment} as approved. |
|
@@ 267-277 (lines=11) @@ | ||
264 | /** |
|
265 | * Marks a given {@link Comment} as approved. |
|
266 | */ |
|
267 | public function approve() { |
|
268 | $comment = $this->getComment(); |
|
269 | if(!$comment) return $this->httpError(404); |
|
270 | if(!$comment->canEdit()) { |
|
271 | return Security::permissionFailure($this, 'You do not have permission to approve this comment'); |
|
272 | } |
|
273 | if(!$comment->getSecurityToken()->checkRequest($this->request)) return $this->httpError(400); |
|
274 | ||
275 | $comment->markApproved(); |
|
276 | return $this->renderChangedCommentState($comment); |
|
277 | } |
|
278 | ||
279 | /** |
|
280 | * Redirect back to referer if available, ensuring that only site URLs |