Exemplo n.º 1
0
                    // this is a bye
                    $jGame->winner_id = null;
                } else {
                    $jGame->winner_id = -1;
                    $jGame->draw = 1;
                }
            }
        }
        // BUG 401 - should be able to set the bonus points without allowing users to pick the bonus result
        if (jTipsGetParam($_REQUEST['bonus_id'], $i, false)) {
            $jGame->bonus_id = jTipsGetParam($_REQUEST['bonus_id'], $i, null);
        }
    }
    // set the description if we have one
    $jGame->description = strip_tags(jTipsGetParam($_REQUEST['description'], $i, ''));
    if ($jGame->save()) {
        $games_to_keep[] = $jGame->id;
        $results[] = 1;
    } else {
        $results[] = 0;
    }
}
$message = "Saved " . array_sum($results) . "/" . count($results) . " Games";
//Delete games that have been removed by unchecking them
$jGame = new jGame($database);
$params = array('round_id' => $jRound->id, 'id' => array('type' => 'query', 'query' => " NOT IN ('" . implode("', '", $games_to_keep) . "')"));
$jGames = forceArray($jGame->loadByParams($params));
$deleted = 0;
foreach ($jGames as $oldGame) {
    $oldGame->destroy();
    $deleted++;
Exemplo n.º 2
0
$id = jTipsGetParam($_REQUEST, 'id', false);
if (!$id or !is_numeric($id)) {
    // BUG 373 - Round fails to copy
    jTipsLogger::_log('No round id specified to copy!', 'ERROR');
    mosRedirect('index2.php?option=com_jtips&task=list&module=Rounds', $jLang['_ADMIN_ROUND_COPY_FAIL']);
}
$focus = new jRound($database);
$focus->load($id);
$focus->id = null;
$focus->round = jTipsGetParam($_REQUEST, 'round', '');
$focus->scored = 0;
if (!$focus->round) {
    jTipsLogger::_log('No Round number entered when copying round, determine next one.', 'ERROR');
    $query = "SELECT MAX(round)+1 AS nextround FROM #__jtips_rounds WHERE season_id = '" . $focus->season_id . "'";
    $database->setQuery($query);
    $focus->round = $database->loadResult();
}
$focus->save();
$query = "SELECT id FROM #__jtips_games WHERE round_id = '" . $database->getEscaped($id) . "'";
$database->setQuery($query);
$game_ids = $database->loadResultArray();
if (!empty($game_ids)) {
    foreach ($game_ids as $gid) {
        $jGame = new jGame($database);
        $jGame->load($gid);
        $jGame->round_id = $focus->id;
        $jGame->id = null;
        $jGame->save();
    }
}
mosRedirect('index2.php?option=com_jtips&task=list&module=Rounds', $jLang['_ADMIN_ROUND_COPY_SUCCESS']);