} if ($is_complete) { dbQuery("DELETE FROM `{$cfg['db_table_prefix']}deadlines` WHERE `id_season` = {$season['id']}"); $deadline = $_REQUEST['startdate']; // Q if ($season['qualification']) { dbQuery("INSERT INTO `{$cfg['db_table_prefix']}deadlines` (`round`, `deadline`, `id_season`) " . "VALUES ('q0', '{$deadline}', {$season['id']})"); $deadline = addDaysToDate($deadline, $_REQUEST['wb_round_length']); dbQuery("INSERT INTO `{$cfg['db_table_prefix']}deadlines` (`round`, `deadline`, `id_season`) " . "VALUES ('q1', '{$deadline}', {$season['id']})"); } // Wb dbQuery("INSERT INTO `{$cfg['db_table_prefix']}deadlines` (`round`, `deadline`, `id_season`) " . "VALUES ('wb0', '{$deadline}', {$season['id']})"); for ($i = 1; $i <= getNumWBRounds($season); $i++) { $deadline = addDaysToDate($deadline, $_REQUEST['wb_round_length']); dbQuery("INSERT INTO `{$cfg['db_table_prefix']}deadlines` (`round`, `deadline`, `id_season`) " . "VALUES ('wb{$i}', '{$deadline}', {$season['id']})"); if ($i == getNumWBRounds($season) - getNumLBRounds($season) / 2) { $lb_startdate = $deadline; } } // Lb if ($season['double_elimination'] != "") { $deadline = $lb_startdate; dbQuery("INSERT INTO `{$cfg['db_table_prefix']}deadlines` (`round`, `deadline`, `id_season`) " . "VALUES ('lb0', '{$deadline}', {$season['id']})"); for ($i = 1; $i <= getNumLBRounds($season); $i++) { if ($i == 1) { $deadline = addDaysToDate($deadline, $_REQUEST['wb_round_length']); } elseif (1 & $i) { $deadline = addDaysToDate($deadline, $_REQUEST['wb_round_length'] - $_REQUEST['lb_round_length']); } else { $deadline = addDaysToDate($deadline, $_REQUEST['lb_round_length']); }
$content_tpl->set_block("F_CONTENT", "B_ADD_DEADLINE", "H_ADD_DEADLINE"); // Access for headadmins only if ($user['usertype_headadmin']) { if ($season['qualification'] == 1) { $content_tpl->set_var("I_ROUND", 0); $content_tpl->parse("H_ADD_Q_ROUND", "B_ADD_Q_ROUND", true); $content_tpl->set_var("I_ROUND", 1); $content_tpl->parse("H_ADD_Q_ROUND", "B_ADD_Q_ROUND", true); } if ($season['single_elimination'] == "") { $content_tpl->parse("H_WARNING_TOURNEY_SYSTEM", "B_WARNING_TOURNEY_SYSTEM"); $content_tpl->parse("H_WARNING", "B_WARNING"); $content_tpl->set_var("I_ID_SEASON", $season['id']); $content_tpl->parse("H_BACK_OVERVIEW", "B_BACK_OVERVIEW"); } else { for ($i = 0; $i <= getNumWBRounds($season); $i++) { $content_tpl->set_var("I_ROUND", $i); $content_tpl->parse("H_ADD_WB_ROUND", "B_ADD_WB_ROUND", true); } for ($i = 0; $i <= getNumLBRounds($season); $i++) { $content_tpl->set_var("I_ROUND", $i); $content_tpl->parse("H_ADD_LB_ROUND", "B_ADD_LB_ROUND", true); } $content_tpl->set_var("I_ROUND", 0); $content_tpl->parse("H_ADD_GF_ROUND", "B_ADD_GF_ROUND", true); $content_tpl->set_var("I_ROUND", 1); $content_tpl->parse("H_ADD_GF_ROUND", "B_ADD_GF_ROUND", true); $content_tpl->set_var("I_ID_SEASON", $season['id']); $content_tpl->parse("H_ADD_DEADLINE", "B_ADD_DEADLINE"); } } else {
$content_tpl->set_block("F_CONTENT", "B_LB_UNPLAYED_MATCH", "H_LB_UNPLAYED_MATCH"); $content_tpl->set_block("F_CONTENT", "B_LB_WO_MATCH", "H_LB_WO_MATCH"); $content_tpl->set_block("F_CONTENT", "B_LB_BYE_MATCH", "H_LB_BYE_MATCH"); $content_tpl->set_block("F_CONTENT", "B_LB_OUT_MATCH", "H_LB_OUT_MATCH"); $content_tpl->set_block("F_CONTENT", "B_LB_EMPTY_MATCH", "H_LB_EMPTY_MATCH"); $content_tpl->set_block("F_CONTENT", "B_LB_PLAYER1", "H_LB_PLAYER1"); $content_tpl->set_block("F_CONTENT", "B_LB_PLAYER2", "H_LB_PLAYER2"); $content_tpl->set_block("F_CONTENT", "B_LOSERS_BRACKET", "H_LOSERS_BRACKET"); if ($season['status'] == "bracket" or $season['status'] == "running" or $season['status'] == "finished") { if ($_REQUEST['opt'] == "") { $_REQUEST['opt'] = "wb"; } if ($_REQUEST['opt'] == "wb") { // WB // Set the wb_round names $num_wb_rounds = getNumWBRounds($season); for ($i = 0; $i <= $num_wb_rounds; ++$i) { $counter_wb_player[$i] = 0; $counter_wb_match[$i] = 1; $content_tpl->set_var("I_ROUND", $i + 1); // Deadline $content_tpl->set_var("H_WB_ACTUAL_ROUND", ""); $content_tpl->set_var("H_WB_DEADLINE", ""); $wb_round = $i + 1; $deadline_ref = dbQuery("SELECT * FROM `{$cfg['db_table_prefix']}deadlines` " . "WHERE `id_season` = {$season['id']} AND `round` = 'wb{$wb_round}'"); if ($deadline_row = dbFetch($deadline_ref)) { if (isAfterPreDeadline($season, "wb", $i + 1) and isBeforePostDeadline($season, "wb", $i + 1)) { $content_tpl->parse("H_WB_ACTUAL_ROUND", "B_WB_ACTUAL_ROUND"); } $content_tpl->set_var("I_DEADLINE", htmlspecialchars($deadline_row['deadline'])); $content_tpl->parse("H_WB_DEADLINE", "B_WB_DEADLINE");
function getNextWinnerPlayer(&$match) { global $season; if ($match['bracket'] == "q") { return "player2"; } elseif ($match['bracket'] == "wb" and $match['round'] < getNumWBRounds($season)) { if (1 & $match['match']) { return "player1"; } else { return "player2"; } } elseif ($match['bracket'] == "wb" and $match['round'] == getNumWBRounds($season) and $season['double_elimination'] != "") { return "player1"; } elseif ($match['bracket'] == "lb" and $match['round'] < getNumLBRounds($season)) { if (1 & $match['round']) { return "player2"; } else { if (1 & $match['match']) { return "player1"; } else { return "player2"; } } } elseif ($match['bracket'] == "lb" and $match['round'] == getNumLBRounds($season)) { return "player2"; } elseif ($match['bracket'] == "gf" and $match['id_player2'] == winnerOf($match)) { return "player2"; } }