示例#1
0
 /**
  * Delete a ticket comment
  *
  * @apiMethod DELETE
  * @apiUri    /support/{ticket}/comments/{comment}
  * @apiParameter {
  * 		"name":        "ticket",
  * 		"description": "Ticket identifier",
  * 		"type":        "integer",
  * 		"required":    true,
  * 		"default":     0
  * }
  * @apiParameter {
  * 		"name":        "comment",
  * 		"description": "Comment identifier",
  * 		"type":        "integer",
  * 		"required":    true,
  * 		"default":     0
  * }
  * @return    void
  */
 public function deleteTask()
 {
     $this->requiresAuthentication();
     if (!$this->acl->check('delete', 'comments')) {
         throw new Exception(Lang::txt('Not authorized'), 403);
     }
     $ticket_id = Request::getInt('ticket', 0);
     $comment_id = Request::getInt('comment', 0);
     $ticket = new \Components\Support\Models\Ticket($ticket_id);
     if (!$ticket->exists()) {
         throw new Exception(Lang::txt('COM_SUPPORT_ERROR_MISSING_RECORD'), 404);
     }
     $comment = new \Components\Support\Models\Comment($comment_id);
     if (!$comment->exists()) {
         throw new Exception(Lang::txt('COM_SUPPORT_ERROR_MISSING_RECORD'), 404);
     }
     if ($comment->isPrivate() && !$this->acl->check('delete', 'private_comments')) {
         throw new Exception(Lang::txt('COM_SUPPORT_ERROR_UNAUTHORIZED'), 403);
     }
     if (!$comment->delete()) {
         throw new Exception($comment->getError(), 500);
     }
     $this->send(null, 204);
 }