function OnPageLoad() { if ($this->page_not_found) { require_once $_SERVER['DOCUMENT_ROOT'] . "/wp-content/themes/stoolball/section-404.php"; return; } echo "<h1>" . Html::Encode($this->GetPageTitle()) . "</h1>"; require_once 'xhtml/navigation/tabs.class.php'; $tabs = array('Summary' => $this->tournament->GetNavigateUrl(), 'Tournament statistics' => ''); echo new Tabs($tabs); ?> <div class="box tab-box"> <div class="dataFilter"></div> <div class="box-content"> <?php # See what stats we've got available require_once "_summary-data-found.php"; if (!$has_player_stats) { echo "<p>There aren't any statistics for the " . htmlentities($this->tournament->GetTitle(), ENT_QUOTES, "UTF-8", false) . ' yet.</p> <p>To find out how to add them, see <a href="/play/manage/website/matches-and-results-why-you-should-add-yours/">Matches and results - why you should add yours</a>.</p>'; } else { require_once "_summary-controls.php"; } ?> </div> </div> <?php }
public function __construct(Match $match) { $this->match = $match; $this->searchable = new SearchItem("match", "match" . $match->GetId(), $match->GetNavigateUrl()); $this->searchable->Title($match->GetTitle() . ", " . $match->GetStartTimeFormatted(true, false)); $this->searchable->Description($this->GetSearchDescription()); $this->searchable->FullText($match->GetNotes()); $this->searchable->RelatedLinksHtml('<ul>' . '<li><a href="' . $match->GetNavigateUrl() . '/statistics">Statistics</a></li>' . '<li><a href="' . $match->GetCalendarNavigateUrl() . '">Add to calendar</a></li>' . '<li><a href="' . $match->GetEditNavigateUrl() . '">Update result</a></li>' . '</ul>'); # Assign more weight to newer matches $weight = $match->GetStartTime() / 60 / 60 / 24 / 365; $this->searchable->WeightWithinType($weight); }
function OnPageLoad() { # Matches this page shouldn't edit are page not found if ($this->page_not_found) { require_once $_SERVER['DOCUMENT_ROOT'] . "/wp-content/themes/stoolball/section-404.php"; return; } echo "<h1>" . Html::Encode($this->GetPageTitle()) . "</h1>"; require_once 'xhtml/navigation/tabs.class.php'; $tabs = array('Summary' => $this->match->GetNavigateUrl()); if ($this->match->GetMatchType() == MatchType::TOURNAMENT_MATCH) { $tabs['Match statistics'] = ''; $tabs['Tournament statistics'] = $this->match->GetTournament()->GetNavigateUrl() . '/statistics'; } else { $tabs['Statistics'] = ''; } echo new Tabs($tabs); ?> <div class="box tab-box"> <div class="dataFilter"></div> <div class="box-content"> <?php if (!$this->has_statistics) { echo "<p>There aren't any statistics for " . htmlentities($this->match->GetTitle(), ENT_QUOTES, "UTF-8", false) . ' yet.</p> <p>To find out how to add them, see <a href="/play/manage/website/matches-and-results-why-you-should-add-yours/">Matches and results - why you should add yours</a>.</p>'; } else { ?> <div class="statsColumns"> <div class="statsColumn"> <div class="chart-js-template" id="worm-chart"></div> </div> <div class="statsColumn"> <div class="chart-js-template" id="run-rate-chart"></div> </div> </div> <div class="statsColumns manhattan"> <h2>Scores in each over</h2> <div class="statsColumn"> <div class="chart-js-template" id="manhattan-chart-first-innings"></div> </div> <div class="statsColumn"> <div class="chart-js-template" id="manhattan-chart-second-innings"></div> </div> </div> <?php } ?> </div> </div> <?php }
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 OnPageLoad() { if (!$this->tournament instanceof Match or !$this->b_is_tournament) { http_response_code(404); require_once $_SERVER['DOCUMENT_ROOT'] . "/wp-content/themes/stoolball/section-404.php"; return; } echo new XhtmlElement('h1', htmlentities($this->GetPageTitle(), ENT_QUOTES, "UTF-8", false)); # check permission if (!$this->b_user_is_match_admin and !$this->b_user_is_match_owner) { ?> <p>Sorry, you can't edit a tournament unless you added it.</p> <p><a href="<?php echo htmlentities($this->tournament->GetNavigateUrl(), ENT_QUOTES, "UTF-8", false); ?> ">Go back to tournament</a></p> <?php return; } # OK to edit the match $o_match = is_object($this->tournament) ? $this->tournament : new Match($this->GetSettings()); $this->editor->SetDataObject($o_match); echo $this->editor; echo '<p class="facebook-tournaments">You can also list your tournament on the <a href="https://www.facebook.com/groups/1451559361817258/">Sussex Stoolball tournaments Facebook group</a>.</p>'; parent::OnPageLoad(); }
function OnPageLoad() { if (!$this->tournament instanceof Match or !$this->b_is_tournament) { http_response_code(404); require_once $_SERVER['DOCUMENT_ROOT'] . "/wp-content/themes/stoolball/section-404.php"; return; } echo new XhtmlElement('h1', Html::Encode($this->GetPageTitle())); # check permission if (!$this->b_user_is_match_admin and !$this->b_user_is_match_owner) { ?> <p>Sorry, you can't edit a tournament unless you added it.</p> <p><a href="<?php echo Html::Encode($this->tournament->GetNavigateUrl()); ?> ">Go back to tournament</a></p> <?php return; } # OK to edit the match $o_match = is_object($this->tournament) ? $this->tournament : new Match($this->GetSettings()); $this->editor->SetDataObject($o_match); echo $this->editor; parent::OnPageLoad(); }
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()); } } }
/** * Helper to build and send the email when a match has been added by a public user * * @param Match $o_match * @param User $o_user * @param bool $b_is_new_match * @param bool $b_is_deleted_match * @param string $s_email * @param Season[] $seasons */ private function SendMatchUpdatedEmail(Match $o_match, User $o_user, $b_is_new_match, $b_is_deleted_match, $s_email, $seasons = null) { # text of email $s_season_list = ''; if (is_array($seasons)) { $i_total_seasons = count($seasons); for ($i = 0; $i < $i_total_seasons; $i++) { if ($i == 0) { $s_season_list = "'" . $seasons[$i]->GetCompetitionName() . "'"; } else { if ($i == $i_total_seasons - 1) { $s_season_list .= " and '" . $seasons[$i]->GetCompetitionName() . "'"; } else { $s_season_list .= ", '" . $seasons[$i]->GetCompetitionName() . "'"; } } } } $s_season = $s_season_list ? " in the {$s_season_list}" : ''; $s_why = $s_season_list ? $s_season_list : 'matches'; $new = $b_is_new_match ? 'new ' : ''; $verb = $b_is_new_match ? 'added' : 'updated'; if ($b_is_deleted_match) { $verb = 'deleted'; } $match_text = $o_match->GetMatchType() == MatchType::TOURNAMENT ? 'tournament' : 'match'; $s_title = html_entity_decode($o_match->GetTitle()); $s_date = ucfirst($o_match->GetStartTimeFormatted()); $s_ground = is_object($o_match->GetGround()) ? $o_match->GetGround()->GetNameAndTown() : ''; $s_notes = $o_match->GetNotes(); $s_domain = $this->settings->GetDomain(); $s_url = 'https://' . $s_domain . $o_match->GetNavigateUrl(); $s_contact_url = 'https://' . $s_domain . $this->settings->GetFolder('Contact'); $s_home_name = $o_match->GetMatchType() == MatchType::TOURNAMENT ? '' : html_entity_decode($o_match->GetHomeTeam()->GetName()); $s_away_name = $o_match->GetMatchType() == MatchType::TOURNAMENT ? '' : html_entity_decode($o_match->GetAwayTeam()->GetName()); $s_bat_first = is_null($o_match->Result()->GetHomeBattedFirst()) ? 'Not known which team batted first' : ($o_match->Result()->GetHomeBattedFirst() ? $s_home_name : $s_away_name) . ' batted first'; $s_home_runs = is_null($o_match->Result()->GetHomeRuns()) ? '(not known)' : $o_match->Result()->GetHomeRuns(); $s_home_wickets = is_null($o_match->Result()->GetHomeWickets()) ? '(not known)' : $o_match->Result()->GetHomeWickets(); if ($s_home_wickets == -1) { $s_home_wickets = 'all out'; } else { $s_home_wickets = 'for ' . $s_home_wickets . ' wickets'; } $s_away_runs = is_null($o_match->Result()->GetAwayRuns()) ? '(not known)' : $o_match->Result()->GetAwayRuns(); $s_away_wickets = is_null($o_match->Result()->GetAwayWickets()) ? '(not known)' : $o_match->Result()->GetAwayWickets(); if ($s_away_wickets == -1) { $s_away_wickets = 'all out'; } else { $s_away_wickets = 'for ' . $s_away_wickets . ' wickets'; } $s_user = $o_user->GetName(); $s_body = wordwrap("A {$new}{$match_text} has been {$verb} on the Stoolball England website at {$s_domain}{$s_season}.\n\n" . "The {$match_text} was {$verb} by {$s_user}.\n\n" . "The {$match_text} details are as follows:\n\n" . " {$s_title}\n" . " {$s_date}\n" . " {$s_ground}"); if ($s_notes) { $s_notes = "\n\n" . wordwrap($s_notes, 70); $s_notes = str_replace("\n", "\n ", $s_notes); $s_body .= $s_notes; } if ($o_match->GetStartTime() <= gmdate('U') and !$b_is_new_match and $o_match->GetMatchType() != MatchType::TOURNAMENT) { $s_body .= <<<EMAILBODY \t{$s_bat_first} EMAILBODY; if ($o_match->Result()->GetHomeBattedFirst() === false) { $s_body .= <<<EMAILBODY \t{$s_away_name} score: {$s_away_runs} runs {$s_away_wickets} \t{$s_home_name} score: {$s_home_runs} runs {$s_home_wickets} EMAILBODY; } else { $s_body .= <<<EMAILBODY \t{$s_home_name} score: {$s_home_runs} runs {$s_home_wickets} \t{$s_away_name} score: {$s_away_runs} runs {$s_away_wickets} EMAILBODY; } } $s_body .= "\n\n"; if (!$b_is_deleted_match) { $s_body .= wordwrap("You can view the {$match_text} at {$s_url}\n\n"); } $s_body .= wordwrap("You have received this email because you are the administrative contact for {$s_why} on {$s_domain}.\n\n" . "We let you know when a {$match_text} is {$verb} by a member of the public, so that you can check there's nothing wrong.\n\n" . "If this email has been sent to the wrong address, or if the {$match_text} details are wrong, please let us know using the contact form at {$s_contact_url}.\n\n"); # send email, copy to me require_once 'Zend/Mail.php'; $o_email = new Zend_Mail('UTF-8'); $o_email->addTo($s_email); $o_email->setFrom('*****@*****.**', 'Stoolball England alerts'); $o_email->setSubject(ucfirst($match_text) . " {$verb}: {$s_title}, {$s_date}"); $o_email->setBodyText($s_body); try { $o_email->send(); } catch (Zend_Mail_Transport_Exception $e) { # Do nothing - failure to send this email should not be a fatal error } }
private function CreateLinkToMatch(Match $match) { $text = $match->GetTitle(); # Add player type for tournaments if ($match->GetPlayerType() and $match->GetMatchType() === MatchType::TOURNAMENT and strpos(strtolower($match->GetTitle()), strtolower(PlayerType::Text($match->GetPlayerType()))) === false) { $text .= ' (' . htmlentities(PlayerType::Text($match->GetPlayerType()), ENT_QUOTES, "UTF-8", false) . ')'; } $link = new XhtmlAnchor(); $link->AddControl(htmlentities($text, ENT_QUOTES, "UTF-8", false)); $link->SetNavigateUrl($match->GetNavigateUrl()); if ($this->b_microformats) { $link->SetCssClass('summary url'); # hCalendar $link->AddAttribute("rel", "schema:url"); $link->AddAttribute("property", "schema:name"); $title_meta = new XhtmlElement('span', ' (stoolball)'); $title_meta->SetCssClass('metadata'); $link->AddControl($title_meta); } return $link; }
function OnPageLoad() { if (!$this->match instanceof Match) { echo new XhtmlElement('h1', ucfirst($this->match_or_tournament) . ' already deleted'); echo new XhtmlElement('p', "The " . $this->match_or_tournament . " you're trying to delete does not exist or has already been deleted."); return; } echo new XhtmlElement('h1', 'Delete ' . $this->match_or_tournament . ': <cite>' . htmlentities($this->match->GetTitle(), ENT_QUOTES, "UTF-8", false) . '</cite>'); if ($this->b_deleted) { ?> <p>The <?php echo $this->match_or_tournament; ?> has been deleted.</p> <?php if ($this->match->GetTournament() instanceof Match) { echo '<p><a href="' . htmlentities($this->match->GetTournament()->GetNavigateUrl(), ENT_QUOTES, "UTF-8", false) . '">Go to ' . htmlentities($this->match->GetTournament()->GetTitle(), ENT_QUOTES, "UTF-8", false) . '</a></p>'; } else { if ($this->match->Seasons()->GetCount()) { foreach ($this->match->Seasons() as $season) { echo '<p><a href="' . htmlentities($season->GetNavigateUrl(), ENT_QUOTES, "UTF-8", false) . '">Go to ' . htmlentities($season->GetCompetitionName(), ENT_QUOTES, "UTF-8", false) . '</a></p>'; } } else { echo '<p><a href="/matches/">View all matches</a></p>'; } } } else { $has_permission = (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_MATCHES) or AuthenticationManager::GetUser()->GetId() == $this->match->GetAddedBy()->GetId()); if ($has_permission) { $s_detail = 'This is a ' . MatchType::Text($this->match->GetMatchType()); $s_detail .= $this->match->GetIsStartTimeKnown() ? ' starting at ' : ' on '; $s_detail .= $this->match->GetStartTimeFormatted() . '. '; $s_context = ''; if ($this->match->GetTournament() instanceof Match) { $s_context = "It's in the " . $this->match->GetTournament()->GetTitle(); } if ($this->match->Seasons()->GetCount()) { $season = $this->match->Seasons()->GetFirst(); $b_the = !(stristr($season->GetCompetitionName(), 'the ') === 0); $s_context .= $s_context ? ', in ' : 'It\'s in '; $s_context .= $b_the ? 'the ' : ''; if ($this->match->Seasons()->GetCount() == 1) { $s_context .= $season->GetCompetitionName() . '.'; } else { $s_context .= 'following seasons: '; } } $s_detail .= $s_context; echo new XhtmlElement('p', htmlentities($s_detail, ENT_QUOTES, "UTF-8", false)); if ($this->match->Seasons()->GetCount() > 1) { $seasons = new XhtmlElement('ul'); foreach ($this->match->Seasons() as $season) { $seasons->AddControl(new XhtmlElement('li', htmlentities($season->GetCompetitionName(), ENT_QUOTES, "UTF-8", false))); } echo $seasons; } if ($this->match->GetMatchType() == MatchType::TOURNAMENT) { ?> <p>Deleting a tournament cannot be undone.</p> <?php } else { ?> <p>Deleting a match cannot be undone. The match will be removed from all league tables and statistics.</p> <?php } ?> <p>Are you sure you want to delete this <?php echo $this->match_or_tournament; ?> ?</p> <form action="<?php echo htmlentities($this->match->GetDeleteNavigateUrl(), ENT_QUOTES, "UTF-8", false); ?> " method="post" class="deleteButtons"> <div> <input type="submit" value="Delete <?php echo $this->match_or_tournament; ?> " name="delete" /> <input type="submit" value="Cancel" name="cancel" /> </div> </form> <?php $this->AddSeparator(); require_once 'stoolball/user-edit-panel.class.php'; $panel = new UserEditPanel($this->GetSettings(), 'this ' . $this->match_or_tournament); $panel->AddLink('view this ' . $this->match_or_tournament, $this->match->GetNavigateUrl()); $panel->AddLink('edit this ' . $this->match_or_tournament, $this->match->GetEditNavigateUrl()); echo $panel; } else { ?> <p>Sorry, you can't delete a <?php echo $this->match_or_tournament; ?> unless you added it.</p> <p><a href="<?php echo htmlentities($this->match->GetNavigateUrl(), ENT_QUOTES, "UTF-8", false); ?> ">Go back to <?php echo $this->match_or_tournament; ?> </a></p> <?php } } }
protected function OnPreRender() { /* @var $o_home Team */ /* @var $o_away Team */ /* @var $o_tourney Match */ # Date and tournament $o_date_para = new XhtmlElement('p'); $o_date = new XhtmlElement('abbr', htmlentities($this->o_match->GetStartTimeFormatted(), ENT_QUOTES, "UTF-8", false)); $o_date->SetTitle(Date::Microformat($this->o_match->GetStartTime())); # hCalendar $o_date->SetCssClass('dtstart'); # hCalendar $o_date->AddAttribute("property", "schema:startDate"); $o_date->AddAttribute("datatype", "xsd:date"); $o_date->AddAttribute("content", Date::Microformat($this->o_match->GetStartTime())); $o_date_para->AddControl('When: '); $o_date_para->AddControl($o_date); # hCalendar end date if ($this->o_match->GetIsStartTimeKnown()) { $i_end_time = $this->o_match->GetStartTime() + 60 * 90; $o_hcal_end = new XhtmlElement('abbr', ' until around ' . htmlentities(Date::Time($i_end_time), ENT_QUOTES, "UTF-8", false)); $o_hcal_end->SetTitle(Date::Microformat($i_end_time)); $o_hcal_end->SetCssClass('metadata dtend'); $o_date_para->AddControl($o_hcal_end); } # If we know the time and place, show when the sun sets # TODO: Assumes UK if ($this->o_match->GetGround() instanceof Ground and $this->o_match->GetGround()->GetAddress()->GetLatitude() and $this->o_match->GetGround()->GetAddress()->GetLongitude()) { $o_date_para->AddControl(' <span class="sunset">sunset ' . htmlentities(Date::Time(date_sunset($this->o_match->GetStartTime(), SUNFUNCS_RET_TIMESTAMP, $this->o_match->GetGround()->GetAddress()->GetLatitude(), $this->o_match->GetGround()->GetAddress()->GetLongitude())), ENT_QUOTES, "UTF-8", false) . '</span>'); } # Display match type/season/tournament if ($this->o_match->GetMatchType() == MatchType::TOURNAMENT_MATCH) { $o_date_para->SetCssClass('description'); # hCal $o_tourney = $this->o_match->GetTournament(); if (is_object($o_tourney)) { $tournament_link = new XhtmlAnchor(htmlentities($o_tourney->GetTitle(), ENT_QUOTES, "UTF-8", false), $o_tourney->GetNavigateUrl()); $tournament_link->AddAttribute("typeof", "schema:SportsEvent"); $tournament_link->AddAttribute("about", $o_tourney->GetLinkedDataUri()); $tournament_link->AddAttribute("rel", "schema:url"); $tournament_link->AddAttribute("property", "schema:name"); $tournament_container = new XhtmlElement("span", $tournament_link); $tournament_container->AddAttribute("rel", "schema:superEvent"); # Check for 'the' to get the grammar right $s_title = strtolower($o_tourney->GetTitle()); if (strlen($s_title) >= 4 and substr($s_title, 0, 4) == 'the ') { $o_date_para->AddControl(', in '); } else { $o_date_para->AddControl(', in the '); } $o_date_para->AddControl($tournament_container); $o_date_para->AddControl('.'); } else { $o_date_para->AddControl(', in a tournament.'); } } else { # hCalendar desc, built up at the same time as the date and league/tournament $hcal_desc = new XhtmlElement('div', null, 'description'); $this->AddControl($hcal_desc); $s_detail_xhtml = ucfirst(MatchType::Text($this->o_match->GetMatchType())); $season_list_xhtml = null; if ($this->o_match->Seasons()->GetCount() == 1) { $season = $this->o_match->Seasons()->GetFirst(); $season_name = new XhtmlAnchor(htmlentities($season->GetCompetitionName(), ENT_QUOTES, "UTF-8", false), $season->GetNavigateUrl()); $b_the = !(stristr($season->GetCompetitionName(), 'the ') === 0); $s_detail_xhtml .= ' in ' . ($b_the ? 'the ' : '') . $season_name->__toString() . '.'; } elseif ($this->o_match->Seasons()->GetCount() > 1) { $s_detail_xhtml .= ' in the following seasons: '; $season_list_xhtml = new XhtmlElement('ul'); $seasons = $this->o_match->Seasons()->GetItems(); $total_seasons = count($seasons); for ($i = 0; $i < $total_seasons; $i++) { $season = $seasons[$i]; /* @var $season Season */ $season_name = new XhtmlAnchor(htmlentities($season->GetCompetitionName(), ENT_QUOTES, "UTF-8", false), $season->GetNavigateUrl()); $li = new XhtmlElement('li', $season_name); if ($i < $total_seasons - 2) { $li->AddControl(new XhtmlElement('span', ', ', 'metadata')); } else { if ($i < $total_seasons - 1) { $li->AddControl(new XhtmlElement('span', ' and ', 'metadata')); } } $season_list_xhtml->AddControl($li); } } else { $s_detail_xhtml .= '.'; } $hcal_desc->AddControl(new XhtmlElement('p', $s_detail_xhtml)); if (!is_null($season_list_xhtml)) { $hcal_desc->AddControl($season_list_xhtml); } } # Who $o_home = $this->o_match->GetHomeTeam(); $o_away = $this->o_match->GetAwayTeam(); $has_home = $o_home instanceof Team; $has_away = $o_away instanceof Team; if ($has_home or $has_away) { $who = new XhtmlElement("p", "Who: "); if ($has_home) { $who->AddControl($this->CreateTeamLink($o_home)); } if ($has_home and $has_away) { $who->AddControl(" and "); } if ($has_away) { $who->AddControl($this->CreateTeamLink($o_away)); } $this->AddControl($who); } # When $this->AddControl($o_date_para); # Ground $o_ground = $this->o_match->GetGround(); if (is_object($o_ground)) { $o_ground_link = new XhtmlElement('a', htmlentities($o_ground->GetNameAndTown(), ENT_QUOTES, "UTF-8", false)); $o_ground_link->AddAttribute('href', $o_ground->GetNavigateUrl()); $o_ground_link->SetCssClass('location'); # hCalendar $o_ground_link->AddAttribute("typeof", "schema:Place"); $o_ground_link->AddAttribute("about", $o_ground->GetLinkedDataUri()); $o_ground_link->AddAttribute("rel", "schema:url"); $o_ground_link->AddAttribute("property", "schema:name"); $o_ground_control = new XhtmlElement('p', 'Where: '); $o_ground_control->AddAttribute("rel", "schema:location"); $o_ground_control->AddControl($o_ground_link); $this->AddControl($o_ground_control); } # Add result $o_result = $this->o_match->Result(); $b_result_known = !$o_result->GetResultType() == MatchResult::UNKNOWN; $toss_known = !is_null($this->o_match->Result()->GetTossWonBy()); $b_batting_order_known = !is_null($this->o_match->Result()->GetHomeBattedFirst()); $has_scorecard_data = ($o_result->HomeBatting()->GetCount() or $o_result->HomeBowling()->GetCount() or $o_result->AwayBatting()->GetCount() or $o_result->AwayBowling()->GetCount() or $o_result->GetHomeRuns() or $o_result->GetHomeWickets() or $o_result->GetAwayRuns() or $o_result->GetAwayWickets()); $has_player_of_match = $this->o_match->Result()->GetPlayerOfTheMatch() instanceof Player and $this->o_match->Result()->GetPlayerOfTheMatch()->GetName(); $has_player_of_match_home = $this->o_match->Result()->GetPlayerOfTheMatchHome() instanceof Player and $this->o_match->Result()->GetPlayerOfTheMatchHome()->GetName(); $has_player_of_match_away = $this->o_match->Result()->GetPlayerOfTheMatchAway() instanceof Player and $this->o_match->Result()->GetPlayerOfTheMatchAway()->GetName(); if ($b_result_known or $b_batting_order_known or $has_scorecard_data) { # Put result in header, so long as we have something to put after it. Otherwise put the result after it. $result_header = "Result"; if ($b_result_known and ($b_batting_order_known or $has_scorecard_data)) { $result_header .= ": " . $this->o_match->GetResultDescription(); } $result_header = new XhtmlElement('h2', htmlentities($result_header, ENT_QUOTES, "UTF-8", false)); if ($has_scorecard_data) { $result_header->AddCssClass("hasScorecard"); } $this->AddControl($result_header); } if ($toss_known) { $toss_team = $this->o_match->Result()->GetTossWonBy() === TeamRole::Home() ? $this->o_match->GetHomeTeam() : $this->o_match->GetAwayTeam(); if ($toss_team instanceof Team) { $toss_text = $toss_team->GetName() . " won the toss"; if ($b_batting_order_known) { $chose_to = ($this->o_match->Result()->GetTossWonBy() === TeamRole::Home()) == $this->o_match->Result()->GetHomeBattedFirst() ? "bat" : "bowl"; $toss_text .= " and chose to " . $chose_to; } $this->AddControl("<p>" . Html::Encode($toss_text) . '.</p>'); } } # If at least one player recorded, create a container for the schema.org metadata if ($has_scorecard_data or $has_player_of_match or $has_player_of_match_home or $has_player_of_match_away) { $this->AddControl('<div rel="schema:performers">'); } if ($has_scorecard_data) { $this->CreateScorecard($this->o_match); } else { # Got to be just result and batting order now. Only include result if batting order's not there, otherwise result will already be in header. if ($b_result_known and !$b_batting_order_known) { $this->AddControl(new XhtmlElement('p', htmlentities($this->o_match->GetResultDescription(), ENT_QUOTES, "UTF-8", false) . '.')); } if ($b_batting_order_known) { $this->AddControl(new XhtmlElement('p', htmlentities(($this->o_match->Result()->GetHomeBattedFirst() ? $o_home->GetName() : $o_away->GetName()) . ' batted first.'), ENT_QUOTES, "UTF-8", false)); } } # Player of the match if ($has_player_of_match) { $player = $this->o_match->Result()->GetPlayerOfTheMatch(); $team = $player->Team()->GetId() == $o_home->GetId() ? $o_home->GetName() : $o_away->GetName(); $player_of_match = new XhtmlElement('p', 'Player of the match: <a property="schema:name" rel="schema:url" href="' . htmlentities($player->GetPlayerUrl(), ENT_QUOTES, "UTF-8", false) . '">' . htmlentities($player->GetName(), ENT_QUOTES, "UTF-8", false) . "</a> ({$team})"); $player_of_match->AddAttribute("typeof", "schema:Person"); $player_of_match->AddAttribute("about", $player->GetLinkedDataUri()); $this->AddControl($player_of_match); } if ($has_player_of_match_home) { $player = $this->o_match->Result()->GetPlayerOfTheMatchHome(); $player_of_match = new XhtmlElement('p', $o_home->GetName() . ' player of the match: <a property="schema:name" rel="schema:url" href="' . htmlentities($player->GetPlayerUrl(), ENT_QUOTES, "UTF-8", false) . '">' . htmlentities($player->GetName(), ENT_QUOTES, "UTF-8", false) . "</a>"); $player_of_match->AddAttribute("typeof", "schema:Person"); $player_of_match->AddAttribute("about", $player->GetLinkedDataUri()); $this->AddControl($player_of_match); } if ($has_player_of_match_away) { $player = $this->o_match->Result()->GetPlayerOfTheMatchAway(); $player_of_match = new XhtmlElement('p', $o_away->GetName() . ' player of the match: <a property="schema:name" rel="schema:url" href="' . htmlentities($player->GetPlayerUrl(), ENT_QUOTES, "UTF-8", false) . '">' . htmlentities($player->GetName(), ENT_QUOTES, "UTF-8", false) . "</a>"); $player_of_match->AddAttribute("typeof", "schema:Person"); $player_of_match->AddAttribute("about", $player->GetLinkedDataUri()); $this->AddControl($player_of_match); } # End container for the schema.org metadata if ($has_scorecard_data or $has_player_of_match or $has_player_of_match_home or $has_player_of_match_away) { $this->AddControl('</div>'); } # Add notes if ($this->o_match->GetNotes()) { $this->AddControl(new XhtmlElement('h2', 'Notes')); $s_notes = htmlentities($this->o_match->GetNotes(), ENT_QUOTES, "UTF-8", false); $s_notes = XhtmlMarkup::ApplyCharacterEntities($s_notes); require_once 'email/email-address-protector.class.php'; $protector = new EmailAddressProtector($this->o_settings); $s_notes = $protector->ApplyEmailProtection($s_notes, AuthenticationManager::GetUser()->IsSignedIn()); $s_notes = XhtmlMarkup::ApplyHeadings($s_notes); $s_notes = XhtmlMarkup::ApplyParagraphs($s_notes); $s_notes = XhtmlMarkup::ApplyLists($s_notes); $s_notes = XhtmlMarkup::ApplySimpleTags($s_notes); $s_notes = XhtmlMarkup::ApplyLinks($s_notes); if (strpos($s_notes, '<p>') > -1) { $this->AddControl($s_notes); } else { $this->AddControl(new XhtmlElement('p', $s_notes)); } } # hCalendar metadata $o_hcal_para = new XhtmlElement('p'); $o_hcal_para->SetCssClass('metadata'); $this->AddControl($o_hcal_para); # hCalendar timestamp $o_hcal_para->AddControl('Status: At '); $o_hcal_stamp = new XhtmlElement('abbr', htmlentities(Date::Time(gmdate('U')), ENT_QUOTES, "UTF-8", false)); $o_hcal_stamp->SetTitle(Date::Microformat()); $o_hcal_stamp->SetCssClass('dtstamp'); $o_hcal_para->AddControl($o_hcal_stamp); # hCalendar GUID $o_hcal_para->AddControl(' match '); $o_hcal_guid = new XhtmlElement('span', htmlentities($this->o_match->GetLinkedDataUri(), ENT_QUOTES, "UTF-8", false)); $o_hcal_guid->SetCssClass('uid'); $o_hcal_para->AddControl($o_hcal_guid); # work out hCalendar status $s_status = 'CONFIRMED'; switch ($this->o_match->Result()->GetResultType()) { case MatchResult::CANCELLED: case MatchResult::POSTPONED: case MatchResult::AWAY_WIN_BY_FORFEIT: case MatchResult::HOME_WIN_BY_FORFEIT: $s_status = 'CANCELLED'; } # hCalendar URL and status $o_hcal_para->AddControl(' is '); $o_hcal_url = new XhtmlAnchor($s_status, 'http://' . $_SERVER['HTTP_HOST'] . $this->o_match->GetNavigateUrl()); $o_hcal_url->SetCssClass('url status'); $o_hcal_para->AddControl($o_hcal_url); }
function OnPageLoad() { $is_tournament = $this->match->GetMatchType() == MatchType::TOURNAMENT; $class = $is_tournament ? "match" : "match vevent"; ?> <div class="$class" typeof="schema:SportsEvent" about="<?php echo Html::Encode($this->match->GetLinkedDataUri()); ?> "> <?php require_once 'xhtml/navigation/tabs.class.php'; $tabs = array('Summary' => ''); if ($is_tournament) { $tabs['Tournament statistics'] = $this->match->GetNavigateUrl() . '/statistics'; # Make sure the reader knows this is a tournament, and the player type $says_tournament = strpos(strtolower($this->match->GetTitle()), 'tournament') !== false; $player_type = PlayerType::Text($this->match->GetPlayerType()); $says_player_type = strpos(strtolower($this->match->GetTitle()), strtolower(rtrim($player_type, '\''))) !== false; $page_title = $this->match->GetTitle() . ", " . Date::BritishDate($this->match->GetStartTime(), false); if (!$says_tournament and !$says_player_type) { $page_title .= ' (' . $player_type . ' stoolball tournament)'; } else { if (!$says_tournament) { $page_title .= ' stoolball tournament'; } else { if (!$says_player_type) { $page_title .= ' (' . $player_type . ')'; } } } $heading = new XhtmlElement('h1', $page_title); $heading->AddAttribute("property", "schema:name"); echo $heading; } else { if ($this->match->GetMatchType() == MatchType::TOURNAMENT_MATCH) { $tabs['Match statistics'] = $this->match->GetNavigateUrl() . '/statistics'; $tabs['Tournament statistics'] = $this->match->GetTournament()->GetNavigateUrl() . '/statistics'; $page_title = $this->match->GetTitle() . " in the " . $this->match->GetTournament()->GetTitle(); } else { $tabs['Statistics'] = $this->match->GetNavigateUrl() . '/statistics'; $page_title = $this->match->GetTitle(); } $o_title = new XhtmlElement('h1', Html::Encode($page_title)); $o_title->AddAttribute("property", "schema:name"); # hCalendar $o_title->SetCssClass('summary'); $o_title_meta = new XhtmlElement('span', ' (stoolball)'); $o_title_meta->SetCssClass('metadata'); $o_title->AddControl($o_title_meta); if ($this->match->GetMatchType() !== MatchType::TOURNAMENT_MATCH) { $o_title->AddControl(", " . Date::BritishDate($this->match->GetStartTime(), false)); } echo $o_title; } echo new Tabs($tabs); ?> <div class="box tab-box"> <div class="dataFilter"></div> <div class="box-content"> <?php if ($is_tournament) { require_once 'stoolball/tournaments/tournament-control.class.php'; echo new TournamentControl($this->GetSettings(), $this->match); } else { require_once 'stoolball/matches/match-control.class.php'; echo new MatchControl($this->GetSettings(), $this->match); } $this->DisplayComments(); $this->ShowSocial(); ?> </div> </div> </div> <?php $this->AddSeparator(); # add/edit/delete options $user_is_admin = AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_MATCHES); $user_is_owner = AuthenticationManager::GetUser()->GetId() == $this->match->GetAddedBy()->GetId(); $panel = new UserEditPanel($this->GetSettings(), 'this match'); $panel->AddCssClass("with-tabs"); if ($user_is_admin or $user_is_owner) { $link_text = $is_tournament ? 'tournament' : 'match'; $panel->AddLink('edit this ' . $link_text, $this->match->GetEditNavigateUrl()); } else { if ($this->match->GetMatchType() != MatchType::PRACTICE and !$is_tournament) { $panel->AddLink('update result', $this->match->GetEditNavigateUrl()); } } if ($is_tournament) { $panel->AddCssClass("with-tabs"); if ($user_is_admin or $user_is_owner) { $panel->AddLink('add or remove teams', $this->match->EditTournamentTeamsUrl()); } $panel->AddLink('add or remove matches', $this->match->GetEditTournamentMatchesUrl()); if (count($this->match->GetMatchesInTournament())) { $panel->AddLink('update results', $this->match->GetNavigateUrl() . "/matches/results"); } } if ($user_is_admin or $user_is_owner) { if ($is_tournament) { $panel->AddLink('edit where to list this tournament', $this->match->EditTournamentCompetitionsUrl()); } $link_text = $is_tournament ? 'tournament' : 'match'; $panel->AddLink('delete this ' . $link_text, $this->match->GetDeleteNavigateUrl()); } if ($this->match->GetMatchType() != MatchType::TOURNAMENT_MATCH and $this->match->GetStartTime() > time()) { $link_text = $is_tournament ? 'tournament' : 'match'; $panel->AddLink("add {$link_text} to your calendar", $this->match->GetCalendarNavigateUrl()); } echo $panel; if ($this->has_player_stats) { $tournament = $is_tournament ? $this->match : $this->match->GetTournament(); require_once 'stoolball/statistics-highlight-table.class.php'; echo new StatisticsHighlightTable($this->best_batting, $this->most_runs, $this->best_bowling, $this->most_wickets, $this->most_catches, "tournament"); echo '<p class="playerSummaryMore"><a href="' . $tournament->GetNavigateUrl() . '/statistics">Tournament statistics</a></p>'; } }
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); }