-
Notifications
You must be signed in to change notification settings - Fork 1
/
middleware-ticket-delete.php
41 lines (29 loc) · 1.48 KB
/
middleware-ticket-delete.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
session_start();
require_once "./app/core/Handle.php";
require_once "./app/models/Tickets.php";
require_once "./app/models/Parties.php";
require_once "./app/models/Notifications.php";
require_once "./app/core/Notification";
require_once "./app/models/WaitingList.php";
function hasEditAuthority($id) {
$ticket = Tickets::getTicket($id);
if(empty($ticket) || $_SESSION['party-manager']->party_id != $ticket->party_id) {
Handle::setPopup(Popups::noEditPermissions());
Handle::redirect("ticket-overview.php");
}
}
function sendNotification($party, $ticket) {
$messagePurchasersID = Notifications::createMessage($party->name, $party->name . " heeft zijn '" . $ticket->name . "' ticket verwijderd. Je hebt dus geen toegang meer tot deze fuif!");
$messageWaitingListID = Notifications::createMessage($party->name, $party->name . " heeft zijn '" . $ticket->name . "' ticket verwijderd. Je bent van de wachtlijst verwijderd voor dit ticket!");
Notification::notifyPurchasersAndWaitingList($party->party_id, $messageWaitingListID, $messagePurchasersID);
}
Handle::handleCommercialAuthentication();
Handle::requiredParameters([$_GET['ticketID'], $_GET['partyID']], Popups::wrongParameters(), "ticket-overview.php");
hasEditAuthority($_GET['ticketID']);
$party = Parties::getParty($_GET['partyID']);
$ticket = Tickets::getTicket($_GET['ticketID']);
sendNotification($party, $ticket);
Tickets::deleteTicket($_GET['ticketID']);
Handle::redirect("ticket-overview.php");
?>