/** * @param SS_HTTPRequest $r * @return SS_HTTPResponse|void * @throws SS_HTTPResponse_Exception */ public function handleAddComment(SS_HTTPRequest $r) { if (!Member::currentUser()) { return $this->httpError(403); } $comment = $r->postVar('comment'); if ($comment != null) { $commentObj = $this->presentation->addComment($comment, Member::currentUserID()); $json = $commentObj->toJSON(); $json['name'] = Member::currentUser()->getName(); $json['ago'] = $commentObj->obj('Created')->Ago(false); return (new SS_HTTPResponse(Convert::array2json($json), 200))->addHeader('Content-Type', 'application/json'); } return $this->httpError(400, "Invalid comment"); }