-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheventListFunctions.inc.php
More file actions
118 lines (112 loc) · 4.3 KB
/
Copy patheventListFunctions.inc.php
File metadata and controls
118 lines (112 loc) · 4.3 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
// ex. "INSERT INTO event (event_user_id, event_date, title, description)
// VALUE($userID, '$eventDate', '$eventTitle', '$eventDescription')";
function addEvent($eventFile, $delimiter, $userId, $eventDate, $eventTitle, $eventDescription)
{
$events = get2DArray($eventFile, $delimiter);
$eventId = rand(1, 10000);
while (search_2d_array($events, 0, $eventId) !== false)
$eventId = rand(1, 10000);
$index = count($events);
$events[$index][0] = $eventId;
$events[$index][1] = $userId;
$events[$index][2] = $eventDate;
$events[$index][3] = $eventTitle;
$events[$index][4] = $eventDescription;
write2DArray($eventFile, $events, $delimiter);
}
// "UPDATE event SET event_date = '$eventDate'";
function editEvent($eventFile, $delimiter, $eventId, $userId, $eventDate, $eventTitle, $eventDescription)
{
$events = get2DArray($eventFile, $delimiter);
$index = search_2d_array($events, 0, $eventId);
if ($index !== false)
{
$events[$index][1] = $userId;
$events[$index][2] = $eventDate;
$events[$index][3] = $eventTitle;
$events[$index][4] = $eventDescription;
write2DArray($eventFile, $events, $delimiter);
}
}
/*
function retrieveEvent($eventFile, $delimiter, $eventId, &$userId, &$eventDate, &$eventTitle, &$eventDescription)
{
$events = get2DArray($eventFile, $delimiter);
$index = search_2d_array($events, 0, $eventId);
if ($index !== false)
{
$userId = $events[$index][1];
$eventDate = $events[$index][2];
$eventTitle = $events[$index][3];
$eventDescription = $events[$index][4];
}
}*/
/*
need sql statment to deleteEvent
ex. "DELETE FROM event WHERE event_ID = $eventID AND event_user_id = $userID";
function deleteEvent($eventFile, $delimiter, $id)
{
$events = get2DArray($eventFile, $delimiter);
$index = search_2d_array($events, 0, $id);
if ($index !== false)
{
unset($events[$index]);
$events = array_values($events);
write2DArray($eventFile, $events, $delimiter);
}
}*/
function echoEvents($events, $fields, $columns, $userId)
{
$filename = $_SERVER['PHP_SELF'];
$sortURL = $filename . "?action=sort&field=";
$deleteURL = $filename . "?action=delete&id=";
$editURL = $filename . "?action=edit&id=";
$count = count($events);
if ($count > 0)
{
echo "<table style=\"background-color:lightgray\"border=\"1\" width=\"100%\">\n";
// column headings
echo "<tr>\n";
echo "<th width=\"5%\"><span style=\"font-weight:bold\">".
"<a href='" . $sortURL . $fields[0] . "'>".$columns[0]."</a></span></th>";
echo "<th width=\"10%\"><span style=\"font-weight:bold\">".
"<a href='" . $sortURL . $fields[1] . "'>".$columns[1]."</a></span></th>";
echo "<th width=\"10%\"><span style=\"font-weight:bold\">".
"<a href='" . $sortURL . $fields[2] . "'>".$columns[2]."</a></span></th>";
echo "<th width=\"10%\"><span style=\"font-weight:bold\">".
"<a href='" . $sortURL . $fields[3] . "'>".$columns[3]."</a></span></th>";
echo "<th width=\"55%\"><span style=\"font-weight:bold;\">".$columns[4]."</span></th>";
echo "<th width=\"5%\"style=\"text-align:center\">Delete</th>\n";
echo "<th width=\"5%\"style=\"text-align:center\">Edit</th>\n";
echo "</tr>\n";
$count = count($events);
for ($i = 0; $i < $count; ++$i) {
echo "<tr>\n";
echo "<td width=\"5%\"style=\"text-align:center;font-weight:bold\">" . $events[$i][$fields[0]] . "</td>\n";
echo "<td width=\"10%\">" . htmlentities($events[$i][$fields[1]]) ."</td>";
echo "<td width=\"10%\">" . htmlentities($events[$i][$fields[2]]) ."</td>";
echo "<td width=\"10%\">" . htmlentities($events[$i][$fields[3]]) ."</td>";
echo "<td width=\"55%\">" . htmlentities($events[$i][$fields[4]]) ."</td>\n"; // this is description
if ($userId == $events[$i][$fields[1]])
{
echo "<td width=\"5%\"style=\"text-align:center\"><a href='"
. $deleteURL . $events[$i][$fields[0]] ."'>Delete</a></td>\n";
echo "<td width=\"5%\"style=\"text-align:center\"><a href='"
. $editURL . $events[$i][$fields[0]] ."'>Edit</a></td>\n";
}
else
{
echo "<td width=\"5%\"style=\"text-align:center\"> </td>\n";
echo "<td width=\"5%\"style=\"text-align:center\"> </td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";
}
else
{
echo "<h2>There are no events posted at this time.</h2>\n";
}
}
?>