/** * Show form to vote a seller if item belongs to a registered user. (itemDetail) * * @param type $item item array or userId */ function voting_item_detail_user($item = null) { $userId = null; if ($item == null) { $userId = osc_item_user_id(); } else { if (is_numeric($item)) { $userId = $item; } else { if (is_array($item)) { $userId = $item['fk_i_user_id']; } else { exit; } } } if (osc_get_preference('user_voting', 'voting') == 1 && is_numeric($userId) && isset($userId) && $userId > 0) { // obtener el avg de las votaciones $aux_vote = ModelVoting::newInstance()->getUserAvgRating($userId); $aux_count = ModelVoting::newInstance()->getUserNumberOfVotes($userId); $vote['vote'] = $aux_vote['vote']; $vote['total'] = $aux_count['total']; $vote['userId'] = $userId; $vote['can_vote'] = false; if (osc_is_web_user_logged_in() && can_vote_user($userId, osc_logged_user_id())) { $vote['can_vote'] = true; } require 'item_detail_user.php'; } }
$hash = ''; // Vote Users if (isset($iVote) && is_numeric($iVote) && isset($votedUserId) && is_numeric($votedUserId)) { if ($iVote <= 5 && $iVote >= 1) { if (can_vote_user($votedUserId, $userId)) { ModelVoting::newInstance()->insertUserVote($votedUserId, $userId, $iVote); } } // return updated voting $aux_vote = ModelVoting::newInstance()->getUserAvgRating($votedUserId); $aux_count = ModelVoting::newInstance()->getUserNumberOfVotes($votedUserId); $vote['vote'] = $aux_vote['vote']; $vote['total'] = $aux_count['total']; $vote['userId'] = $votedUserId; $vote['can_vote'] = true; if (!osc_is_web_user_logged_in() || !can_vote_user($votedUserId, $userId)) { $vote['can_vote'] = false; } require 'view_votes_user.php'; } // Vote Items if (isset($iVote) && is_numeric($iVote) && isset($itemId) && is_numeric($itemId)) { if ($iVote <= 5 && $iVote >= 1) { if ($userId == 0) { $userId = 'NULL'; $hash = $_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR']; $hash = sha1($hash); } else { $hash = null; } $open = osc_get_preference('open', 'voting');