public function OnPostback() { # If there's no id, ensure no match object is created. Page will then display a "match not found" message. # There's a separate page for adding matches, even for admins. if (!$this->editor->GetDataObjectId()) { return; } # Get the submitted match $this->match = $this->editor->GetDataObject(); # Because this is a new request, we need to reverify whether this is the match owner before letting anything happen. # Can't trust that info from a postback so MUST go to the database to check it. $this->match_manager->ReadByMatchId(array($this->editor->GetDataObjectId())); $check_match = $this->match_manager->GetFirst(); $this->b_user_is_match_owner = ($check_match instanceof Match and AuthenticationManager::GetUser()->GetId() == $check_match->GetAddedBy()->GetId()); # Don't wan't to edit tournaments on this page, so even as admin make sure we're not trying to save one. # Can't change the match type, so find out what that is from the db too. $this->b_is_tournament = $check_match->GetMatchType() == MatchType::TOURNAMENT; # Check whether cancel was clicked if ($this->editor->CancelClicked()) { # If so, get the match's short URL and redirect $this->match_manager->ExpandMatchUrl($this->match); $this->Redirect($this->match->GetNavigateUrl()); } # save data if valid if ($this->IsValid() and !$this->b_is_tournament) { # Save player of match $this->match_manager->SaveHighlights($this->match); $this->match_manager->ExpandMatchUrl($this->match); # Add comment if provided if (trim($this->match->GetNewComment())) { require_once 'forums/topic-manager.class.php'; require_once 'forums/review-item.class.php'; require_once 'forums/subscription-manager.class.php'; $topic_manager = new TopicManager($this->GetSettings(), $this->GetDataConnection()); $item_to_comment_on = new ReviewItem($this->GetSettings()); $item_to_comment_on->SetType(ContentType::STOOLBALL_MATCH); $item_to_comment_on->SetId($this->match->GetId()); $item_to_comment_on->SetNavigateUrl("https://" . $this->GetSettings()->GetDomain() . $this->match->GetNavigateUrl()); $message = $topic_manager->SaveComment($item_to_comment_on, $this->match->GetNewComment()); # send subscription emails $subs_manager = new SubscriptionManager($this->GetSettings(), $this->GetDataConnection()); $subs_manager->SendCommentsSubscriptions($item_to_comment_on, $message); unset($subs_manager); } # Match may have been updated so send an email $this->match_manager->NotifyMatchModerator($this->match->GetId()); # Show user the match, so they can see update was applied $this->Redirect($this->match->GetNavigateUrl()); } }
function OnPostback() { if ($this->editor->GetDataObjectId()) { # Because this is a new request we need to reverify that this is the match owner before letting anything happen. # Can't trust that info from a postback so MUST go to the database to check it. $this->match_manager->ReadByMatchId(array($this->editor->GetDataObjectId())); $check_match = $this->match_manager->GetFirst(); $this->b_user_is_match_owner = ($check_match instanceof Match and AuthenticationManager::GetUser()->GetId() == $check_match->GetAddedBy()->GetId()); # This page is only for tournaments, so check that against the db too $this->b_is_tournament = $check_match->GetMatchType() == MatchType::TOURNAMENT; } else { # Not an entirely correct error for there being no match id on postback, # but no match = not the owner, and most importantly it will prevent the # match being saved or the edit form being shown. $this->b_user_is_match_owner = false; } # get object $this->tournament = $this->editor->GetDataObject(); # Check whether cancel was clicked if ($this->editor->CancelClicked()) { $this->match_manager->ExpandMatchUrl($this->tournament); if ($this->adding) { http_response_code(303); $this->Redirect($this->tournament->GetDeleteNavigateUrl()); } else { # Show the tournament $this->Redirect($this->tournament->GetNavigateUrl()); } } # save data if valid if ($this->IsValid()) { # Confirm match is being saved as a tournament $this->b_is_tournament = $this->b_is_tournament and $this->tournament->GetMatchType() == MatchType::TOURNAMENT; # Check that the requester has permission to update this match if (($this->b_user_is_match_admin or $this->b_user_is_match_owner) and $this->b_is_tournament) { # Save the teams in the tournament $this->match_manager->SaveTeams($this->tournament); $this->match_manager->NotifyMatchModerator($this->tournament->GetId()); $this->match_manager->ExpandMatchUrl($this->tournament); http_response_code(303); if ($this->adding) { $this->Redirect($this->tournament->AddTournamentCompetitionsUrl()); } else { $this->Redirect($this->tournament->GetNavigateUrl()); } } } }
function OnPostback() { # get object $this->tournament = $this->editor->GetDataObject(); if ($this->editor->GetDataObjectId()) { # Because this is a new request we need to reverify security details before letting anything happen. # Can't trust that info from a postback so MUST go to the database to check it. $this->match_manager->ReadByMatchId(array($this->editor->GetDataObjectId())); $check_match = $this->match_manager->GetFirst(); if ($check_match instanceof Match) { # This page is only for tournaments, so check that against the db $this->b_is_tournament = $check_match->GetMatchType() == MatchType::TOURNAMENT; /* The editor requires the teams in the tournament to populate the dropdown and to come up with a * match title, and it doesn't have them when recreating the tournament from the postback data. * Since we have $check_match available from the database anyway, get the teams from there. */ foreach ($check_match->GetAwayTeams() as $team) { $this->tournament->AddAwayTeam($team); } } } else { # Error for there being no match id on postback, $this->b_is_tournament = false; } # Check whether cancel was clicked if ($this->editor->CancelClicked()) { $this->match_manager->ExpandMatchUrl($this->tournament); $this->Redirect($this->tournament->GetNavigateUrl()); } # save data if valid if ($this->IsValid()) { # Confirm match is being saved as a tournament $this->b_is_tournament = $this->b_is_tournament and $this->tournament->GetMatchType() == MatchType::TOURNAMENT; # Check that the requester has permission to update this match if ($this->b_is_tournament) { # Save the matches in the tournament $this->match_manager->SaveMatchesInTournament($this->tournament); $this->match_manager->NotifyMatchModerator($this->tournament->GetId()); $this->match_manager->ExpandMatchUrl($this->tournament); http_response_code(303); $this->Redirect($this->tournament->GetNavigateUrl()); } } }
public function OnPostback() { # If there's no id, ensure no match object is created. Page will then display a "match not found" message. # There's a separate page for adding matches, even for admins. if (!$this->editor->GetDataObjectId()) { return; } # Get the submitted match $this->match = $this->editor->GetDataObject(); # Because this is a new request, we need to reverify whether this is the match owner before letting anything happen. # Can't trust that info from a postback so MUST go to the database to check it. $this->match_manager->ReadByMatchId(array($this->editor->GetDataObjectId())); $check_match = $this->match_manager->GetFirst(); $this->b_user_is_match_owner = ($check_match instanceof Match and AuthenticationManager::GetUser()->GetId() == $check_match->GetAddedBy()->GetId()); # Don't wan't to edit tournaments on this page, so even as admin make sure we're not trying to save one. # Can't change the match type, so find out what that is from the db too. $this->b_is_tournament = $check_match->GetMatchType() == MatchType::TOURNAMENT; # Check whether cancel was clicked if ($this->editor->CancelClicked()) { # Match may have been updated so send an email $this->match_manager->NotifyMatchModerator($this->match->GetId()); # If so, get the match's short URL and redirect $this->match_manager->ExpandMatchUrl($this->match); $this->Redirect($this->match->GetNavigateUrl()); } # save data if valid if ($this->IsValid() and !$this->b_is_tournament) { switch ($this->editor->GetCurrentPage()) { case ScorecardEditControl::FIRST_INNINGS: $this->match_manager->SaveScorecard($this->match, true, $this->SearchIndexer()); $this->editor->SetCurrentPage(ScorecardEditControl::SECOND_INNINGS); break; case ScorecardEditControl::SECOND_INNINGS: $this->match_manager->SaveScorecard($this->match, false, $this->SearchIndexer()); $this->match_manager->ExpandMatchUrl($this->match); http_response_code(303); $this->Redirect($this->match->EditHighlightsUrl()); break; } } }
public function OnPostback() { # If there's no id, ensure no match object is created. Page will then display a "match not found" message. # There's a separate page for adding matches, even for admins. if (!$this->editor->GetDataObjectId()) { return; } # Get the submitted match $this->match = $this->editor->GetDataObject(); $check_match = $this->match; # Because this is a new request, if the user isn't admin we need to reverify whether this is the match owner # before letting anything happen. Can't trust that info from a postback so MUST go to the database to check it. if (!$this->b_user_is_match_admin) { $this->match_manager->ReadByMatchId(array($this->editor->GetDataObjectId())); $check_match = $this->match_manager->GetFirst(); $this->b_user_is_match_owner = ($check_match instanceof Match and AuthenticationManager::GetUser()->GetId() == $check_match->GetAddedBy()->GetId()); if ($this->b_user_is_match_owner) { # Set the owner of the match. This means the edit control knows who the owner is and therefore # whether to display the fixture editor on an invalid postback $this->match->SetAddedBy(AuthenticationManager::GetUser()); } else { # If user is neither admin nor owner, they won't have the team info. Get it from the $check_match so # that the match title can be updated correctly with a changed result. $this->match->SetHomeTeam($check_match->GetHomeTeam()); $this->match->SetAwayTeam($check_match->GetAwayTeam()); } } # Don't wan't to edit tournaments on this page, so even as admin make sure we're not trying to save one. # If user's not admin, can't change the match type, so find out what that is from the db too. For admin, # $check_match is the submitted one as the match type might've been changed. $this->b_is_tournament = $check_match->GetMatchType() == MatchType::TOURNAMENT; # Check whether cancel was clicked if ($this->editor->CancelClicked()) { # If so, get the match's short URL and redirect $this->match_manager->ExpandMatchUrl($this->match); $this->Redirect($this->match->GetNavigateUrl()); } # save data if valid if ($this->IsValid() and !$this->b_is_tournament) { # Check whether the user has permission to update the fixture as well as the result if ($this->b_user_is_match_admin or $this->b_user_is_match_owner) { # Get the ground name from the database. This is used when compiling an email about the updated match result. if ($this->match->GetGround() instanceof Ground and $this->match->GetGround()->GetId() and !$this->match->GetGround()->GetName()) { require_once 'stoolball/ground-manager.class.php'; $ground_manager = new GroundManager($this->GetSettings(), $this->GetDataConnection()); $ground_manager->ReadById(array($this->match->GetGround()->GetId())); if ($ground_manager->GetCount()) { $this->match->SetGround($ground_manager->GetFirst()); } unset($ground_manager); } $this->match_manager->SaveFixture($this->match); if ($this->b_user_is_match_admin) { $this->match_manager->SaveSeasons($this->match, false); } $this->editor->SetNavigateUrl($this->match->GetEditNavigateUrl()); # because edit URL may have changed } # Save the result $this->match_manager->SaveIfPlayed($this->match); $this->match_manager->SaveWhoWonTheToss($this->match); $this->match_manager->SaveWhoBattedFirst($this->match); # If match didn't happen or the teams aren't known yet, save and finish, otherwise go to next page $result = $this->match->Result()->GetResultType(); if ($result == MatchResult::HOME_WIN_BY_FORFEIT or $result == MatchResult::AWAY_WIN_BY_FORFEIT or $result == MatchResult::CANCELLED or $result == MatchResult::POSTPONED or $check_match->GetStartTime() > gmdate('U') or $this->b_user_is_match_admin and (!$this->match->GetHomeTeamId() or !$this->match->GetAwayTeamId())) { # Match may have been updated so, first, send an email $this->match_manager->NotifyMatchModerator($this->match->GetId()); http_response_code(303); $this->Redirect($this->match->GetNavigateUrl()); } else { http_response_code(303); $this->Redirect($this->match->EditScorecardUrl()); } } }
function OnLoadPageData() { /* @var $o_competition Competition */ # check parameter if (!isset($_GET['item']) or !is_numeric($_GET['item'])) { http_response_code(400); exit; } # new data managers $o_comp_manager = new CompetitionManager($this->GetSettings(), $this->GetDataConnection()); # get competition $latest = (isset($_GET['latest']) and $_GET['latest'] == '1'); if ($latest) { $o_comp_manager->ReadById(array($_GET['item']), null); } else { $o_comp_manager->ReadById(null, array($_GET['item'])); } $this->competition = $o_comp_manager->GetFirst(); $this->season = $this->competition->GetWorkingSeason(); # must have found a competition if (!$this->competition instanceof Competition or !$this->season instanceof Season) { http_response_code(404); exit; } # If the competition was requested, redirect to the current season if ($latest) { http_response_code(303); header("Location: " . $this->season->GetNavigateUrl()); return; } # Update search engine. Only do this for the latest season as then we have the right teams already. if ($this->competition->GetSearchUpdateRequired() and $latest) { $this->SearchIndexer()->DeleteFromIndexById("competition" . $this->competition->GetId()); require_once "search/competition-search-adapter.class.php"; $adapter = new CompetitionSearchAdapter($this->competition); $this->SearchIndexer()->Index($adapter->GetSearchableItem()); $this->SearchIndexer()->CommitChanges(); $o_comp_manager->SearchUpdated($this->competition->GetId()); } unset($o_comp_manager); # get matches $o_match_manager = new MatchManager($this->GetSettings(), $this->GetDataConnection()); $o_match_manager->ReadBySeasonId(array($this->season->GetId())); $a_matches = $o_match_manager->GetItems(); $this->season->SetMatches($a_matches); # While we're here, check if there are any outstanding notifications to be sent $o_match_manager->NotifyMatchModerator(); unset($o_match_manager); # Get stats highlights require_once 'stoolball/statistics/statistics-manager.class.php'; $statistics_manager = new StatisticsManager($this->GetSettings(), $this->GetDataConnection()); $statistics_manager->FilterBySeason(array($this->season->GetId())); $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); if (!$this->has_player_stats) { $player_of_match = $statistics_manager->ReadBestPlayerAggregate("player_of_match"); $this->has_player_stats = (bool) count($player_of_match); } unset($statistics_manager); # Get other seasons $a_comp_ids = array($this->competition->GetId()); $o_season_manager = new SeasonManager($this->GetSettings(), $this->GetDataConnection()); $o_season_manager->ReadByCompetitionId($a_comp_ids); $a_other_seasons = $o_season_manager->GetItems(); $this->competition->SetSeasons(array()); foreach ($a_other_seasons as $season) { if ($season->GetId() == $this->season->GetId()) { $this->competition->AddSeason($this->season, true); } else { $this->competition->AddSeason($season, false); } } unset($o_season_manager); }
function OnLoadPageData() { /* @var $o_last_match Match */ /* @var $season Season */ /* @var $team Team */ # new data manager $o_match_manager = new MatchManager($this->GetSettings(), $this->GetDataConnection()); # Collect season to add this match to, starting with the URL # get season and teams (was at this stage because editor needed teams to build its # posted data object, but that's no longer the case so probably could be later if needed) if (isset($this->i_season_id)) { $season_manager = new SeasonManager($this->GetSettings(), $this->GetDataConnection()); $season_manager->ReadById(array($this->i_season_id)); $this->season = $season_manager->GetFirst(); unset($season_manager); $this->edit->Seasons()->Add($this->season); # If there are at least 2 teams in the season, show only those teams, otherwise show all teams of the relevant player type if (count($this->season->GetTeams()) > 1) { $this->edit->SetTeams(array($this->season->GetTeams())); } else { require_once 'stoolball/team-manager.class.php'; $team_manager = new TeamManager($this->GetSettings(), $this->GetDataConnection()); $team_manager->FilterByPlayerType(array($this->season->GetCompetition()->GetPlayerType())); $team_manager->ReadTeamSummaries(); $this->edit->SetTeams(array($team_manager->GetItems())); unset($team_manager); } } # Not elseif, because when you've added a match there's a season, but we still need this to run to populate # the choices for the next match to be added if ($this->team instanceof Team) { # Otherwise it should be a team. # Get more information about the team itself require_once 'stoolball/team-manager.class.php'; $team_manager = new TeamManager($this->GetSettings(), $this->GetDataConnection()); $team_manager->ReadById(array($this->team->GetId())); $this->team = $team_manager->GetFirst(); if (!is_null($this->team)) { $this->edit->SetContextTeam($this->team); $season_ids = array(); $team_groups = array(); $a_exclude_team_ids = array(); $team_manager->FilterByActive(true); # Add the home team first $team_groups[] = array($this->team); $a_exclude_team_ids[] = $this->team->GetId(); # Get the seasons this team is in... $season_manager = new SeasonManager($this->GetSettings(), $this->GetDataConnection()); if ($this->i_match_type == MatchType::FRIENDLY) { # For a friendly, any group of teams they play with is fine $season_manager->ReadCurrentSeasonsByTeamId(array($this->team->GetId())); } else { # For anything else, get the seasons *for this type of match* $season_manager->ReadCurrentSeasonsByTeamId(array($this->team->GetId()), array($this->i_match_type)); } $seasons = $season_manager->GetItems(); unset($season_manager); $this->edit->Seasons()->Clear(); # on postback, the season just added is already there, so clear to prevent a duplicate foreach ($seasons as $season) { $this->edit->Seasons()->Add($season); $season_ids[] = $season->GetId(); } #... and their opponent teams in those seasons if (count($season_ids)) { $team_manager->FilterExceptTeams($a_exclude_team_ids); $team_manager->ReadBySeasonId($season_ids); $season_teams = $team_manager->GetItems(); if (count($season_teams)) { $team_groups['This season\'s teams'] = $season_teams; } foreach ($season_teams as $team) { $a_exclude_team_ids[] = $team->GetId(); } } # ...and if this is a friendly it could be any other team if ($this->i_match_type == MatchType::FRIENDLY) { # get any other teams they played in the last 2 years, and combine with existing results $team_manager->FilterExceptTeams($a_exclude_team_ids); $team_manager->ReadRecentOpponents(array($this->team->GetId()), 24); $recent_opponents = $team_manager->GetItems(); if (count($recent_opponents)) { $team_groups['Recent opponents'] = $recent_opponents; } foreach ($recent_opponents as $team) { $a_exclude_team_ids[] = $team->GetId(); } # get any other teams they might play, and combine with existing results $team_manager->FilterExceptTeams($a_exclude_team_ids); $team_manager->ReadAll(); $team_groups['Other teams'] = $team_manager->GetItems(); } # What if there are still no opponents to choose from? In that case select all teams. if (count($team_groups) == 1) { $team_manager->FilterExceptTeams($a_exclude_team_ids); $team_manager->ReadAll(); $team_groups[] = $team_manager->GetItems(); } # Offer those teams to select from if ($total_groups = count($team_groups)) { # If only two groups (home team + 1 group), don't group teams. Remove the only key from the array. if ($total_groups == 2) { $keys = array_keys($team_groups); $team_groups = array($team_groups[$keys[0]], $team_groups[$keys[1]]); } $this->edit->SetTeams($team_groups); } } unset($team_manager); } # Save match if ($this->IsPostback() and $this->IsValid()) { # Get posted match $this->match = $this->edit->GetDataObject(); if (!$this->IsRefresh()) { # Save match $o_match_manager->SaveFixture($this->match); $o_match_manager->SaveSeasons($this->match, true); $o_match_manager->NotifyMatchModerator($this->match->GetId()); # Update 'next 5 matches' $o_match_manager->ReadNext(); $this->a_next_matches = $o_match_manager->GetItems(); } # Reset control for new match $this->edit->SetDataObject(new Match($this->GetSettings())); } $o_match_manager->FilterByMatchType(array($this->i_match_type)); if (isset($this->i_season_id)) { # If we're adding a match to a season, get last game in season for its date $o_match_manager->ReadLastInSeason($this->season->GetId()); } else { if ($this->team instanceof Team) { # Get the last game already scheduled for the team to use its date $o_match_manager->ReadLastForTeam($this->team->GetId()); } } $o_last_match = $o_match_manager->GetFirst(); if (is_object($o_last_match)) { $current_season = Season::SeasonDates(); if (gmdate('Y', $o_last_match->GetStartTime()) < gmdate('Y', $current_season[0])) { # If the last match this team played was last season, use the time but not the date $this->edit->SetDefaultTime(gmmktime(gmdate('H', $o_last_match->GetStartTime()), gmdate('i', $o_last_match->GetStartTime()), 0, gmdate('m'), gmdate('d'), gmdate('Y'))); } else { # If the last match was this season and has a time, use it if ($o_last_match->GetIsStartTimeKnown()) { $this->edit->SetDefaultTime($o_last_match->GetStartTime()); } else { # If the last match has no time, use 6.30pm BST $this->edit->SetDefaultTime(gmmktime(17, 30, 0, gmdate('m', $o_last_match->GetStartTime()), gmdate('d', $o_last_match->GetStartTime()), gmdate('Y', $o_last_match->GetStartTime()))); } } } unset($o_match_manager); # Get grounds $o_ground_manager = new GroundManager($this->GetSettings(), $this->GetDataConnection()); $o_ground_manager->ReadAll(); $a_grounds = $o_ground_manager->GetItems(); $this->edit->SetGrounds($a_grounds); unset($o_ground_manager); }
function OnLoadPageData() { /* @var $o_match Match */ /* @var $o_team Team */ # new data manager $match_manager = new MatchManager($this->GetSettings(), $this->GetDataConnection()); # create repeater control, and save any posted data $this->repeater = new DataEditRepeater($this, 'CreateEditControl'); $this->repeater->SetCssClass('matchResults'); $this->repeater->SetPersistedParameters(array('team', 'season', "tournament")); $this->repeater->SetButtonText('Save all results'); $this->repeater->SetShowButtonsAtTop(true); if ($this->IsPostback() and !$this->IsRefresh() and $this->IsValid()) { require_once 'forums/topic-manager.class.php'; require_once 'forums/review-item.class.php'; require_once 'forums/subscription-manager.class.php'; $topic_manager = new TopicManager($this->GetSettings(), $this->GetDataConnection()); foreach ($this->repeater->GetDataObjects() as $o_current_match) { /* @var $o_current_match Match */ $match_manager->SaveResult($o_current_match); $match_manager->ExpandMatchUrl($o_current_match); $match_manager->NotifyMatchModerator($o_current_match->GetId()); if (trim($o_current_match->GetNewComment())) { $item_to_comment_on = new ReviewItem($this->GetSettings()); $item_to_comment_on->SetType(ContentType::STOOLBALL_MATCH); $item_to_comment_on->SetId($o_current_match->GetId()); $item_to_comment_on->SetNavigateUrl("https://" . $this->GetSettings()->GetDomain() . $o_current_match->GetNavigateUrl()); $message = $topic_manager->SaveComment($item_to_comment_on, $o_current_match->GetNewComment()); # send subscription emails - new object each time to reset list of who's already recieved an email $subs_manager = new SubscriptionManager($this->GetSettings(), $this->GetDataConnection()); $subs_manager->SendCommentsSubscriptions($item_to_comment_on, $message); unset($subs_manager); } } $this->b_saved = true; } # get matches if (!is_null($this->i_team_id)) { $a_season_times = Season::SeasonDates(); $match_manager->FilterByTeam(array($this->i_team_id)); $match_manager->FilterByDateStart($a_season_times[0]); $match_manager->FilterByDateEnd($a_season_times[1]); $match_manager->ReadMatchSummaries(); } else { if (!is_null($this->i_season_id)) { $match_manager->ReadBySeasonId(array($this->i_season_id), true); } else { if (!is_null($this->tournament_id)) { $match_manager->FilterByTournament($this->tournament_id); $this->a_matches = $match_manager->ReadMatchSummaries(); } } } $this->a_matches = $match_manager->GetItems(); # Make sure we have some matches if (count($this->a_matches)) { # If it's matches for a team, get the team if (!is_null($this->i_team_id)) { # Should only need to look at the first match, because the team must be a # part of that match in order for the match to be in this list $o_match =& $this->a_matches[0]; $o_team = $o_match->GetHomeTeam(); if ($o_team instanceof Team and $o_team->GetId() == $this->i_team_id) { $this->team = $o_team; } else { foreach ($o_match->GetAwayTeams() as $o_team) { if ($o_team->GetId() == $this->i_team_id) { $this->team = $o_team; break; } } } if (!is_object($this->team)) { $this->Redirect(); } # Now that we have short URL data, if data has just been saved for team, redirect back to team if ($this->b_saved) { $this->Redirect($this->team->GetNavigateUrl()); } } else { if (!is_null($this->i_season_id)) { # get details of the season require_once 'stoolball/competition-manager.class.php'; $o_comp_manager = new CompetitionManager($this->GetSettings(), $this->GetDataConnection()); $o_comp_manager->ReadById(null, array($this->i_season_id)); $o_competition = $o_comp_manager->GetFirst(); unset($o_comp_manager); if ($o_competition instanceof Competition) { $this->season = $o_competition->GetWorkingSeason(); } if (!$this->season instanceof Season) { $this->Redirect(); } # Now that we have short URL data, if data has just been saved for season, redirect back to season if ($this->b_saved) { $this->Redirect($this->season->GetNavigateUrl()); } } else { if (!is_null($this->tournament_id)) { $match_manager->ReadByMatchId(array($this->tournament_id)); $this->tournament = $match_manager->GetFirst(); if (!is_null($this->tournament)) { # If the tournament has just been saved, now we have its URL so redirect to the thanks page if ($this->b_saved) { $this->Redirect($this->tournament->GetNavigateUrl()); } } } } } } else { $this->Redirect(); } unset($match_manager); }