public function OnPageInit() { # Get team to display players for if (!isset($_GET['player']) or !is_numeric($_GET['player'])) { $this->Redirect(); } $this->player = new Player($this->GetSettings()); $this->player->SetId($_GET['player']); }
public function OnPageInit() { header("Content-Type: application/javascript"); # Get team to display players for if (!isset($_GET['player']) or !is_numeric($_GET['player'])) { $this->Redirect(); } $this->player = new Player($this->GetSettings()); $this->player->SetId($_GET['player']); }
public function OnPageInit() { # Create the editor and manager $this->player_manager = new PlayerManager($this->GetSettings(), $this->GetDataConnection()); $this->editor = new PlayerEditor($this->GetSettings()); $this->editor->SetAllowCancel(true); $this->RegisterControlForValidation($this->editor); # Get player to edit $this->player = new Player($this->GetSettings()); $this->player->SetId($this->player_manager->GetItemId()); # If the team parameter is passed, that's a request to create a new player in a team if (isset($_GET['team']) and is_numeric($_GET['team'])) { $this->player->Team()->SetId($_GET['team']); } }
/** * @return void * @desc Re-build from data posted by this control the data object this control is editing */ public function BuildPostedDataObject() { $player = new Player($this->GetSettings()); $key = $this->GetNamingPrefix() . 'item'; if (isset($_POST[$key])) { $player->SetId($this->GetNamingPrefix() . $_POST[$key]); } $key = $this->GetNamingPrefix() . 'Name'; if (isset($_POST[$key])) { $player->SetName($this->GetNamingPrefix() . $_POST[$key]); } $this->SetDataObject($player); $key = $this->GetNamingPrefix() . "MergeOptions"; if (isset($_POST[$key]) and $_POST[$key] == "1") { $this->merge_requested = true; } }
/** * @access public * @return void * @param int[] $player_ids * @desc Delete from the database the players matching the supplied ids */ public function Delete($player_ids) { # check parameter $this->ValidateNumericArray($player_ids); # Get tables $players = $this->GetSettings()->GetTable('Player'); $matches = $this->GetSettings()->GetTable("Match"); $batting = $this->GetSettings()->GetTable("Batting"); $bowling = $this->GetSettings()->GetTable("Bowling"); $stats = $this->GetSettings()->GetTable('PlayerMatch'); $player_id_list = implode(', ', $player_ids); # delete from short URL cache require_once 'http/short-url-manager.class.php'; $o_url_manager = new ShortUrlManager($this->GetSettings(), $this->GetDataConnection()); $sql = "SELECT short_url FROM {$players} WHERE player_id IN ({$player_id_list})"; $result = $this->GetDataConnection()->query($sql); while ($row = $result->fetch()) { $o_url_manager->Delete($row->short_url); } $result->closeCursor(); unset($o_url_manager); # remove player of the match awards $sql = "UPDATE {$matches} SET player_of_match_id = NULL WHERE player_of_match_id IN ({$player_id_list})"; $this->LoggedQuery($sql); $sql = "UPDATE {$matches} SET player_of_match_home_id = NULL WHERE player_of_match_home_id IN ({$player_id_list})"; $this->LoggedQuery($sql); $sql = "UPDATE {$matches} SET player_of_match_away_id = NULL WHERE player_of_match_away_id IN ({$player_id_list})"; $this->LoggedQuery($sql); # Reassign batting and bowling to 'unknown' player $unknown_player = new Player($this->GetSettings()); $unknown_player->SetName("Unknown"); foreach ($player_ids as $player_id) { $sql = "SELECT team_id FROM {$players} WHERE player_id = " . Sql::ProtectNumeric($player_id); $result = $this->GetDataConnection()->query($sql); $row = $result->fetch(); $unknown_player->Team()->SetId($row->team_id); $unknown_player->SetId($this->SaveOrMatchPlayer($unknown_player)); $player = new Player($this->GetSettings()); $player->SetId($player_id); $this->is_internal_delete = true; $this->MergePlayers($player, $unknown_player); $this->is_internal_delete = false; } # Delete statistics $sql = "DELETE FROM {$stats} WHERE player_id IN ({$player_id_list})"; $this->LoggedQuery($sql); # delete the player $sql = "DELETE FROM {$players} WHERE player_id IN ({$player_id_list})"; $this->LoggedQuery($sql); }
/** * Helper to build basic info about a match from raw data * * @param Match $match * @param DataRow $row */ private function BuildMatchSummary(Match $match, $row) { $match->SetId($row->match_id); if (isset($row->start_time)) { $match->SetStartTime($row->start_time); } if (isset($row->start_time_known)) { $match->SetIsStartTimeKnown($row->start_time_known); } if (isset($row->match_type)) { $match->SetMatchType($row->match_type); } if (isset($row->player_type_id)) { $match->SetPlayerType($row->player_type_id); } if (isset($row->qualification)) { $match->SetQualificationType($row->qualification); } if (isset($row->players_per_team)) { $match->SetMaximumPlayersPerTeam($row->players_per_team); } if (isset($row->max_tournament_teams)) { $match->SetMaximumTeamsInTournament($row->max_tournament_teams); } if (isset($row->tournament_spaces)) { $match->SetSpacesLeftInTournament($row->tournament_spaces); } if (isset($row->overs_per_innings)) { $match->SetOvers($row->overs_per_innings); } if (isset($row->match_title)) { $match->SetTitle($row->match_title); } if (isset($row->custom_title)) { $match->SetUseCustomTitle($row->custom_title); } if (isset($row->home_bat_first) and !is_null($row->home_bat_first)) { $match->Result()->SetHomeBattedFirst($row->home_bat_first); } if (isset($row->won_toss) and !is_null($row->won_toss)) { $match->Result()->SetTossWonBy($row->won_toss); } if (isset($row->home_runs)) { $match->Result()->SetHomeRuns($row->home_runs); } if (isset($row->home_wickets)) { $match->Result()->SetHomeWickets($row->home_wickets); } if (isset($row->away_runs)) { $match->Result()->SetAwayRuns($row->away_runs); } if (isset($row->away_wickets)) { $match->Result()->SetAwayWickets($row->away_wickets); } if (isset($row->home_points)) { $match->Result()->SetHomePoints($row->home_points); } if (isset($row->away_points)) { $match->Result()->SetAwayPoints($row->away_points); } if (isset($row->player_of_match_id)) { $player = new Player($this->GetSettings()); $player->SetId($row->player_of_match_id); $player->SetName($row->player_of_match); $player->SetShortUrl($row->player_of_match_url); $player->Team()->SetId($row->player_of_match_team_id); $match->Result()->SetPlayerOfTheMatch($player); } if (isset($row->player_of_match_home_id)) { $player = new Player($this->GetSettings()); $player->SetId($row->player_of_match_home_id); $player->SetName($row->player_of_match_home); $player->SetShortUrl($row->player_of_match_home_url); $player->Team()->SetId($row->player_of_match_home_team_id); $match->Result()->SetPlayerOfTheMatchHome($player); } if (isset($row->player_of_match_away_id)) { $player = new Player($this->GetSettings()); $player->SetId($row->player_of_match_away_id); $player->SetName($row->player_of_match_away); $player->SetShortUrl($row->player_of_match_away_url); $player->Team()->SetId($row->player_of_match_away_team_id); $match->Result()->SetPlayerOfTheMatchAway($player); } if (isset($row->match_notes)) { $match->SetNotes($row->match_notes); } if (isset($row->short_url)) { $match->SetShortUrl($row->short_url); } if (isset($row->update_search) and $row->update_search == 1) { $match->SetSearchUpdateRequired(); } if (isset($row->added_by) and is_numeric($row->added_by)) { $match->SetAddedBy(new User($row->added_by)); } if (isset($row->match_result_id)) { $match->Result()->SetResultType($row->match_result_id); } if (isset($row->date_changed)) { $match->SetLastAudit(new AuditData($row->modified_by_id, $row->known_as, $row->date_changed)); } }
/** * Read when and how often a player has played */ public function ReadPlayerSummary() { $from = $this->FromFilteredPlayerStatistics() . " INNER JOIN nsa_team AS team ON nsa_player_match.team_id = team.team_id "; $where = ""; $where = $this->ApplyFilters($where); if ($where) { $where = "WHERE " . substr($where, 3, strlen($where) - 3); } $sql = "SELECT player_id, player_name, player_role, player_url,\r\n\t\tteam.team_id, team.team_name, team.short_url AS team_short_url,\r\n\t\tCOUNT(nsa_player_match.match_id) AS total_matches, MIN(nsa_player_match.match_time) AS first_played, MAX(nsa_player_match.match_time) AS last_played\r\n\t\t{$from}\r\n\t\t{$where}\r\n\t\tGROUP BY nsa_player_match.player_id\r\n\t\tORDER BY player_name ASC"; $data = array(); $result = $this->GetDataConnection()->query($sql); if (!$this->GetDataConnection()->isError()) { while ($row = $result->fetch()) { $player = new Player($this->GetSettings()); $player->SetId($row->player_id); $player->SetName($row->player_name); if (isset($row->total_matches)) { $player->SetTotalMatches($row->total_matches); } if (isset($row->first_played)) { $player->SetFirstPlayedDate($row->first_played); } if (isset($row->last_played)) { $player->SetLastPlayedDate($row->last_played); } if (isset($row->player_role)) { $player->SetPlayerRole($row->player_role); } if (isset($row->player_url)) { $player->SetShortUrl($row->player_url); } $player->Team()->SetId($row->team_id); $player->Team()->SetName($row->team_name); if (isset($row->team_short_url)) { $player->Team()->SetShortUrl($row->team_short_url); } $data[] = $player; } } $result->closeCursor(); unset($result); return $data; }