This repository has been archived on 2023-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
web/public/race/configure/teams/delete.php

38 lines
1.0 KiB
PHP
Raw Normal View History

2022-03-15 17:20:50 +00:00
<?php $app = require '../../../../app/inc.php';
2022-02-09 15:59:20 +00:00
2022-03-07 06:13:17 +00:00
use App\Teamtable\Team;
2022-03-30 19:11:34 +00:00
use App\Teamtable\TeamMapper;
2022-02-09 15:59:20 +00:00
2022-03-07 06:13:17 +00:00
$item = filter_input(INPUT_GET, 'item', FILTER_VALIDATE_INT);
2022-03-07 07:24:45 +00:00
$confirm = filter_input(INPUT_GET, 'confirm', FILTER_VALIDATE_BOOLEAN);
2022-03-07 06:13:17 +00:00
2022-03-30 19:11:34 +00:00
$teamMapper = new TeamMapper($app->database->conn);
2022-02-09 15:59:20 +00:00
2022-03-07 06:13:17 +00:00
// item is NULL if not set
if ($item === NULL)
2022-02-09 15:59:20 +00:00
{
2022-03-07 06:13:17 +00:00
$app->session->flash('Kunne ikke slette lag: Mangler parameter.', 'danger');
2022-02-09 15:59:20 +00:00
$app->redirect('index.php');
}
2022-03-30 19:11:34 +00:00
$team = $teamMapper->get($item);
2022-03-07 06:13:17 +00:00
if (!$team)
2022-02-09 15:59:20 +00:00
{
2022-03-07 06:13:17 +00:00
// team does not exist
$app->session->flash('Kunne ikke slette lag: Lag eksisterer ikke', 'danger');
2022-02-09 15:59:20 +00:00
$app->redirect('index.php');
}
2022-03-07 06:13:17 +00:00
// show confirmation page
2022-03-20 21:02:26 +00:00
if (!$confirm)
2022-02-14 01:52:59 +00:00
{
$app->view('template/header', ['title' => 'Bekreft sletting']);
2022-03-19 21:22:24 +00:00
$app->view('pages/race/configure/teams/delete', ['team' => $team]);
2022-02-14 01:52:59 +00:00
$app->view('template/footer');
die();
}
2022-03-07 06:13:17 +00:00
// all is good, lets delete the team
2022-03-30 19:11:34 +00:00
$teamMapper->delete($team->id);
2022-03-07 06:13:17 +00:00
$app->session->flash("Slettet lag: {$team->name}", "success");
2022-02-09 15:59:20 +00:00
$app->redirect('index.php');