2 require_once("{$GLOBALS['srcdir']}/sql.inc");
4 function getPnoteById($id, $cols = "*")
6 return sqlQuery("SELECT $cols FROM pnotes WHERE id='$id' " .
7 "order by date DESC limit 0,1");
10 function getPnotesByDate($date, $activity = "1", $cols = "*", $pid = "%",
11 $limit = "all", $start = 0, $username = '')
13 $sql = "SELECT $cols FROM pnotes WHERE date LIKE '%$date%' " .
14 "AND pid LIKE '$pid' ";
15 if ($activity != "all")
16 $sql .= "AND activity = '$activity' ";
18 $sql .= "AND assigned_to = '$username' ";
19 $sql .= "ORDER BY date DESC";
21 $sql .= " LIMIT $start, $limit";
23 $res = sqlStatement($sql);
25 for ($iter = 0;$row = sqlFetchArray($res);$iter++)
30 function getPnotesByPid ($pid, $activity = "1", $cols = "*", $limit=10, $start=0)
32 $res = sqlStatement("SELECT $cols FROM pnotes WHERE pid LIKE '$pid' " .
33 "AND activity = '$activity' ORDER BY date DESC LIMIT $start,$limit");
34 for ($iter = 0; $row = sqlFetchArray($res); $iter++)
39 function addPnote($pid, $newtext, $authorized = '0', $activity = '1',
40 $title='Unassigned', $assigned_to = '')
42 $body = date('Y-m-d H:i') . ' (' . $_SESSION['authUser'];
43 if ($assigned_to) $body .= " to $assigned_to";
44 $body = addslashes($body . ') ' . $newtext);
46 return sqlInsert("INSERT INTO pnotes (date, body, pid, user, groupname, " .
47 "authorized, activity, title, assigned_to) VALUES (NOW(), '$body', '$pid', '" .
48 $_SESSION['authUser'] . "', '". $_SESSION['authProvider'] .
49 "', '$authorized', '$activity', '$title', '$assigned_to')");
52 function updatePnote($id, $newtext, $title, $assigned_to)
54 $row = getPnoteById($id);
55 if (! $row) die("updatePnote() did not find id '$id'");
56 $activity = $assigned_to ? '1' : '0';
58 $body = $row['body'] . "\n" . date('Y-m-d H:i') .
59 ' (' . $_SESSION['authUser'];
60 if ($assigned_to) $body .= " to $assigned_to";
61 $body = addslashes($body . ') ' . $newtext);
63 sqlStatement("UPDATE pnotes SET " .
64 "body = '$body', activity = '$activity', title='$title', " .
65 "assigned_to = '$assigned_to' WHERE id = '$id'");
68 function authorizePnote($id, $authorized = "1")
70 sqlQuery("UPDATE pnotes SET authorized = '$authorized' WHERE id = '$id'");
73 function disappearPnote($id)
75 sqlStatement("UPDATE pnotes SET activity = '0' WHERE id='$id'");
79 function reappearPnote ($id)
81 sqlStatement("UPDATE pnotes SET activity = '1' WHERE id='$id'");