/** * Adds vote to the db. * * @return Vote data. */ protected function add() { if($this->isAjax) { $args = array( 'Choice' => Director::urlParam('Vote'), 'IP' => Director::urlParam('IP') ); $vote = new Vote($args); if($vote->write()) { $args['success'] = true; } else { $args['success'] = false; } $json = json_encode($args); return $json; } else { return Director::redirect('/'); } }
public function registervote() { $pos = $_GET['pos'] == "true" ? true : false; $roomid = Convert::raw2sql($_GET['roomid']); $optionid = Convert::raw2sql($_GET['optionid']); $nonce = $_POST["payment_method_nonce"]; $option = Option::get_by_id("Option", $optionid); if (isset($_POST["payment_method_nonce"])) { $result = Braintree_Transaction::sale(['amount' => '1.00', 'paymentMethodNonce' => $nonce]); } if ($option) { $vote = new Vote(); $vote->Positive = $pos; $vote->ParentID = $option->ID; $voteID = $vote->write(); } }