/** * Handle a submission by inserting/updating the vote * and (optionally) adding the comment. * * @since 0.1 * * @param integer $contestantId * * @return boolean Success indicator */ protected function handleSubmission($contestantId) { $success = true; if (trim($this->getRequest()->getText('new-comment-text')) !== '') { $comment = new ContestComment(array('user_id' => $this->getUser()->getId(), 'contestant_id' => $contestantId, 'text' => $this->getRequest()->getText('new-comment-text'), 'time' => wfTimestampNow())); $success = $comment->writeToDB(); if ($success) { ContestContestant::s()->addToField('comments', 1); } } if ($success && !is_null($this->getRequest()->getVal('contestant-rating'))) { $attribs = array('value' => $this->getRequest()->getInt('contestant-rating'), 'contestant_id' => $contestantId, 'user_id' => $this->getUser()->getId()); if (!is_null($this->getRequest()->getVal('contestant-vote-id'))) { $attribs['id'] = $this->getRequest()->getInt('contestant-vote-id'); } $vote = new ContestVote($attribs); $success = $vote->writeToDB() && $success; } return $success; }