Skip to content

Instantly share code, notes, and snippets.

@thewheat
Created October 3, 2013 12:31
Show Gist options
  • Select an option

  • Save thewheat/6809082 to your computer and use it in GitHub Desktop.

Select an option

Save thewheat/6809082 to your computer and use it in GitHub Desktop.
Support for custom number of fixtures. Caveat: disables checking of proper number of fixtures for all leagues. Should work with https://github.com/thewheat/PHPLeague-for-WP/commit/0c47e97739d24a9b5e7b065b4ae85bf72ce6a24a Add to your existing files Lines ending with "// added for custom number of fixtures" Lines between "// new code - 1" and "// …
// new code - 1
if (isset($_POST['fixtures_add']) && check_admin_referer('phpleague'))
{
$nb_fixtures = $db->nb_fixtures_league($id_league);
$db->add_fixtures_league($nb_fixtures+1, $id_league);
}
if (isset($_POST['fixtures_delete']) && check_admin_referer('phpleague'))
{
$nb_fixtures = $db->nb_fixtures_league($id_league);
$db->remove_fixtures_league($id_league, $nb_fixtures);
}
// new code - 0
// Odd number of teams is probably not desired...
...
// Security check
if ($nb_fixtures != $fixtures_number && false) // added false for custom number of fixtures // new code
{
...
$output .= '<div class="tablenav top"><div class="alignleft actions">'.$fct->input('fixtures', __('Save', 'phpleague'), array('type' => 'submit', 'class' => 'button')).'</div></div>';
// new code - 1
$output .= '<div class="tablenav top">';
$output .= '<div class="alignleft actions">'.$fct->input('fixtures_add', __('Add Fixtures', 'phpleague'), array('type' => 'submit', 'class' => 'button')).'</div>';
$output .= '<div class="alignleft actions">'.$fct->input('fixtures_delete', __('Delete last fixture', 'phpleague'), array('type' => 'submit', 'class' => 'button', 'onclick'=> 'return confirm("' . __('Delete last fixture?', 'phpleague') . '")')).'</div>';
$output .= '</div>';
// new code - 0
// Check what kind of fixtures we are dealing with (odd/even)
if (($nb_teams % 2) != 0)
{
$nb_fixtures = $nb_teams * $nb_legs;
$nb_matches = ($nb_teams - 1) / 2;
}
else
{
$nb_fixtures = ($nb_teams * $nb_legs) - $nb_legs;
$nb_matches = ($nb_teams / 2);
}
// new code - 1
$nb_fixtures = $db->nb_fixtures_league($id_league); // added for custom number of fixtures
// new code - 0
// Data processing...
// Check what kind of number we have (odd/even)
if (($nb_teams % 2) != 0)
$nb_fixtures = $nb_teams * $nb_legs;
else
$nb_fixtures = ($nb_teams * $nb_legs) - $nb_legs;
// new code - 1
$nb_fixtures = $db->nb_fixtures_league($id_league); // added for custom number of fixtures
// new code - 0
// If the player mod is enabled, we show the toggle button
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment