function inSeason(&$jSeason) { global $database; $params = array('user_id' => $this->user_id, 'season_id' => $jSeason->id); $jTipsUser = new jTipsUser($database); $jTipsUser->loadByParams($params); if (isset($jTipsUser->season_id) && !empty($jTipsUser->season_id) && $jTipsUser->season_id == $jSeason->id) { return TRUE; } else { return FALSE; } }
<?php if (!defined('_JEXEC') and !defined('_VALID_MOS')) { die('Restricted Access'); } /** * Author: Jeremy Roberts * Package: jTicket * Website: www.jtips.com.au * Created: 30/09/2008 * * Description: Saves the User Preferences */ global $database, $Itemid; $jTipsUsers = new jTipsUser($database); $jTipsUserParams = array('user_id' => jTipsGetParam($_REQUEST, 'id', 0)); $jTipsUserArr = forceArray($jTipsUsers->loadByParams($jTipsUserParams)); foreach ($jTipsUserArr as $jTipsUser) { $jTipsUser->setPreference('default_season', jTipsGetParam($_REQUEST, 'default_season', -1)); $jTipsUser->setPreference('timezone', jTipsGetParam($_REQUEST, 'timezone', null)); $jTipsUser->setPreference('email_reminder', jTipsGetParam($_REQUEST, 'email_reminder', '0')); $jTipsUser->setPreference('tips_notifications', jTipsGetParam($_REQUEST, 'tips_notifications', '0')); } $return_view = jTipsGetParam($_REQUEST, 'return', 'Dashboard'); if (!$return_view) { $return_view = 'Dashboard'; } jTipsRedirect('index.php?option=com_jtips&view=' . jTipsGetParam($_REQUEST, 'return', 'Dashboard') . '&Itemid=' . $Itemid . '&season=' . getSeasonID());
$jTipsUser = new jTipsUser($database); $limitstart = jTipsGetParam($_REQUEST, 'limitstart', 0); $limit = jTipsGetParam($_REQUEST, 'limit', 25); $direction = jTipsGetParam($_REQUEST, 'filter_order_Dir', 'asc'); if (empty($direction)) { $direction = 'asc'; } $orderby = jTipsGetParam($_REQUEST, 'filter_order', 'name'); if (empty($orderby)) { $orderby = 'name'; } $params = array('order' => array('type' => 'order', 'direction' => $direction, 'by' => $orderby), 'join_users' => array('type' => 'join', 'join_table' => '#__users', 'lhs_table' => '#__jtips_users', 'lhs_key' => 'user_id', 'rhs_table' => '#__users', 'rhs_key' => 'id')); if ($season_id = jTipsGetParam($_REQUEST, 'season_id', false)) { $params['season_id'] = $season_id; } $jTipsUsers = forceArray($jTipsUser->loadByParams($params, $limit, $limitstart)); $pageNav = new mosPageNav($jTipsUser->getCount(), $limitstart, $limit); $data = array(); $i = 0; foreach ($jTipsUsers as $jTipsUserItem) { $scores = $jTipsUserItem->getSummaryScores(); $data[$jTipsUserItem->id] = array("<label for='cb{$i}'>" . $jTipsUserItem->getUserField('name') . "</label>", $jTipsUserItem->getUserField('username'), $jTipsUserItem->getSeasonName(), $jTipsUserItem->doubleup, number_format($scores[$jTipsUserItem->season_id]['average'], 2), $scores[$jTipsUserItem->season_id]['total_points'], '<div style="text-align:center;"><a href="javascript:toggleBoolean(\'' . $jTipsUserItem->id . '\', \'paid\');"><img src="images/' . ($jTipsUserItem->paid ? "tick" : "publish_x") . '.png" id="paid_' . $jTipsUserItem->id . '" border="0" /></div>', '<div style="text-align:center;"><a href="javascript:toggleBoolean(\'' . $jTipsUserItem->id . '\', \'status\');"><img src="images/' . ($jTipsUserItem->status == 1 ? "tick" : "publish_x") . '.png" border="0" id="status_' . $jTipsUserItem->id . '" /></a></div>'); $i++; } $jSeason = new jSeason($database); $jSeasons = forceArray($jSeason->loadByParams()); $options = array(jTipsHTML::makeOption('', $jLang['_ADMIN_USERS_SELECT_SEASON'])); foreach ($jSeasons as $season) { $options[] = jTipsHTML::makeOption($season->id, $season->name); } $filters = array($jLang['_ADMIN_SEASON_SELECT'] => jTipsHTML::selectList($options, 'season_id', "id='season_id' class='inputbox' onChange='this.form.submit();'", 'value', 'text', jTipsGetParam($_REQUEST, 'season_id', '')));
function getUsers($round_id = FALSE) { global $database; if ($round_id === FALSE) { // BUG 304 - join with users table to avoid trying to load ids with no matching user $params = array('#__jtips_users.season_id' => $this->id, '#__jtips_users.status' => 1, 'join' => array('type' => 'join', 'join_table' => '#__users', 'lhs_table' => '#__jtips_users', 'lhs_key' => 'user_id', 'rhs_table' => '#__users', 'rhs_key' => 'id')); } else { $params = array('#__jtips_users.id' => array('type' => 'in', 'query' => 'SELECT #__jtips_history.user_id FROM #__jtips_history WHERE #__jtips_history.round_id = ' . $round_id), '#__jtips_users.season_id' => $this->id, '#__jtips_users.status' => 1); } $jTipsUser = new jTipsUser($database); $jTipsUsers = forceArray($jTipsUser->loadByParams($params)); $this->users = $jTipsUsers; return $jTipsUsers; }
$include_path = $mosConfig_absolute_path . '/administrator/components/com_jtips/'; //Include required files require_once $include_path . 'utils/timedate.php'; require_once $include_path . 'utils/functions.inc.php'; require_once $include_path . 'classes/jround.class.php'; require_once $include_path . 'classes/jseason.class.php'; require_once $include_path . 'classes/jgame.class.php'; require_once $include_path . 'classes/jteam.class.php'; require_once $include_path . 'classes/juser.class.php'; include $include_path . 'config.jtips.php'; //BUG if (!$jTipsCurrentUser) { $jTipsCurrentUser = new jTipsUser($database); $my =& $mainframe->getUser(); $parameters = array('user_id' => $my->id); $temp = forceArray($jTipsCurrentUser->loadByParams($parameters)); $jTipsCurrentUser = array_shift($temp); unset($parameters); } //Get the season $jtips_params = array('name' => trim($season_name)); $jSeason = new jSeason($database); $jSeason->loadByParams($jtips_params); if (isset($jSeason->id) and !empty($jSeason->id)) { //parse the info here $hasData = true; $round_id = $jSeason->getCurrentRound(); $jRound = new jRound($database); if (!$round_id) { $hasData = false; } else {
$params = array('season_id' => $id); $jRound = new jRound($database); $jRounds = $jSeason->loadByParams($params); if (!is_array($jRounds)) { if ($jRound->exists()) { $jRounds = array($jRound); } else { $jRounds = array(); } } jTipsLogger::_log('deleting rounds from season'); foreach ($jRounds as $jRound) { array_push($destroyed, $jRound->destroy()); } $jTipsUser = new jTipsUser($database); $jTipsUsers = $jTipsUser->loadByParams($params); if (!is_array($jTipsUsers)) { if ($jTipsUser->exists()) { $jTipsUsers = array($jTipsUser); } else { $jTipsUsers = array(); } } jTipsLogger::_log('deleting users from season'); foreach ($jTipsUsers as $jTipsUser) { array_push($destroyed, $jTipsUser->destroy()); } array_push($destroyed, $jSeason->destroy()); if (in_array(FALSE, $destroyed)) { $message = 'Season(s) not cleanly removed!'; } else {
require_once $include_path . 'classes/juser.class.php'; include $include_path . 'config.jtips.php'; //Get the season $jtips_params = array('name' => trim($season_name)); $jSeason = new jSeason($database); $jSeason->loadByParams($jtips_params); if (isset($jSeason->id) and !empty($jSeason->id)) { //parse the info here if (!$my) { $my =& $mainframe->getUser(); } $query = "SELECT tip_id AS team_id, COUNT(*) times_picked " . "FROM #__jtips_tips JOIN #__jtips_users ON " . "#__jtips_tips.user_id = #__jtips_users.id "; if ($params->get('user') and $my->id) { $jTipsUserParams = array('season_id' => $jSeason->id, 'user_id' => $my->id, 'status' => 1); $jTipsFTModuleUser = new jTipsUser($database); $jTipsFTModuleUser->loadByParams($jTipsUserParams); if ($jTipsFTModuleUser->id) { $query .= "WHERE #__jtips_users.user_id = " . $database->Quote($my->id) . " "; } } $query .= "GROUP BY #__jtips_tips.tip_id ORDER BY times_picked DESC"; $database->setQuery($query, 0, 1); $team = $database->loadRow(); if ($team) { $jTeam = new jTeam($database); $jTeam->load($team[0]); ?> <div style="text-align:center;"><?php $popupUrl = "view=TeamLadder&action=ShowTeam&menu=0&id=" . $jTeam->id . "&season_id=" . $jTeam->season_id; if (isJoomla15()) { $x = $jTips['ShowTipsWidth'];
<?php } else { JHTML::_('behavior.modal'); } // load the selected season $jSeason = new jSeason($database); $jSeason->loadByParams(array('name' => $params->get('season'))); if (!$jSeason->id) { // show an error message ?> <p class="error">No competition selected. Please update module configuration.</p><?php } else { $my =& $mainframe->getUser(); //do we have a valid user? $jTipsMyTipsUser = new jTipsUser($database); $jTipsMyTipsUser->loadByParams(array('user_id' => $my->id, 'season_id' => $jSeason->id)); if (!$jTipsMyTipsUser->id) { ?> <p class="message">Join the <?php echo $jSeason->name; ?> competition!</p><?php } else { // valid user and season, get their tips $round_id = $jSeason->getCurrentRound(); if (!$round_id) { ?> <p class="message">Competition has ended.</p><?php } else { // valid everything, get the tips $jTipParams = array('user_id' => $jTipsMyTipsUser->id, 'game_id' => array('type' => 'join', 'join_table' => '#__jtips_games', 'lhs_table' => '#__jtips_tips', 'lhs_key' => 'game_id', 'rhs_table' => '#__jtips_games', 'rhs_key' => 'id', 'supplement' => "AND #__jtips_games.round_id = '" . $round_id . "'"));
function process() { global $database, $jTips, $mosConfig_absolute_path; $this->clearHistory(); $params = array('round_id' => $this->id); $jSeason = new jSeason($database); $jSeason->load($this->season_id); $jGame = new jGame($database); $jGames = forceArray($jGame->loadByParams($params)); $params = array('season_id' => $this->season_id); $jTipsUser = new jTipsUser($database); $jTipsUsers = forceArray($jTipsUser->loadByParams($params)); $noTips = $scores = $worst_precision = array(); $played = count($jGames); foreach ($jTipsUsers as $jTipsUser) { jTipsLogger::_log("Processing scores for user " . $jTipsUser->id); $score = $matching = $precision = $allAwayScore = 0; if ($jTipsUser->hasTipped($this->id)) { jTipsLogger::_log($jTipsUser->id . " has tipped in round " . $this->id); foreach ($jGames as $jGame) { jTipsLogger::_log("Processing game " . $jGame->id); $params = array('user_id' => $jTipsUser->id, 'game_id' => $jGame->id); $jTip = new jTip($database); $jTip->loadByParams($params); // make sure this is not a bye game if (!$jGame->home_id or !$jGame->away_id or !$jGame->winner_id) { jTipsLogger::_log('attempting to process tips on a bye game, skipping', 'INFO'); continue; } /* * Feature Request 101 - Team Starts * Determine the winner when we take the starts into account * We only care about the starts for picking the winner/draw * For picking the margins and scores, use the actual winner */ if ($jSeason->team_starts) { jTipsLogger::_log('processing team starts'); $homeScore = $awayScore = 0; $homeScore = $jGame->home_score + ($jGame->home_start + 0); $awayScore = $jGame->away_score + ($jGame->away_start + 0); if ($homeScore > $awayScore) { $winnerID = $jGame->home_id; } else { if ($homeScore < $awayScore) { $winnerID = $jGame->away_id; } else { if ($homeScore == $awayScore) { $winnerID = -1; } } } jTipsLogger::_log('feature 101: With starts, the winner is ' . $winnerID . ', otherwise the winner is ' . $jGame->winner_id . " HOME {$homeScore} v AWAY {$awayScore}"); } else { $winnerID = $jGame->winner_id; } if ($jTip->tip_id == $winnerID) { //User tipped right! jTipsLogger::_log("CORRECT TIP by " . $jTipsUser->id . " in round_id " . $this->id . " in game_id " . $jGame->id); //BUG 248 - Add ToughScore if enabled if ($jSeason->tough_score and $jGame->tough_score) { $score += $jGame->tough_score; } if ($winnerID == -1) { $score += isset($jSeason->user_draw) ? $jSeason->user_draw : 0; jTipsLogger::_log("Draw correctly picked!"); } else { $score += isset($jSeason->user_correct) ? $jSeason->user_correct : 0; } $matching++; } if ($winnerID == $jGame->away_id) { $allAwayScore += $jSeason->user_correct; } //Check for correct margins and handle precision score gathering if ($jSeason->pick_margin == 1 and $jGame->has_margin == 1) { $margin = abs($jGame->home_score - $jGame->away_score); if ($jTip->margin == $margin) { $score += isset($jSeason->user_pick_margin) ? $jSeason->user_pick_margin : 0; jTipsLogger::_log("correct margin picked!"); } if ($jSeason->precision_score == 1) { if ($jGame->winner_id == $jTip->tip_id) { $margin_offset = abs($margin - $jTip->margin); } else { $margin_offset = abs($margin + $jTip->margin); } if (isset($worst_precision[$jGame->id]) && $margin_offset > $worst_precision[$jGame->id] || empty($worst_precision[$jGame->id])) { $worst_precision[$jGame->id] = $margin_offset; } $precision += $margin_offset; jTipsLogger::_log("PICK_MARGIN: Adding {$margin_offset} to precision of {$precision}"); } } //Check for correct scores and handle precision score gathering if ($jSeason->pick_score == 1 and $jGame->has_score == 1) { $margin = abs($jGame->home_score - $jGame->away_score); if ($jTip->home_score == $jGame->home_score and $jTip->away_score == $jGame->away_score) { $score += isset($jSeason->user_pick_score) ? $jSeason->user_pick_score : 0; jTipsLogger::_log("Correct scores picked!"); } if ($jSeason->precision_score == 1) { $pickedScoreMargin = abs($jTip->home_score - $jTips->away_score); if ($jGame->winner_id == $jTip->tip_id) { $score_offset = abs($margin - $pickedScoreMargin); } else { $score_offset = abs($margin + $pickedScoreMargin); } if (isset($worst_precision[$jGame->id]) and $score_offset > $worst_precision[$jGame->id] or empty($worst_precision[$jGame->id])) { $worst_precision[$jGame->id] = $score_offset; } $precision += $score_offset; jTipsLogger::_log("PICK_SCORE: Adding {$score_offset} to precision of {$precision}"); jTipsLogger::_log("PREC DEBUG: {$jTipsUser->id}-{$jTipsUser->user_id} Picked Margin: {$pickedScoreMargin}. Actual Margin: {$margin}. Applied Precision: {$score_offset}. Running Precision: {$precision}", 'INFO'); } } //Check for a bonus team selection if ($jSeason->pick_bonus >= 1 and $jGame->has_bonus == 1) { if ($jTip->bonus_id == $jGame->bonus_id && $jGame->bonus_id != -1) { $score += isset($jSeason->user_pick_bonus) ? $jSeason->user_pick_bonus : 0; } } } //was a perfect round picked? if ($matching == $played) { $score += isset($jSeason->user_bonus) ? $jSeason->user_bonus : 0; } //did the user use their 'doubleup' if ($jTipsUser->doubleup == $this->id and $jTips['DoubleUp'] == 1) { $score = $score * 2; } $scores[] = $score; //Save the data to the history object $jHistory = new jHistory($database); $jHistory->user_id = $jTipsUser->id; $jHistory->round_id = $this->id; jTipsLogger::_log("Score for user_id " . $jTipsUser->id . " in round_id " . $this->id . " is {$score}"); $jHistory->points = $score; //Update rank after all users have been saved $jHistory->outof = count($jTipsUsers); //$jHistory->comment = $jTipsUser->comment; if ($jSeason->precision_score == 1) { jTipsLogger::_log("setting precision to {$precision} for user_id " . $jTipsUser->id . " in round_id " . $this->id); $jHistory->precision = $precision; } else { $jHistory->precision = 0; } if ($jHistory->save() !== false) { $results[] = 1; } else { jTipsLogger::_log("Error saving history: " . $jHistory->_error); $results[] = 0; } //remove the current comment $jTipsUser->comment = null; $jTipsUser->save(); // Check if the AlphaUserPoints config option is set if (isJoomla15()) { $api_AUP = JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; } else { $api_AUP = $mosConfig_absolute_path . 'components/com_alphauserpoints/helper.php'; } if (!$this->scored and $jTips['AlphaUserPoints'] and jTipsFileExists($api_AUP)) { require_once $api_AUP; jTipsLogger::_log('sending ' . $score . ' points for user ' . $jTipsUser->user_id, 'INFO'); $refID = AlphaUserPointsHelper::getAnyUserReferreID($jTipsUser->user_id); AlphaUserPointsHelper::newpoints('plgaup_jtips_total_points', $refID, '', '', $score); } if (!$this->scored and $jTips['JomSocialActivities'] and $jTips['JomSocialUserResults']) { global $mosConfig_absolute_path; require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/utils/jTipsJomSocial.php'; jTipsJomSocial::writeRoundResult($jSeason, $this, $jTipsUser->user_id, $score); } } else { $noTips[] = $jTipsUser; } } if (count($noTips) > 0) { ///////////////////////////////////////////////// // Feature Request 71 // Allow users that did not to be assigned // all the away teams // /*if ($jSeason->user_none != -1) { $thisRound = $jSeason->user_none; } else if (is_array($scores) && count($scores) > 0) { $thisRound = min($scores); } else { $thisRound = 0; }*/ if ($jSeason->user_none == -2) { //handle all away teams $thisRound = $allAwayScore; jTipsLogger::_log("didn't tip? You'll be stuck with the away teams. You got {$thisRound}"); } else { if ($jSeason->user_none == -1) { //handle lowest possible score if (is_array($scores) and count($scores) > 0) { $thisRound = min($scores); jTipsLogger::_log("didn't tip? You'll be stuck with the lowest score this round, {$thisRound}"); } else { $thisRound = 0; jTipsLogger::_log("didn't tip? You'll be stuck {$thisRound}"); } } else { //handle allocated score $thisRound = $jSeason->user_none; jTipsLogger::_log("didn't tip? You're getting {$thisRound}"); } } // // END Feature Request 71 //////////////////////////////////////////////////// foreach ($noTips as $jTipsUser) { $jHistory = new jHistory($database); $jHistory->user_id = $jTipsUser->id; $jHistory->round_id = $this->id; $jHistory->points = $thisRound; $jHistory->precision = array_sum($worst_precision); //$jHistory->outof = count($jTipsUsers); //$jHistory->comment = $jTipsUser->comment; if ($jHistory->save() !== false) { $results[] = 1; } else { $results[] = 0; } $jTipsUser->save(); // Check if the AlphaUserPoints config option is set if (isJoomla15()) { $api_AUP = JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; } else { $api_AUP = $mosConfig_absolute_path . 'components/com_alphauserpoints/helper.php'; } if (!$this->scored and $jTips['AlphaUserPoints'] and jTipsFileExists($api_AUP)) { require_once $api_AUP; jTipsLogger::_log('sending ' . $score . ' points for user ' . $jTipsUser->user_id, 'INFO'); $refID = AlphaUserPointsHelper::getAnyUserReferreID($jTipsUser->user_id); AlphaUserPointsHelper::newpoints('plgaup_jtips_total_points', $refID, '', '', $thisRound); } if (!$this->scored and $jTips['JomSocialActivities']) { global $mosConfig_absolute_path; require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/utils/jTipsJomSocial.php'; if ($jTips['JomSocialUserResults']) { jTipsJomSocial::writeRoundResult($jSeason, $this, $jTipsUser->user_id, $score); } if ($jTips['JomSocialOnNoTips']) { jTipsJomSocial::writeOnNoTips($jTipsUser->user_id, $jSeason, $this); } } } } $jHistory = new jHistory($database); $jHistory->setRanks($this->id, true); if (!$this->scored and $jTips['JomSocialActivities']) { // find out who won the round and write it to the JomSocial stream $winners = $this->getRoundWinners(); jTipsJomSocial::writeRoundWinners($winners, $this, $jSeason); } $this->scored = 1; $result = $this->save(); //if ($this->scored != 1) { jTeam::updateLadder($this, $jSeason); //} //$this->scored = 1; //return $this->save(); return $result; }
* @copyright Copyright © 2009, jTips * @license Commercial - See website for details * * @since 2.1 - 16/10/2008 * @version 2.1 * @package jTips * * Description: */ global $database, $jTips, $mainframe; require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/juser.class.php'; $my =& $mainframe->getUser(); $season_id = getSeasonID(); if (!$season_id or empty($my->id)) { jTipsRedirect('index.php?option=com_jtips&Itemid=' . jTipsGetParam($_REQUEST, 'Itemid')); } $jTipsUser = new jTipsUser($database); $parameters = array('user_id' => $my->id, 'season_id' => $season_id); $jTipsUser->loadByParams($parameters); if ($jTipsUser->exists()) { jTipsLogger::_log('removing user ' . $jTipsUser->id . ' from competition ' . $jTipsUser->season_id); $jTipsUser->destroy(); } $message = $jLang['_COM_UNSUBSCRIBE_SUCCESS']; //do we need to stop any paypal subscriptions? if ($jTips['Payments'] == 'paypal' and $jTips['PayPalIsSub'] and !empty($jTips['PayPalUnSub'])) { //Yes! redirect to paypal cancel page jTipsRedirect(stripslashes($jTips['PayPalUnSub']), $message); } else { jTipsRedirect('index.php?option=com_jtips&Itemid=' . jTipsGetParam($_REQUEST, 'Itemid') . '&season=' . $season_id, $message); }
jtips_HTML::title(); } jTips_HTML::expired(); /* * Load the current user object */ global $jTipsCurrentUser, $mainframe; $jTipsCurrentUser = new jTipsUser($database); if (jTipsGetParam($_REQUEST, 'user_id', false)) { $jTipsCurrentUser->load(jTipsGetParam($_REQUEST, 'user_id', false)); } else { $my =& $mainframe->getUser(); $parameters = array('season_id' => getSeasonID(), 'user_id' => $my->id); //BUG 219 - simplify user loading // BUG 348 - when somehow multiple users exist for the same competition, load only one. $usersArray = forceArray($jTipsCurrentUser->loadByParams($parameters)); if (!count($usersArray)) { $jTipsCurrentUser->loadByParams($parameters); } else { $jTipsCurrentUser = array_shift($usersArray); } unset($parameters); } if (jTipsGetParam($_REQUEST, 'menu', 1)) { $_REQUEST['season'] = $jTipsCurrentUser->season_id; $_GET['season'] = $jTipsCurrentUser->season_id; } $task = $task ? $task : 'Dashboard'; $view = jTipsGetParam($_REQUEST, 'view', 'Dashboard'); if (!$view) { $view = 'Dashboard';
$jTip = new jTip($database); $limitstart = jTipsGetParam($_REQUEST, 'limitstart', 0); $limit = jTipsGetParam($_REQUEST, 'limit', $jTips['NumMax']); $params = array('join' => array('type' => 'join', 'join_table' => '#__jtips_games', 'lhs_table' => '#__jtips_tips', 'lhs_key' => 'game_id', 'rhs_table' => '#__jtips_games', 'rhs_key' => 'id'), 'group' => array('type' => 'group', 'by' => 'round_id`, `user_id'), 'order' => array('type' => 'order', 'by' => 'round_id', 'direction' => 'DESC')); if ($user_id = jTipsGetParam($_REQUEST, 'user_id', false)) { $params['user_id'] = $user_id; } $jTipArray = forceArray($jTip->loadByParams($params, $limit, $limitstart)); unset($params['order']); $pageNav = new mosPageNav($jTip->getCount($params, true), $limitstart, $limit); $header = array('', 'User', 'Round', 'Season'); $data = array(); $i = 0; foreach ($jTipArray as $tip) { $tip->fillInAdditionalFields(); $data[$tip->id] = array(makeListLink($tip->user->getName(), $i++), $tip->round_num, $tip->season->name); } $jSeason = new jSeason($database); $jSeasons = forceArray($jSeason->loadByParams(array())); $seasons = objectsToSelectList($jSeasons, 'name'); $jTipsUser = new jTipsUser($database); $jTipsUsers = forceArray($jTipsUser->loadByParams(array())); foreach ($jTipsUsers as $u) { $u->name = $u->getName() . " (" . $seasons[$u->season_id] . ")"; $jTipsUsersArray[] = $u; } $users = objectsToSelectList($jTipsUsersArray, 'name'); asort($users); $formData = array('title' => $jLang['_ADMIN_DASH_TIPS_MANAGER'], 'editTask' => 'edit', 'module' => 'Tips', 'icon' => 'tips'); $filters = array($jLang['_ADMIN_USERS_SELECT'] => makeSelectList($users, 'user_id', "id='user_id' onChange='this.form.submit();'", jTipsGetParam($_REQUEST, 'user_id', '')), $jLang['_ADMIN_SEASON_SELECT'] => makeSelectList($seasons, 'season_id', "id='season_id' onChange='this.form.submit();'", jTipsGetParam($_REQUEST, 'season_id', ''))); jTipsAdminDisplay::ListView($formData, $header, $data, $pageNav, 'list', $filters);
//make a set of options for a select list $season_options = objectsToSelectList($jSeasons, 'name'); $filters = array('Select Season' => makeSelectList($season_options, 'season_id', "id='season_id' onChange='this.form.submit();'", $season_id)); //Load the Rounds if ($season_id) { $params = array('season_id' => $season_id); $jRound = new jRound($database); $jRounds = forceArray($jRound->loadByParams($params)); $round_options = objectsToSelectList($jRounds, 'round'); $filters['Select Round'] = makeSelectList($round_options, 'round_id', "id='round_id' onChange='this.form.submit();'", $round_id); } //Load the users if ($round_id and $season_id) { $params = array('season_id' => $season_id); $jTipsUser = new jTipsUser($database); $jTipsUsers = forceArray($jTipsUser->loadByParams($params)); $user_options = objectsToSelectList($jTipsUsers, 'getName', true); asort($user_options); $filters['Select User'] = makeSelectList($user_options, 'user_id', "id='user_id' onChange='this.form.submit();'", $user_id); } $tpl->selectLists = $filters; $data = array(); //Now we have the preliminary options, get the set of games if ($season_id and $round_id and $user_id) { $params = array('round_id' => $round_id); $jGame = new jGame($database); $jGames = forceArray($jGame->loadByParams($params)); foreach ($jGames as $game) { $params = array('game_id' => $game->id, 'user_id' => $user_id); $jTip = new jTip($database); $jTip->loadByParams($params);
$query = "SELECT id FROM #__jtips_seasons WHERE end_time > NOW() AND id <> " . $database->quote($season_id); $database->setQuery($query); $seasons = $database->loadResultArray(); if (!empty($seasons)) { foreach ($seasons as $other_season_id) { $jTipsUser->season_id = $other_season_id; $jTipsUser->id = null; $jTipsUser->save(); if ($jTips['UserNotifyEnable']) { $jTipsUser->sendNotificationEmail(''); } } } } $jTipsUserParams = array('user_id' => $my->id, 'season_id' => $season_id); $jTipsUser->loadByParams($jTipsUserParams); if ($jTips['AdminNotifyEnable']) { jTipsLogger::_log('preparing to send email notification to administration', 'INFO'); $variables = array(); $values = array(); foreach (get_object_vars($jTipsUser) as $key => $val) { if (is_string($key)) { array_push($variables, $key); $values[$key] = $val; } } foreach (get_object_vars($my) as $key => $val) { if (is_string($key)) { array_push($variables, $key); $values[$key] = $val; }