public static function alter()
 {
     Controller::requirePermissions(["AdminAccessDashboard", "AdminMatches"]);
     $id = $_POST["id"];
     $match = current(MatchModel::get($_POST["id"]));
     if (array_key_exists("date", $_POST)) {
         try {
             $id = $match->correctDate($match->id, $_POST["date"]);
             Controller::addAlert(new Alert("success", "Correction completed"));
         } catch (DuplicateException $e) {
             Controller::addAlert(new Alert("danger", "The report cannot be moved to the specified date as there is already another report filed for the team for the match on that date"));
         }
     } else {
         if (array_key_exists("home_team_id", $_POST)) {
             try {
                 $homeTeamId = $_POST["home_team_id"] != 0 ? $_POST["home_team_id"] : null;
                 $awayTeamId = $_POST["away_team_id"] != 0 ? $_POST["away_team_id"] : null;
                 $id = $match->correctTeams($match->id, $homeTeamId, $awayTeamId);
                 Controller::addAlert(new Alert("success", "Correction completed"));
             } catch (DuplicateException $e) {
                 Controller::addAlert(new Alert("danger", "The report cannot be updated with those team(s) as there is already another report filed for the team for the match on that date"));
             }
         }
     }
     Controller::redirect("/acp/match/manage?id=" . $id);
 }
 public static function index()
 {
     Controller::requirePermissions(["AdminAccessDashboard"]);
     if (!empty($_POST)) {
         Setting::set("info_box_content", $_POST["info"]);
     }
     View::load("acp/index.twig", ["organizationCount" => count(Organization::get()), "teamCount" => count(Team::get()), "unassignedTeams" => Team::get(null, null, null, false, false), "info" => Setting::get("info_box_content"), "mismatches" => Match::get(null, null, null, null, null, Match::STATUS_MISMATCH)]);
 }
 public static function delete()
 {
     Controller::requireFields("get", ["id"], "/acp/team");
     Controller::requirePermissions(["AdminAccessDashboard", "AdminTeams", "AdminPlayers", "PerformDeletionOperations"]);
     $team = current(TeamModel::get($_GET["id"]));
     $team->delete();
     Controller::addAlert(new Alert("success", "Team deleted successfully"));
     Controller::redirect("/acp/team");
 }
 public static function delete()
 {
     Controller::requirePermissions(["AdminAccessDashboard", "AdminUsers", "PerformDeletionOperations"]);
     if (!array_key_exists("id", $_GET)) {
         Controller::redirect("/acp/user");
     }
     $users = UserModel::get($_GET["id"]);
     if (!empty($users)) {
         current($users)->delete();
         Controller::addAlert(new Alert("success", "User deleted successfully"));
     } else {
         Controller::addAlert(new Alert("danger", "The user you attempted to delete does not exist"));
     }
     Controller::redirect("/acp/user");
 }
 public static function delete()
 {
     Controller::requirePermissions(["AdminAccessDashboard"]);
     $fixture = current(FixtureModel::get($_GET["id"]));
     if (!$fixture) {
         Controller::addAlert(new Alert("success", "The specified fixture does not exist"));
         Controller::redirect("/acp/league");
     }
     $league = $fixture->getLeague();
     // check permissions
     $visitor = UserModel::getVisitor();
     if ($visitor->id != $league->managerId) {
         Controller::requirePermissions(["AdminAllLeagues"]);
     }
     $fixture->delete();
     Controller::addAlert(new Alert("success", "Fixture deleted successfully"));
     Controller::redirect("/acp/league/manage?id=" . $league->id);
 }
 public static function delete()
 {
     Controller::requirePermissions(["AdminAccessDashboard"]);
     if (!array_key_exists("id", $_GET)) {
         Controller::redirect("/acp/league");
     }
     $section = current(LeagueSectionModel::get($_GET["id"]));
     // check permissions
     $visitor = User::getVisitor();
     if ($visitor->id != $section->getLeague()->managerId) {
         Controller::requirePermissions(["AdminAllLeagues"]);
     }
     try {
         $section->delete();
         Controller::addAlert(new Alert("success", "League section deleted successfully"));
     } catch (ObjectCannotBeDeletedException $e) {
         Controller::addAlert(new Alert("danger", "You cannot delete a section which has teams assigned to it. Please reassign the teams to an alternative section first"));
     }
     Controller::redirect("/acp/league/manage?id=" . $section->getLeague()->id);
 }
 public static function delete()
 {
     Controller::requirePermissions(["AdminAccessDashboard", "AdminUserGroups", "PerformDeletionOperations"]);
     if (!array_key_exists("id", $_GET)) {
         Controller::redirect("/acp/group");
     }
     $group = current(UserGroupModel::get($_GET["id"]));
     if (!$group) {
         Controller::addAlert(new Alert("danger", "The specified group does not exist"));
     } else {
         if ($group->special) {
             Controller::addAlert(new Alert("danger", "The specified group is a special group and cannot be deleted as it would break core functionality"));
         } else {
             if (($count = count($group->getUsers())) > 0) {
                 Controller::addAlert(new Alert("danger", "There are " . $count . " users currently in " . "the specified group, you must assign them to a different group before you can delete this group"));
             } else {
                 $group->delete();
                 Controller::addAlert(new Alert("success", "User group deleted successfully"));
             }
         }
     }
     Controller::redirect("/acp/group");
 }
 public static function updateplayer()
 {
     Controller::requireFields("get", ["id"], "/acp/team");
     $player = current(Player::get($_GET["id"]));
     if (!User::getVisitor()->checkPermissions(["RegisterTeamsForAnyOrganization"])) {
         Controller::requirePermissions(["RegisterTeamsForOwnOrganization"]);
         if ($player->getTeam()->organizationId != User::getVisitor()->organizationId) {
             ErrorHandler::forbidden();
         }
     }
     if ($_GET["exempt"] == 1 && !$player->exempt) {
         if ($player->getTeam()->getNumberOfExemptPlayers() >= MAX_EXEMPTS) {
             Controller::addAlert(new Alert("danger", "You have already starred the maximum number of players"));
             Controller::redirect("/team/edit?id=" . $player->getTeam()->id);
         }
     }
     Player::update($player->id, null, (bool) $_GET["exempt"]);
     Controller::addAlert(new Alert("success", "Player updated successfully"));
     Controller::redirect("/team/edit?id=" . $player->getTeam()->id);
 }
 public static function submitted()
 {
     Controller::requirePermissions(["SubmitMatchReports"]);
     $visitor = User::getVisitor();
     $teams = Team::get(null, $visitor->organizationId);
     $teamIds = [];
     foreach ($teams as $team) {
         $teamIds[] = $team->id;
     }
     $reports = MatchReport::get(null, null, null, $teamIds, 25);
     View::load("match/submitted.twig", ["organizationReports" => $reports, "userReports" => MatchReport::get(null, null, $visitor->id, null, 25)]);
 }