-
Notifications
You must be signed in to change notification settings - Fork 1
/
middleware-party-edit-detail.php
88 lines (69 loc) · 3.42 KB
/
middleware-party-edit-detail.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
session_start();
require_once "./app/core/Handle.php";
require_once "./app/models/Parties.php";
function moveToPermanentPhotoFolder($path, $id, $type) {
$extension = pathinfo($path, PATHINFO_EXTENSION);
$newPath = './public/images/uploaded/party/';
if($type == 0)
$newPath .= 'background/party-' . $id . '.' . $extension;
else if($type == 1)
$newPath .= 'card/party-' . $id . '.' . $extension;
else
$newPath .= 'trailer/party-' . $id . '.' . $extension;
copy($path, $newPath);
return $newPath;
}
Handle::hasManageAuthority();
Handle::authentication("organizer", Popups::mustBeAuthenticated(), "login.php");
Handle::requiredParameters([$_SESSION['party-setup'], $_POST['startTimeParty'], $_POST['endTimeParty'],
$_POST['minimumAge'], $_POST['amount'], $_POST['minimumPrice'], $_POST['cloakRoom'],
$_POST['happyHourStartTime'], $_POST['happyHourEndTime'], $_POST['facebookUrl'], $_POST['instagramUrl'],
$_POST['twitterUrl']], Popups::requiredField(), "party-overview.php");
$partyID = $_SESSION['party-manager']->party_id;
$genreID = $_SESSION['party-setup']['genreID'];
$partyName = $_SESSION['party-setup']['partyName'];
$description = $_SESSION['party-setup']['description'];
$province = $_SESSION['party-setup']['province'];
$city = $_SESSION['party-setup']['city'];
$date = $_SESSION['party-setup']['date'];
$address = $_SESSION['party-setup']['address'];
$cardImagePath = $_SESSION['party-setup']['cardImagePath'];
$backgroundImagePath = $_SESSION['party-setup']['backgroundImagePath'];
$trailerVideoPath = $_SESSION['party-setup']['trailerVideoPath'];
$organizer = $_SESSION['organizer'];
$startTimeParty = $_POST['startTimeParty'];
$endTimeParty = $_POST['endTimeParty'];
$minimumAge = $_POST['minimumAge'];
$amountCoupons = $_POST['amount'];
$minimumPriceCoupons = $_POST['minimumPrice'];
$cloakRoomPrice = $_POST['cloakRoom'];
$happyHourStartTime = $_POST['happyHourStartTime'];
$happyHourEndTime = $_POST['happyHourEndTime'];
$facebookUrl = $_POST['facebookUrl'];
$instagramUrl = $_POST['instagramUrl'];
$twitterUrl = $_POST['twitterUrl'];
Parties::updateParty($partyID, $genreID, $partyName, $description, $province, $city, $address);
if(!empty($cardImagePath)) {
$cardImagePath = moveToPermanentPhotoFolder($cardImagePath, $partyID, 1);
Parties::uploadCardPhoto($partyID, $cardImagePath);
}
if(!empty($backgroundImagePath)) {
$backgroundImagePath = moveToPermanentPhotoFolder($backgroundImagePath, $partyID, 0);
Parties::uploadBackgroundPhoto($partyID, $backgroundImagePath);
}
if(!empty($trailerVideoPath)) {
$trailerVideoPath = moveToPermanentPhotoFolder($trailerVideoPath, $partyID, 2);
Parties::uploadTrailerVideo($partyID, $trailerVideoPath);
}
$startTimeParty = date('Y-m-d H:i:s', strtotime("$date $startTimeParty"));
$endTimeParty = date('Y-m-d H:i:s', strtotime("$date $endTimeParty + 1 days"));
$happyHourStartTime = date('Y-m-d H:i:s', strtotime("$date $happyHourStartTime"));
$happyHourEndTime = date('Y-m-d H:i:s', strtotime("$date $happyHourEndTime"));
$id = Parties::updatePartyInformation($partyID, $facebookUrl, $twitterUrl, $instagramUrl, $startTimeParty, $endTimeParty, $minimumAge, $minimumPriceCoupons, $amountCoupons,
$cloakRoomPrice, $happyHourStartTime, $happyHourEndTime);
Handle::setPopup(Popups::settingsSaved());
$_SESSION['party-manager'] = Parties::getParty($partyID);
unset($_SESSION['party-setup']);
Handle::redirect("party-edit.php");
?>