/** * It creates a new ModelVoting object class ir if it has been created * before, it return the previous object * * @access public * @since 3.0 * @return ModelVoting */ public static function newInstance() { if (!self::$instance instanceof self) { self::$instance = new self(); } return self::$instance; }
/** * hook delete * @param type $userID */ function voting_user_delete($userId) { ModelVoting::newInstance()->deleteUser($userId); }
if (can_vote($itemId, $userId, $hash)) { ModelVoting::newInstance()->insertItemVote($itemId, $userId, $iVote, $hash); } } else { if ($user == 1 && is_null($hash)) { if (can_vote($itemId, $userId, $hash)) { ModelVoting::newInstance()->insertItemVote($itemId, $userId, $iVote, $hash); } } } } // return updated voting $item = Item::newInstance()->findByPrimaryKey($itemId); View::newInstance()->_exportVariableToView('item', $item); if (osc_is_this_category('voting', osc_item_category_id())) { $aux_vote = ModelVoting::newInstance()->getItemAvgRating(osc_item_id()); $aux_count = ModelVoting::newInstance()->getItemNumberOfVotes(osc_item_id()); $vote['vote'] = $aux_vote['vote']; $vote['total'] = $aux_count['total']; $vote['can_vote'] = true; if (osc_get_preference('user', 'voting') == 1) { if (!osc_is_web_user_logged_in()) { $vote['can_vote'] = false; } } if (!can_vote(osc_item_id(), osc_logged_user_id(), $hash)) { $vote['can_vote'] = false; } require 'view_votes.php'; } }