/** * News-Comment anlegen * * @post /news/:news_id/comments */ public function appendComment($news_id) { $news = $this->requireNews($news_id); if (!$news->allow_comments) { $this->error(409, 'Comments are not allowed'); } if (!isset($this->data['content']) || !strlen($content = trim($this->data['content']))) { $this->error(400, 'Content required.'); } $comment = new \StudipComment(); $comment->setData(array('object_id' => $news_id, 'user_id' => $GLOBALS['user']->id, 'content' => $content)); if (!$comment->store()) { $this->halt(500, 'Could not create comment.'); } $this->redirect('comment/' . $comment->id, 201, "ok"); }