/** * Removes all found votes from the voting because a newer vote has been registered * * @param int $user_id Tweet User ID * @param int $entry_id Entry id to check for multiple votes */ private function ExcludeOldTweetEntry($contest_id, $user_id, $entry_id, $tweet_id) { // Select old tweets of user for this entry and exlude them from the voting $TweetCollection = Tweet::findAll(['contest_id' => $contest_id, 'entry_id' => $entry_id, 'user_id' => $user_id, 'needs_validation' => 0, 'old_vote' => 0]); foreach ($TweetCollection as $Tweet) { // don't set oldvote on given tweet id if ($Tweet->id != $tweet_id) { $Tweet->old_vote = 1; if ($Tweet->save()) { $this->stdout("Tweet with Tweet ID " . $Tweet->id . " removed from Voting because of a newer Vote\n", Console::BOLD); } } } }
/** * Creates a Tweet Object and saves it to the DB * * @param Array $tweet JSON Tweet structure * @param Array $regex regular expression to parse the rating and Entry - http://regex101.com/r/cB6oU6/7 * @return int id of the tweet or null if an error happened */ private function ExcludeOldTweetEntry($contest_id, $user_id, $entry_id, $tweet_id) { // Select old tweets of user for this entry and exlude them from the voting $TweetCollection = Tweet::findAll(['contest_id' => $contest_id, 'entry_id' => $entry_id, 'user_id' => $user_id, 'needs_validation' => 0, 'old_vote' => 0]); foreach ($TweetCollection as $Tweet) { // don't set oldvote on given tweet id if ($Tweet->id != $tweet_id) { $Tweet->old_vote = 1; $Tweet->save(); } } }