function OnLoadPageData() { # new data manager $o_comp_manager = new CompetitionManager($this->GetSettings(), $this->GetDataConnection()); # get competitions $o_comp_manager->SetExcludeInactive(!AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_COMPETITIONS)); $o_comp_manager->ReadCompetitionsInCategories(); $this->competitions = $o_comp_manager->GetItems(); # tidy up unset($o_comp_manager); }
function OnLoadPageData() { require_once "stoolball/team-manager.class.php"; $team_manager = new TeamManager($this->GetSettings(), $this->GetDataConnection()); $team_manager->FilterByActive(true); $team_manager->ReadById(); $this->teams = $team_manager->GetItems(); require_once "stoolball/competition-manager.class.php"; $comp_manager = new CompetitionManager($this->GetSettings(), $this->GetDataConnection()); $comp_manager->SetExcludeInactive(true); $comp_manager->ReadById(); $this->competitions = $comp_manager->GetItems(); }
function OnLoadPageData() { require_once 'stoolball/competition-manager.class.php'; $comp_manager = new CompetitionManager($this->GetSettings(), $this->GetDataConnection()); $comp_manager->ReadCompetitionsInCategories(array(17, 33, 45, 61, 62, 72, 73)); $competitions = $comp_manager->GetItems(); unset($comp_manager); $season_ids = array(); foreach ($competitions as $competition) { /*@var $competition Competition */ $season = $competition->GetLatestSeason(); $season_ids[] = $season->GetId(); } # Fixtures require_once 'stoolball/match-manager.class.php'; $match_manager = new MatchManager($this->GetSettings(), $this->GetDataConnection()); $match_manager->FilterByMaximumResults(5); $match_manager->FilterByDateStart(gmdate('U')); $match_manager->ReadBySeasonId($season_ids); $this->matches = $match_manager->GetItems(); unset($match_manager); # Get stats highlights require_once 'stoolball/statistics/statistics-manager.class.php'; $statistics_manager = new StatisticsManager($this->GetSettings(), $this->GetDataConnection()); $statistics_manager->FilterBySeason($season_ids); $statistics_manager->FilterMaxResults(1); $this->best_batting = $statistics_manager->ReadBestBattingPerformance(); $this->best_bowling = $statistics_manager->ReadBestBowlingPerformance(); $this->most_runs = $statistics_manager->ReadBestPlayerAggregate("runs_scored"); $this->most_wickets = $statistics_manager->ReadBestPlayerAggregate("wickets"); $this->most_catches = $statistics_manager->ReadBestPlayerAggregate("catches"); # See what stats we've got available $best_batting_count = count($this->best_batting); $best_bowling_count = count($this->best_bowling); $best_batters = count($this->most_runs); $best_bowlers = count($this->most_wickets); $best_catchers = count($this->most_catches); $this->has_player_stats = ($best_batting_count or $best_batters or $best_bowling_count or $best_bowlers or $best_catchers); unset($statistics_manager); }
function OnLoadPageData() { # new data managers $o_comp_manager = new CompetitionManager($this->GetSettings(), $this->GetDataConnection()); $o_team_manager = new TeamManager($this->GetSettings(), $this->GetDataConnection()); # get comps $o_comp_manager->SetExcludeInactive(true); $o_comp_manager->ReadAllSummaries(); $this->a_comps = $o_comp_manager->GetItems(); # get teams $o_team_manager->FilterByActive(true); foreach ($this->a_comps as $o_comp) { /* @var $o_comp Competition */ $a_seasons = array($o_comp->GetLatestSeason()->GetId()); $o_team_manager->ReadBySeasonId($a_seasons); while ($o_team_manager->MoveNext()) { $o_comp->GetLatestSeason()->AddTeam($o_team_manager->GetItem()); } $o_team_manager->Clear(); } # tidy up unset($o_comp_manager); unset($o_team_manager); }
private function IndexCompetitions() { require_once 'stoolball/competition-manager.class.php'; require_once 'search/competition-search-adapter.class.php'; $this->SearchIndexer()->DeleteFromIndexByType("competition"); $manager = new CompetitionManager($this->GetSettings(), $this->GetDataConnection()); $manager->ReadAll(); $results = $manager->GetItems(); unset($manager); foreach ($results as $result) { $adapter = new CompetitionSearchAdapter($result); $this->SearchIndexer()->Index($adapter->GetSearchableItem()); } $this->SearchIndexer()->CommitChanges(); }
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; } }