} else { $message = 'Save Failed: ' . $jRound->_error; } $games = jTipsGetParam($_REQUEST, 'game', array()); for ($i = 0; $i < count($games); $i++) { $jGame = new jGame($database); if (jTipsGetParam($_REQUEST, 'id', false)) { $game_id = jTipsGetParam($games, $i, -1); $jGame->load($game_id); $newRound = false; } else { $newRound = true; //BUG 253 - save past rounds easily } $jGame->round_id = $jRound->id; if ($jRound->getStatus() === false or $newRound) { $jGame->home_id = jTipsGetParam($_REQUEST['home_id'], $i, -1); $jGame->away_id = jTipsGetParam($_REQUEST['away_id'], $i, -1); $jGame->position = jTipsGetParam($_REQUEST['position'], $i, null); } if ($jSeason->pick_score == 1 and jTipsGetParam($_REQUEST['has_score'], $i, false)) { $jGame->has_score = 1; } else { if ($jRound->getStatus() === false) { $jGame->has_score = 0; } } if ($jSeason->pick_margin == 1 and jTipsGetParam($_REQUEST['has_margin'], $i, false)) { $jGame->has_margin = 1; } else { if ($jRound->getStatus() === false) {
jTipsSpoofCheck(); global $mosConfig_absolute_path, $database, $jTips, $jTipsCurrentUser, $jLang, $Itemid; require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/jcomment.class.php'; require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/jgame.class.php'; require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/jround.class.php'; require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/jseason.class.php'; require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/jtip.class.php'; jTipsLogger::_log('about to start saving tips'); //TODO: remove this if (empty($jTipsCurrentUser->id)) { die('No jTips User!'); } $jRound = new jRound($database); $jRound->load(jTipsGetParam($_REQUEST, 'round_id', 0)); // BUG 389 - Can save tips by hacking HTML with Firebug if (!$jRound->id or $jRound->getStatus() !== false) { // trying to post to an invalid round or round in progress jTipsRedirect('index.php?option=com_jtips&Itemid=' . $Itemid, $jLang['_COM_CANNOT_POST_CLOSED']); exit; } $jSeason = new jSeason($database); $jSeason->load($jRound->season_id); $jGame = new jGame($database); $jGameParams = array('round_id' => $jRound->id); $jGames = forceArray($jGame->loadByParams($jGameParams)); $myTips = array(); $isUpdate = null; foreach ($jGames as $jGame) { $game_id = 'game' . $jGame->id; jTipsLogger::_log('saving tips for game ' . $jGame->id); $jTip = new jTip($database);
$jRound = new jRound($database); if ($round_id == false) { $complete = 0; while ($complete !== 1) { $tempRound = new jRound($database); if ($round_id == false) { $round_id = $jSeason->getCurrentRound(); } $tempRound->load($round_id); $round_id = $tempRound->getPrev(); if (!is_numeric($round_id)) { break; } $jRound = new jRound($database); $jRound->load($round_id); $complete = $jRound->getStatus(); } } $jRound->load($round_id); $render->assign('jRound', $jRound); $jGameParams = array('round_id' => $jRound->id); $jGame = new jGame($database); $jGames = forceArray($jGame->loadByParams($jGameParams)); $render->assign('jGames', $jGames); //should columns be hidden? $hideRaw = jTipsGetParam($_REQUEST, 'hide'); if ($hideRaw) { //BUG 231 - Add a fallback in case we are using PHP < 5.2.0 if (!function_exists('json_decode')) { $hideColumns = array('result', 'actual', 'awarded'); } else {
sort($seasons); $rounds_to_process = array(); foreach ($seasons as $sid) { ksort($rounds[$sid]); $rounds_to_process = array_merge($rounds_to_process, $rounds[$sid]); } jTipsLogger::_log("round order now fixed (bug 58)"); // // END BUG 58 Fix //////////////////////////////////////////////////// $skippedRounds = $processedRounds = 0; foreach ($rounds_to_process as $id) { //clearHistory($id); $jRound = new jRound($database); $jRound->load($id); //make sure we only process rounds that are pending results if (!$jRound->getStatus()) { $skippedRounds++; jTipsLogger::_log('failed to process this round (' . $jRound->id . ')... it hasnt finished yet! STATUS: ' . $jRound->getStatus()); continue; } if ($jRound->process()) { $processedRounds++; } else { $skippedRounds++; } } $message = $processedRounds . " / " . count($cid) . " " . $jLang['_ADMIN_ROUND_PROCESSED']; //jTipsDebug($message); jTipsLogger::_log($message); mosRedirect('index2.php?option=com_jtips&task=list&module=Rounds', $message);