function OnLoadPageData() { /* @var $match_manager MatchManager */ /* @var $editor TournamentEditControl */ # get id of Match $i_id = $this->match_manager->GetItemId(); if (!$i_id) { return; } # no need to read if redisplaying invalid form if ($this->IsValid()) { $this->match_manager->ReadByMatchId(array($i_id)); $this->tournament = $this->match_manager->GetFirst(); if ($this->tournament instanceof Match) { $this->b_user_is_match_owner = AuthenticationManager::GetUser()->GetId() == $this->tournament->GetAddedBy()->GetId(); $this->b_is_tournament = $this->tournament->GetMatchType() == MatchType::TOURNAMENT; } else { return; } } if ($this->b_user_is_match_admin or $this->b_user_is_match_owner) { # Get all seasons # Don't filter by match type at this point because we want to know what other types of match the seasons support. # If it's tournaments only, they'll be treated differently. require_once 'stoolball/season-manager.class.php'; $season_manager = new SeasonManager($this->GetSettings(), $this->GetDataConnection()); $season_dates = Season::SeasonDates($this->tournament->GetStartTime()); $season_manager->FilterByDateStart($season_dates[0]); $season_manager->FilterByDateEnd($season_dates[1]); $season_manager->ReadSeasonSummaries(array($this->tournament->GetPlayerType())); $this->editor->Seasons()->SetItems($season_manager->GetItems()); unset($season_manager); } }
function OnLoadPageData() { # get match if (!is_object($this->match)) { $i_id = $this->manager->GetItemId($this->match); if ($i_id) { $this->manager->ReadByMatchId(array($i_id)); $this->match = $this->manager->GetFirst(); } } # tidy up unset($this->manager); if (is_object($this->match) and $this->match->GetMatchType() == MatchType::TOURNAMENT) { $this->match_or_tournament = 'tournament'; } }
function OnLoadPageData() { /* @var $match_manager MatchManager */ /* @var $editor TournamentEditControl */ # get id of Match $i_id = $this->match_manager->GetItemId(); if (!$i_id) { return; } # no need to read if redisplaying invalid form if ($this->IsValid()) { $this->match_manager->ReadByMatchId(array($i_id)); $this->tournament = $this->match_manager->GetFirst(); if ($this->tournament instanceof Match) { $this->b_user_is_match_owner = AuthenticationManager::GetUser()->GetId() == $this->tournament->GetAddedBy()->GetId(); $this->b_is_tournament = $this->tournament->GetMatchType() == MatchType::TOURNAMENT; } else { return; } } if ($this->b_user_is_match_admin or $this->b_user_is_match_owner) { # 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->Grounds()->SetItems($o_ground_manager->GetItems()); unset($o_ground_manager); # get teams in seasons, in order to promote home grounds of teams $season_ids = array(); foreach ($this->tournament->Seasons() as $season) { $season_ids[] = $season->GetId(); } require_once 'stoolball/team-manager.class.php'; $team_manager = new TeamManager($this->GetSettings(), $this->GetDataConnection()); if (count($season_ids)) { $team_manager->ReadBySeasonId($season_ids); $this->editor->ProbableTeams()->SetItems($team_manager->GetItems()); } unset($team_manager); } }
function OnLoadPageData() { /* @var $match_manager MatchManager */ /* @var $editor TournamentMatchesControl */ # get id of Match $i_id = $this->match_manager->GetItemId(); if (!$i_id) { return; } # no need to read if redisplaying invalid form if ($this->IsValid()) { $this->match_manager->ReadByMatchId(array($i_id)); $this->tournament = $this->match_manager->GetFirst(); if ($this->tournament instanceof Match) { $this->b_is_tournament = $this->tournament->GetMatchType() == MatchType::TOURNAMENT; } else { return; } } }
function OnLoadPageData() { /* @var $match_manager MatchManager */ # get id of Match $i_id = $this->match_manager->GetItemId(); # Get details of match but, if invalid, don't replace submitted details with saved ones if ($i_id and $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); # Tournament or match in the future or not played is page not found $editable_results = array(MatchResult::UNKNOWN, MatchResult::HOME_WIN, MatchResult::AWAY_WIN, MatchResult::TIE, MatchResult::ABANDONED); if (!$this->match instanceof Match or $this->b_is_tournament or $this->match->GetStartTime() > gmdate('U') or !in_array($this->match->Result()->GetResultType(), $editable_results)) { http_response_code(404); $this->page_not_found = true; } }
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; } }