This repository was archived by the owner on Aug 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrouphomepage.php
More file actions
376 lines (359 loc) · 13.6 KB
/
grouphomepage.php
File metadata and controls
376 lines (359 loc) · 13.6 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
<?php
include_once('globals.php');
include_once('checklogin.php');
include_once('classes/groupannouncement.php');
include_once('classes/event.php');
include_once('classes/email.php');
include_once('classes/file.php');
include_once('classes/grouppicture.php');
include_once('classes/task.php');
//------Start XHTML Output--------------------------------------//
require('doctype.php');
require('appearance.php');
echo "<link rel=\"stylesheet\" href=\"skins/$skin/grouphomepage.css\" type=\"text/css\" title=\"$skin\" />\n";
foreach($altskins as $altskin)
echo "<link rel=\"alternate stylesheet\" href=\"skins/$altskin/grouphomepage.css\" type=\"text/css\" title=\"$altskin\" />\n";
?>
<title><?php echo $appname; ?> - <?php echo $currentGroup->getName(); ?></title>
<script type="text/javascript" src="ChangeLocation.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="windowfiles/dhtmlwindow.js">
/***********************************************
* DHTML Window Widget- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>
<script type="text/javascript">
//<![CDATA[
function showEvent(id, x, y)
{
document.getElementById(id).style.top=(y + 20)+"px";
if(x > window.innerWidth / 2)
document.getElementById(id).style.left=(x - 200)+"px";
else
document.getElementById(id).style.left=x+"px";
document.getElementById(id).style.visibility='visible';
}
function hideEvent(id)
{
document.getElementById(id).style.visibility='hidden';
}
function editAnnouncement(id, heading, body)
{
document.getElementById('editid').value = id;
document.getElementById('editheading').value = heading;
document.getElementById('editbody').value = body;
}
function dehtml(desc)
{
desc.replace("<a href", "<a onclick=\"window.open(this.href); return false;\" href");
desc.replace("<A HREF", "<a onclick=\"window.open(this.href); return false;\" href");
desc.replace("<a href", "<a onclick=\"window.open(this.href); return false;\" href");
desc.replace("<A HREF", "<a onclick=\"window.open(this.href); return false;\" href");
desc.replace("</a", "</a");
desc.replace(">", ">");
desc.replace("&quot;", "\"");
desc.replace(""", "\"");
return desc;
}
function viewEvent(name, desc, date)
{
document.getElementById('viewname').innerHTML = name;
desc = dehtml(desc);
document.getElementById('viewdesc').innerHTML = desc;
document.getElementById('viewdate').innerHTML = date;
}
function viewTask(name, desc, date)
{
document.getElementById('taskname').innerHTML = name;
desc = dehtml(desc);
document.getElementById('taskdesc').innerHTML = desc;
document.getElementById('taskdate').innerHTML = date;
}
//]]>
</script>
</head>
<body>
<?php
/**** begin html head *****/
require('htmlhead.php'); //starts main container
/****end html head content ****/
if(isset($_POST['addannouncement']))
{
if(createGroupAnnouncement($_POST['heading'], $_POST['body'], $_POST['date'], $currentGroup, $db))
{
?>
<script type="text/javascript">
var successwin=dhtmlwindow.open('successbox', 'inline', '<p>Announcement added.</p>', 'Success', 'width=125px,height=10px,left=300px,top=100px,resize=0,scrolling=0', 'recal');
</script>
<?php
}
else
{
?>
<script type="text/javascript">
var successwin=dhtmlwindow.open('successbox', 'inline', '<p>Announcement was not added. Please ensure that you have filled out all fields, and try again.</p>', 'Error', 'width=125px,height=10px,left=300px,top=100px,resize=0,scrolling=0', 'recal');
</script>
<?php
}
}
if(isset($_POST['editannouncement']))
{
$ann = new GroupAnnouncement($_POST['id'], $db);
$ann->setHeading($_POST['heading']);
$ann->setBody($_POST['body']);
$ann->updateDB();
?>
<script type="text/javascript">
var successwin=dhtmlwindow.open('successbox', 'inline', '<p>Announcement edited.</p>', 'Success', 'width=125px,height=10px,left=300px,top=100px,resize=0,scrolling=0', 'recal');
</script>
<?php
}
if(isset( $_POST['deleteannouncement']))
{
$ann = new GroupAnnouncement($_POST['id'], $db);
$ann->delete();
?>
<script type="text/javascript">
var successwin=dhtmlwindow.open('successbox', 'inline', '<p>Announcement deleted.</p>', 'Success', 'width=125px,height=10px,left=300px,top=100px,resize=0,scrolling=0', 'recal');
</script>
<?php
}
if(isset($_POST['scratch']) && !$currentUser->isGroupGuest($currentGroup))
{
$currentGroup->setScratch($_POST['scratchpad'], $currentUser->getID());
?>
<script type="text/javascript">
var successwin=dhtmlwindow.open('successbox', 'inline', '<p>Scratchpad updated.</p>', 'Success', 'width=125px,height=10px,left=300px,top=100px,resize=0,scrolling=0', 'recal');
</script>
<?php
}
if($currentGroup->getScratchUpdater())
{
$by = new Person($currentGroup->getScratchUpdater(), $db);
$scratchBlurb = "<p id=\"scratchblurb\">Scratchpad last updated by {$by->getFullName()} at {$currentGroup->getScratchUpdated()}</p>\n";
}
else
$scratchBlurb = '';
?>
<div id="calendar">
<?php
$events = $currentGroup->getWeekEvents();
$eventArray = array();
foreach($events as $event)
{
$temp = explode('/', $event->getDate());
$eventArray[intval($temp[1])][] = $event;
}
$tasks = $currentGroup->getWeekTasks();
$taskArray = array();
foreach($tasks as $task)
{
$temp = explode('-', $task->getDue());
$taskArray[intval($temp[2])][]=$task;
}
$month = date('n');
$day = date('j');
$year = date('Y');
echo "<table width=\"85%\" style=\"border-collapse: collapse\"><tr valign=\"top\">\n";
for($i = 0; $i < 7; $i++)
{
echo "<td style=\"width: 14%\" class=\"calbord\">";
echo "<div class=\"prop\"> </div>";
echo "<div class=\"dateHeading\">".date( "D n/d", mktime( 0,0,0,$month,$day+$i,$year ) )."</div>";
$d = date('j', mktime(0, 0, 0, $month, $day+$i, $year));
if(isset($eventArray[$d]))
{
foreach($eventArray[$d] as $event)
{
echo "<a href=\"#\" onmouseover=\"showEvent(".$event->getID().", event.clientX+document.documentElement.scrollLeft, event.clientY+document.documentElement.scrollTop);\" onmouseout=\"hideEvent(".$event->getID().");\" onclick=\"editwin=dhtmlwindow.open('editbox', 'div', 'event-view', 'View Event', 'width=350px,height=150px,left=300px,top=100px,resize=1,scrolling=1'); viewEvent('".htmlspecialchars($event->getName())."', '".htmlspecialchars($event->getDescAlmostJava())."', '".$event->getDate()."');\">".$event->getName()."</a><br />\n";
echo "<div class=\"event\" id=\"".$event->getID()."\">".$event->getName()."<br />".$event->getDate()."<br />".$event->getDescHTML()."</div>\n";
}
}
if(isset($taskArray[$d]))
{
echo 'Due:';
foreach($taskArray[$d] as $task)
echo "<a href=\"#\" onclick=\"editwin=dhtmlwindow.open('editbox', 'div', 'task-view', 'View Task', 'width=350px,height=150px,left=300px,top=100px,resize=1,scrolling=1'); viewTask('".htmlspecialchars($task->getName())."', '".htmlspecialchars($task->getCalDesc())."', '".$task->getDue()."');\">".$task->getName()."</a><br />";
}
echo "</td>";
}
echo "</tr></table>";
?>
</div>
<div id="container">
<div id="announcements">
<?php
$announcements = $currentGroup->getGroupAnnouncements();
echo "<h1>Announcements:</h1>\n";
foreach($announcements as $announcement)
{
echo "<div class=\"announcement\">\n";
if($currentUser->isGroupModerator($currentGroup))
echo "<a href=\"#\" onclick=\"editwin=dhtmlwindow.open('editbox', 'div', 'edit-announcement', 'Edit Announcement', 'width=500px,height=300px,left=300px,top=100px,resize=1,scrolling=1'); editAnnouncement(".$announcement->getID().", '".$announcement->getHeadingJava()."', '".$announcement->getBodyJava()."'); return false\">";
echo "<b>{$announcement->getHeading()}</b>";
if($currentUser->isGroupModerator($currentGroup))
echo "</a>";
echo "<br />".$announcement->getBody();
echo "</div><br />\n";
}
if(!count($announcements))
echo "Your group currently does not have any announcements.<br />";
if($currentUser->isGroupModerator($currentGroup))
echo "<a href=\"#\" onclick=\"addwin=dhtmlwindow.open('addbox', 'div', 'add-announcement', 'Create Announcement', 'width=500px,height=300px,left=300px,top=100px,resize=1,scrolling=1'); return false\">Click here to add an announcement.</a>";
?>
</div>
<div id="scratchpad">
<h1>Group Scratchpad</h1>
<div id="scratchpadtext">
<p>
<?php
if($currentGroup->getScratch()){
echo htmlspecialchars($currentGroup->getScratch());
}
else
echo "No scratchpad entry present";
?>
</p>
<?php
echo $scratchBlurb;
?>
<button id="scratchpadedit">Edit</button>
</div>
<form method="post" id="scratchpadform" action="grouphomepage.php"><fieldset>
<?php
if(!$currentUser->isGroupGuest($currentGroup))
{
echo "<textarea rows=\"10\" cols=\"40\" name=\"scratchpad\">".htmlspecialchars($currentGroup->getScratch())."</textarea><br />\n";
echo "<input type=\"submit\" name=\"scratch\" value=\"Update Scratchpad\" /> <input type=\"reset\" /><input id=\"canceledit\" value=\"Cancel\" /> \n";
}
?>
</fieldset></form>
</div>
<div id="recent">
<div class="box" id="email"><span class="box-header">Last 5 Emails</span>
<?php
$emails = $currentGroup->getRecentEmails();
if(count($emails) > 0)
{
echo "<ul>\n";
foreach($emails as $email)
echo "\t<li><a href=\"email.php?display=".$email->getID()."\">".htmlspecialchars($email->getSubject())."</a> <span class=\"timeago\">".$email->getShortDateTime()." ago</span></li>\n";
echo "</ul>\n";
}
else
echo "<p>Your group does not have any emails.</p>\n";
?>
</div>
<div class="box" id="files">
<span class="box-header">Last 5 Files</span>
<?php
$files = $currentGroup->getRecentFiles();
if(count($files) > 0)
{
echo "<ul>\n";
foreach($files as $file)
echo "\t<li><a href=\"download.php?id=".$file->getID()."\">".htmlspecialchars($file->getName())."</a> <span class=\"timeago\">".$file->getShortDateTime()." ago</span></li>\n";
echo "</ul>\n";
}
else
echo "<p>Your group does not have any files.</p>\n";
?>
</div>
<br class="clearboth" />
</div>
</div>
<?php
if($currentUser->isGroupModerator($currentGroup))
{
?>
<div class="window-content" id="add-announcement" style="display: none">
<form action="grouphomepage.php" method="post"><fieldset>
<label for="date">Expiration Date (MM/DD/YY):</label><input type="text" id="date" name="date" size="20" /><input type="button" onclick="calwin=dhtmlwindow.open('calbox', 'div', 'calendarmenu', 'Select date', 'width=600px,height=165px,left=300px,top=100px,resize=0,scrolling=0'); return false" value="Select Date" /><br />
<label for="heading">Heading:</label><input type="text" name="heading" id="heading" size="60" /><br />
<label for="body">Body:</label><br />
<textarea name="body" id="body" cols="55" rows="8"></textarea><br />
<input type="submit" name="addannouncement" value="Add Announcement" />
</fieldset></form>
</div>
<div class="window-content" id="edit-announcement" style="display: none">
<form action="grouphomepage.php" method="post"><fieldset>
<input type="hidden" name="id" id="editid" />
<label for="editheading">Heading:</label><input type="text" name="heading" id="editheading" size="60" /><br />
<label for="editbody">Body:</label><br />
<textarea name="body" id="editbody" cols="55" rows="8"></textarea><br />
<input type="submit" name="editannouncement" value="Edit Announcement" />
<input type="submit" name="deleteannouncement" value="Delete Announcement" />
</fieldset></form>
</div>
<?php
}
?>
<div class="window-content" id="event-view" style="display: none">
<b>Date</b>: <span id="viewdate"></span><br />
<b>Event name</b>: <span id="viewname"></span><br />
<b>Event description</b>:<br /><span id="viewdesc"></span>
</div>
<div class="window-content" id="task-view" style="display: none">
<b>Due Date</b>: <span id="taskdate"></span><br />
<b>Task name</b>: <span id="taskname"></span><br />
<b>Task description</b>:<br /><span id="taskdesc"></span>
</div>
<div id="calendarmenu" style="display: none">
<table>
<tr>
<?php
$currentMonth = date('n');
$currentYear = date('Y');
for($i = $currentMonth; $i < $currentMonth+4; $i++)
{
echo "<td valign=\"top\">";
echo "<table>";
echo "<tr><td colspan=\"7\">".date( "F Y", mktime( 0, 0, 0, $i, 1, $currentYear ) )."</td></tr>";
echo "<tr><td>S</td><td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td></tr>";
$startDay = date( "w", mktime( 0, 0, 0, $i, 1, $currentYear ) );
$endDay = date( "j", mktime( 0, 0, 0, $i+1, 0, $currentYear ) );
if($startDay)
echo "<tr><td colspan=\"$startDay\"></td>";
$weekDay = $startDay;
for($j = 1; $j <= $endDay; $j++)
{
if($weekDay == 0)
echo '<tr>';
echo "<td><a href=\"#\" onclick=\"document.getElementById('date').value='".date( "m/d/Y", mktime( 0,0,0,$i,$j,$currentYear ) )."'; calwin.close();\">$j</a></td>";
$weekDay++;
if($weekDay == 7)
{
echo "</tr>\n";
$weekDay = 0;
}
}
if($weekDay != 0)
echo "<td colspan=\"".(7-$weekDay)."\"></td></tr>";
echo "</table>";
echo "</td>";
}
?>
</tr>
</table>
</div>
<?php
//include rest of html layout file
require('htmlcontentfoot.php');// ends main container
?>
</body>
<script type="text/javascript">
$(document).ready(function(){
$("#scratchpadedit").click(function(){
$("#scratchpadtext").hide("slow",function(){
$("#scratchpadform").show("slow");
});
});
$("#canceledit").click(function(){
$("#scratchpadform").hide("slow",function(){
$("#scratchpadtext").show("slow");
});
});
});
</script></html>