function OnPostback() { # Get the match info and store it $i_id = $this->manager->GetItemId($this->match); $this->manager->ReadByMatchId(array($i_id)); $this->match = $this->manager->GetFirst(); if (!$this->match instanceof Match) { # This can be the case if the back button is used to go back to the "match has been deleted" page. $this->b_deleted = true; return; } # Check whether cancel was clicked if (isset($_POST['cancel'])) { $this->Redirect($this->match->GetNavigateUrl()); } # Check whether delete was clicked if (isset($_POST['delete'])) { # Check again that the requester has permission to delete this match $has_permission = (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_MATCHES) or AuthenticationManager::GetUser()->GetId() == $this->match->GetAddedBy()->GetId()); if ($has_permission) { # Delete the match $this->manager->DeleteMatch(array($i_id)); # Remove match, and all dependent tournament matches, from search results foreach ($this->match->GetMatchesInTournament() as $tournament_match) { $this->SearchIndexer()->DeleteFromIndexById("match" . $tournament_match->GetId()); } $this->SearchIndexer()->DeleteFromIndexById("match" . $this->match->GetId()); $this->SearchIndexer()->CommitChanges(); require_once 'stoolball/data-change-notifier.class.php'; $notifier = new DataChangeNotifier($this->GetSettings()); $notifier->MatchUpdated($this->match, AuthenticationManager::GetUser(), false, true); # Update 'next 5 matches' $this->manager->ReadNext(); $this->a_next_matches = $this->manager->GetItems(); # Note success $this->b_deleted = true; } } }