-
Notifications
You must be signed in to change notification settings - Fork 1
/
removeTimeslot.php
57 lines (50 loc) · 1.84 KB
/
removeTimeslot.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
<?php
include 'includes/session.php';
include 'includes/dbConnect.php';
include 'includes/library.php';
$meeting_id = mysqli_real_escape_string($connection, $_GET['meeting_id']);
$mudt_id = mysqli_real_escape_string($connection, $_GET['mudt_id']);
$query = "SELECT * FROM meeting_users WHERE meeting_id='$meeting_id'";
$result = mysqli_query($connection, $query);
if (!isLoggedIn() || !$result){
header("Location: error.php");
exit;
}
else {
if ($user_id == getMeetingOwnerID($connection, $meeting_id)){
$owner = true;
}
else $owner = false;
}
$query = "SELECT * FROM meeting_users WHERE meeting_id='".$meeting_id."' && user_id='".$user_id."'";
$result = mysqli_query($connection, $query);
if ($result){
$mu = mysqli_fetch_array($result, MYSQLI_ASSOC);
$mu_id = $mu['mu_id'];
$query = "SELECT * FROM mu_date_time WHERE mu_id=$mu_id && mudt_id=$mudt_id";
$result = mysqli_query($connection, $query) OR DIE(mysqli_error($connection));
$mu_date_time = mysqli_fetch_array($result);
$date_time = $mu_date_time['date_time'];
if ($owner){
// delete participant's timeslot
$query = "SELECT * FROM meeting_users WHERE meeting_id=$meeting_id";
$result = mysqli_query($connection, $query) OR DIE(mysqli_error($connection));
while ($currentUser = mysqli_fetch_array($result)){
$current_mu_id = $currentUser['mu_id'];
if ($current_mu_id != $mu_id){
$query = "DELETE FROM mu_Date_time WHERE mu_id='$current_mu_id' && date_time='$date_time'";
$result2 = mysqli_query($connection, $query) OR DIE(mysqli_error($connection));
}
}
}
// delete self's timeslot
$query = "DELETE FROM mu_date_time WHERE mu_id=$mu_id && mudt_id=$mudt_id";
$result = mysqli_query($connection, $query);
header("Location: meeting.php?meeting_id=$meeting_id");
exit;
}
else {
header("Location: error.php");
exit;
}
?>