function OnLoadPageData() { /* @var $match_manager MatchManager */ /* @var $editor MatchEditControl */ # get id of Match $i_id = $this->match_manager->GetItemId(); if ($i_id) { # Get details of match but, if invalid, don't replace submitted details with saved ones if ($this->IsValid()) { $this->match_manager->ReadByMatchId(array($i_id)); $this->match_manager->ExpandMatchScorecards(); $this->match = $this->match_manager->GetFirst(); if ($this->match instanceof Match) { $this->b_user_is_match_owner = AuthenticationManager::GetUser()->GetId() == $this->match->GetAddedBy()->GetId(); $this->b_is_tournament = $this->match->GetMatchType() == MatchType::TOURNAMENT; } } unset($this->match_manager); # get all competitions if user has permission to change the season if ($this->b_user_is_match_admin) { require_once 'stoolball/competition-manager.class.php'; $o_comp_manager = new CompetitionManager($this->GetSettings(), $this->GetDataConnection()); $o_comp_manager->ReadAllSummaries(); $this->editor->SetSeasons(CompetitionManager::GetSeasonsFromCompetitions($o_comp_manager->GetItems())); unset($o_comp_manager); } if ($this->b_user_is_match_admin or $this->b_user_is_match_owner) { # get all teams $season_ids = array(); if ($this->match instanceof Match) { foreach ($this->match->Seasons() as $season) { $season_ids[] = $season->GetId(); } } require_once 'stoolball/team-manager.class.php'; $o_team_manager = new TeamManager($this->GetSettings(), $this->GetDataConnection()); if ($this->match instanceof Match and $this->match->GetMatchType() == MatchType::TOURNAMENT_MATCH) { $o_team_manager->FilterByTournament(array($this->match->GetTournament()->GetId())); $o_team_manager->FilterByTeamType(array()); # override default to allow all team types $o_team_manager->ReadTeamSummaries(); } else { if ($this->b_user_is_match_admin or !count($season_ids) or $this->match->GetMatchType() == MatchType::FRIENDLY) { $o_team_manager->ReadById(); # we need full data on the teams to get the seasons they are playing in; } else { # If the user can't change the season, why let them select a team that's not in the season? $o_team_manager->ReadBySeasonId($season_ids); } } $this->editor->SetTeams(array($o_team_manager->GetItems())); unset($o_team_manager); # get all grounds require_once 'stoolball/ground-manager.class.php'; $o_ground_manager = new GroundManager($this->GetSettings(), $this->GetDataConnection()); $o_ground_manager->ReadAll(); $this->editor->SetGrounds($o_ground_manager->GetItems()); unset($o_ground_manager); } } # Tournament or match not found is page not found if (!$this->match instanceof Match or $this->b_is_tournament) { http_response_code(404); $this->page_not_found = true; } }