public function init($formID) { switch ($formID) { case 'vote': $key = key($_POST[$formID]); $id = $_POST[$formID][$key]; if (check_in_ses('vote_set', $id)) { } Redirect($base . '#review-' . $id); exit; break; case 'review': $validation = crud_validation($reviews->form_map(), 'review'); $data = $reviews->post = $validation['post']; if ($validation['error']) { foreach ($validation['error'] as $e => $v) { $reviews->map[$e]['error'] = $v; } } else { $crud->insert(REVIEWS_TABLE, $data); $rating = $reviews->get_rating($data['productID']); $customers_rating = round($rating['avg'] * 2) / 2; $crud->update(PRODUCTS_TABLE, array('customers_rating' => number_format($customers_rating, 2, '.', ''), 'customer_votes' => (int) $rating['amt']), 'productID=' . $productID); } Redirect($base . '#review-' . $id); exit; break; } }
private function new_vote() { if (isset($_POST['vote']['id']) && $_POST['vote']['id'] == 'review') { $post = $_POST['vote']; unset($post['id']); $key = key($post); $id = $post[$key]; if (in_array($key, array('up', 'dwn')) && !empty($id)) { if (check_in_ses('vote_set', $id)) { $this->update($this->set['tbl'], array('vote_' . $key => 'increment(1)'), 'id=' . $id); // Redirect($_SERVER['REQUEST_URI'] . '#review-' . $id); Redirect($_SERVER['REQUEST_URI']); } } } }