| @@ 285-303 (lines=19) @@ | ||
| 282 | /** |
|
| 283 | * Deletes a given {@link Comment} via the URL. |
|
| 284 | */ |
|
| 285 | public function delete() |
|
| 286 | { |
|
| 287 | $comment = $this->getComment(); |
|
| 288 | if (!$comment) { |
|
| 289 | return $this->httpError(404); |
|
| 290 | } |
|
| 291 | if (!$comment->canDelete()) { |
|
| 292 | return Security::permissionFailure($this, 'You do not have permission to delete this comment'); |
|
| 293 | } |
|
| 294 | if (!$comment->getSecurityToken()->checkRequest($this->request)) { |
|
| 295 | return $this->httpError(400); |
|
| 296 | } |
|
| 297 | ||
| 298 | $comment->delete(); |
|
| 299 | ||
| 300 | return $this->request->isAjax() |
|
| 301 | ? true |
|
| 302 | : $this->redirectBack(); |
|
| 303 | } |
|
| 304 | ||
| 305 | /** |
|
| 306 | * Marks a given {@link Comment} as spam. Removes the comment from display |
|
| @@ 308-323 (lines=16) @@ | ||
| 305 | /** |
|
| 306 | * Marks a given {@link Comment} as spam. Removes the comment from display |
|
| 307 | */ |
|
| 308 | public function spam() |
|
| 309 | { |
|
| 310 | $comment = $this->getComment(); |
|
| 311 | if (!$comment) { |
|
| 312 | return $this->httpError(404); |
|
| 313 | } |
|
| 314 | if (!$comment->canEdit()) { |
|
| 315 | return Security::permissionFailure($this, 'You do not have permission to edit this comment'); |
|
| 316 | } |
|
| 317 | if (!$comment->getSecurityToken()->checkRequest($this->request)) { |
|
| 318 | return $this->httpError(400); |
|
| 319 | } |
|
| 320 | ||
| 321 | $comment->markSpam(); |
|
| 322 | return $this->renderChangedCommentState($comment); |
|
| 323 | } |
|
| 324 | ||
| 325 | /** |
|
| 326 | * Marks a given {@link Comment} as ham (not spam). |
|
| @@ 328-343 (lines=16) @@ | ||
| 325 | /** |
|
| 326 | * Marks a given {@link Comment} as ham (not spam). |
|
| 327 | */ |
|
| 328 | public function ham() |
|
| 329 | { |
|
| 330 | $comment = $this->getComment(); |
|
| 331 | if (!$comment) { |
|
| 332 | return $this->httpError(404); |
|
| 333 | } |
|
| 334 | if (!$comment->canEdit()) { |
|
| 335 | return Security::permissionFailure($this, 'You do not have permission to edit this comment'); |
|
| 336 | } |
|
| 337 | if (!$comment->getSecurityToken()->checkRequest($this->request)) { |
|
| 338 | return $this->httpError(400); |
|
| 339 | } |
|
| 340 | ||
| 341 | $comment->markApproved(); |
|
| 342 | return $this->renderChangedCommentState($comment); |
|
| 343 | } |
|
| 344 | ||
| 345 | /** |
|
| 346 | * Marks a given {@link Comment} as approved. |
|
| @@ 348-362 (lines=15) @@ | ||
| 345 | /** |
|
| 346 | * Marks a given {@link Comment} as approved. |
|
| 347 | */ |
|
| 348 | public function approve() |
|
| 349 | { |
|
| 350 | $comment = $this->getComment(); |
|
| 351 | if (!$comment) { |
|
| 352 | return $this->httpError(404); |
|
| 353 | } |
|
| 354 | if (!$comment->canEdit()) { |
|
| 355 | return Security::permissionFailure($this, 'You do not have permission to approve this comment'); |
|
| 356 | } |
|
| 357 | if (!$comment->getSecurityToken()->checkRequest($this->request)) { |
|
| 358 | return $this->httpError(400); |
|
| 359 | } |
|
| 360 | $comment->markApproved(); |
|
| 361 | return $this->renderChangedCommentState($comment); |
|
| 362 | } |
|
| 363 | ||
| 364 | /** |
|
| 365 | * Redirect back to referer if available, ensuring that only site URLs |
|