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 pathtaskcomplete.php
More file actions
64 lines (61 loc) · 2.8 KB
/
taskcomplete.php
File metadata and controls
64 lines (61 loc) · 2.8 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
<?php
include_once('globals.php');
include_once('checklogin.php');
include_once('classes/task.php');
if(is_numeric($_GET['taskid']))
{
$task = new Task($_GET['taskid'], $currentGroup->getType(), $currentGroup->getSemester(), $db);
if($task->isValid())
{
if($currentUser->getID() != $task->getCreator()->getID() && !$currentUser->isGroupModerator($currentGroup))
errorPage('Access Denied', 'You must be either the task owner or a group moderator to close a task.', 403);
//else OK
}
else
errorPage('Invalid Task ID', 'The task ID provided is invalid.', 400);
$thedate = date('Y-m-d');
if($_POST['form'] == 'submit')
{
$subdate = strtotime($_POST['date']);
if($_POST['date'] !== false && $subdate <= time())
{
$task->setClosed($subdate);
header('Location: taskview.php?taskid='.$task->getID());
}
else if($_POST['date'] === false)
$message = 'ERROR: The entered date is not in a recognizable format. Please use the ISO 8601 format (YYYY-MM-DD).';
else //Remove this error message when time travel is invented
$message = 'ERROR: The entered date is in the future.';
}
}
else if($_GET['taskid'])
errorPage('Invalid Task ID', 'The task ID provided is invalid.', 400);
else
errorPage('Missing Task ID', 'No task ID was provided.', 400);
//------Start XHTML Output--------------------------------------//
require('doctype.php');
require('appearance.php');
echo "<link rel=\"stylesheet\" href=\"skins/$skin/tasks.css\" type=\"text/css\" title=\"$skin\" />\n";
foreach($altskins as $altskin)
echo "<link rel=\"alternate stylesheet\" href=\"skins/$altskin/tasks.css\" type=\"text/css\" title=\"$altskin\" />\n";
?>
<script type="text/javascript" src="Calendar.js"></script>
<script type="text/javascript">
var cal = new CalendarPopup("caldiv");
cal.showNavigationDropdowns();
</script>
<title><?php echo $appname; ?> - Close Task</title>
</head>
<body>
<?php
require('sidebar.php');
?>
<div id="content"><div id="topbanner"><?php echo $currentGroup->getName(); ?></div>
<?php
echo '<p>We are closing the task <b>'.$task->getName()."</b></p>\n";
echo "<form method=\"post\" action=\"taskcomplete.php?taskid={$_GET['taskid']}\" style=\"float: left\"><fieldset><legend>Complete Task</legend>\n";
echo "<label>Date completed: <input type=\"text\" name=\"date\" value=\"$thedate\" /></label> <a href=\"#\" onclick=\"cal.select(document.forms[0].date,'calsel','yyyy-MM-dd'); return false;\" id=\"calsel\">Select</a><br />\n";
echo "<input type=\"submit\" value=\"Complete Task\" /><input type=\"reset\" /><input type=\"hidden\" name=\"form\" value=\"submit\" />\n";
echo "<p>Cancel and <a href=\"tasks.php\">return to main tasks listing</a> or <a href=\"taskview.php?taskid={$task->getID()}\">return to task</a></p>\n</fieldset></form><div id=\"caldiv\"></div>\n";
?>
</div></body></html>