-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask_action.php
More file actions
77 lines (64 loc) · 2.78 KB
/
Copy pathtask_action.php
File metadata and controls
77 lines (64 loc) · 2.78 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
<?php
// $Header: /cvsroot/tsheet/timesheet.php/task_action.php,v 1.7 2005/05/23 07:32:00 vexil Exp $
// Authenticate
require("class.AuthenticationManager.php");
require("class.CommandMenu.php");
if (!$authenticationManager->isLoggedIn() || !$authenticationManager->hasAccess('aclTasks')) {
Header('Location: login.php?clearanceRequired=' . get_acl_level('aclTasks'));
exit;
}
// Connect to database.
$dbh = dbConnect();
$contextUser = strtolower($_SESSION['contextUser']);
//load local vars from superglobals
$action = $_REQUEST["action"];
$task_id = isset($_REQUEST["task_id"]) ? mysqli_real_escape_string($dbh, $_REQUEST["task_id"]): 0;
$proj_id = $_REQUEST["proj_id"];
if ($action == "add" || $action == "edit") {
$name = mysqli_real_escape_string($dbh, $_REQUEST["name"]);
$description = mysqli_real_escape_string($dbh, $_REQUEST["description"]);
$assigned = isset($_REQUEST["assigned"]) ? $_REQUEST['assigned']: array();
//array_walk($assigned, $authenticationManager->escape_string);
$task_status = mysqli_real_escape_string($dbh, $_REQUEST["task_status"]);
}
//create a time string for >>now<<
$time_string = date("Y-m-d H:i:00");
if (!isset($action))
Header("Location: $HTTP_REFERER");
elseif ($action == "add") {
$name = addslashes($name);
$description = addslashes($description);
list($qh, $num) = dbQuery("INSERT INTO $TASK_TABLE (proj_id, name, description, assigned, started, status) VALUES ".
"('$proj_id', '$name','$description', ".
"'$time_string', '$time_string', '$task_status')");
$task_id = dbLastID($dbh);
if (isset($assigned)) {
while (list(,$username) = each($assigned))
dbQuery("INSERT INTO $TASK_ASSIGNMENTS_TABLE (proj_id, task_id, username) VALUES ($proj_id, $task_id, '$username')");
}
// redirect to the task management page (we're done)
Header("Location: task_maint.php?proj_id=$proj_id");
} elseif ($action == "edit") {
$name = addslashes($name);
$description = addslashes($description);
$query = "UPDATE $TASK_TABLE SET name='$name',description='$description',".
" status='$task_status' ";
if ($task_status=='Complete') {
$query .= ",completed='$time_string'";
}
$query .= " WHERE task_id=$task_id";
list($qh,$num) = dbquery($query);
if ($assigned) {
dbQuery("DELETE FROM $TASK_ASSIGNMENTS_TABLE WHERE task_id = $task_id");
while (list(,$username) = each($assigned))
dbQuery("INSERT INTO $TASK_ASSIGNMENTS_TABLE(proj_id, task_id, username) VALUES ($proj_id, $task_id, '$username')");
}
// we're done so redirect to the task management page
Header("Location: task_maint.php?proj_id=$proj_id");
} elseif ($action == 'delete') {
dbQuery("DELETE FROM $TASK_TABLE WHERE task_id = $task_id");
dbQuery("DELETE FROM $TASK_ASSIGNMENTS_TABLE WHERE task_id = $task_id");
Header("Location: task_maint.php?proj_id=$proj_id");
}
// vim:ai:ts=4:sw=4
?>