function replacePlayer($player_id, $new_seed) { global $sql; global $time; $error = 0; // Get player's old seed $q = "SELECT " . TBL_PLAYERS . ".*" . " FROM " . TBL_PLAYERS . " WHERE (" . TBL_PLAYERS . ".PlayerID = '{$player_id}')"; $result = $sql->db_Query($q); $old_seed = mysql_result($result, 0, TBL_PLAYERS . ".Seed"); echo "old_seed: {$old_seed}<br>"; // Find player_target $q = "SELECT " . TBL_PLAYERS . ".*" . " FROM " . TBL_PLAYERS . " WHERE (" . TBL_PLAYERS . ".Event = '" . $this->fields['EventID'] . "')" . " AND (" . TBL_PLAYERS . ".Seed = '{$new_seed}')"; $result = $sql->db_Query($q); $numPlayers = mysql_numrows($result); if ($numPlayers == 1) { $player_target_id = mysql_result($result, 0, TBL_PLAYERS . ".PlayerID"); echo "player_target_id: {$player_target_id}<br>"; $q_2 = "SELECT count(*) " . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . ", " . TBL_PLAYERS . " WHERE (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_MATCHS . ".Status = 'active')" . " AND ((" . TBL_PLAYERS . ".PlayerID = " . TBL_SCORES . ".Player)" . " OR ((" . TBL_PLAYERS . ".Team = " . TBL_SCORES . ".Team)" . " AND (" . TBL_PLAYERS . ".Team != 0)))" . " AND (" . TBL_PLAYERS . ".PlayerID = '{$player_target_id}')"; $result_2 = $sql->db_Query($q_2); $pmatches = mysql_result($result_2, 0); echo "pmatches: {$pmatches}<br>"; if ($pmatches > 0) { // Cannot switch with a player_target who has played already ??? $error = 1; } else { // Delete player_target matches // And then change his seed. deletePlayerMatches($player_target_id); // Update player's seed $q = "UPDATE " . TBL_PLAYERS . " SET Seed = '" . $old_seed . "' WHERE (PlayerID = '" . $player_target_id . "')"; $sql->db_Query($q); } } if ($error == 0) { // Update player's seed $q = "UPDATE " . TBL_PLAYERS . " SET Seed = '" . $new_seed . "' WHERE (PlayerID = '" . $player_id . "')"; $sql->db_Query($q); if ($this->getField('FixturesEnable') == TRUE && $this->getField('Status') == 'active') { $this->brackets(true); } $this->setFieldDB('IsChanged', 1); } return $error; }
header("Location: eventmanage.php?eventid={$event_id}"); exit; } if (isset($_POST['kick_player']) && $_POST['kick_player'] != "") { $playerid = $_POST['kick_player']; deletePlayer($playerid); if ($event->getField('FixturesEnable') == TRUE && $event->getField('Status') == 'active') { $event->brackets(true); } updateStats($event_id, $time, TRUE); header("Location: eventmanage.php?eventid={$event_id}"); exit; } if (isset($_POST['del_player_games']) && $_POST['del_player_games'] != "") { $playerid = $_POST['del_player_games']; deletePlayerMatches($playerid); if ($event->getField('FixturesEnable') == TRUE) { $event->brackets(true); } updateStats($event_id, $time, TRUE); header("Location: eventmanage.php?eventid={$event_id}"); exit; } if (isset($_POST['del_player_awards']) && $_POST['del_player_awards'] != "") { $playerid = $_POST['del_player_awards']; deletePlayerAwards($playerid); header("Location: eventmanage.php?eventid={$event_id}"); exit; } if (isset($_POST['checkin_player']) && $_POST['checkin_player'] != "") { $playerid = $_POST['checkin_player'];