public function editAction() { $comment_id = (int) $this->getParam('id'); $form_config = $this->current_module_config->forms->upload_comment; $form = new \FA\Form($form_config); $form->populate($_POST); if ($_POST && $form->isValid($_POST) && $this->csrf->verify($form->getValue('csrf'), '_upload_comments')) { // TODO: Check comment edit rate limit here! $comment = UploadComment::find($comment_id); if (!$comment instanceof UploadComment) { throw new \FA\Exception('Comment not found!'); } if (!$comment->canEdit($this->user)) { throw new \FA\Exception('Unable to edit comment!'); } $upload = $comment->upload; // Prevent posting if comments are locked if ($upload->comments_locked) { throw new \FA\Exception('Comments are locked on this Upload!'); } // Verify the user can even progress further self::_userCheck($upload); // Update the comment's text $comment->message = $form->getValue('JSMessage'); $comment->save(); // Redirect to the Upload page to our comment! // TODO: Add a way to auto-lock on to the comment. Maybe a perma-link style approach? return $this->redirectToName('upload_view', array('id' => $upload->id)); } }