***********************
** FILE NAME : notification.php
** SYSTEM NAME : Gnucomo - Gnu Computer Monitoring
-** VERSION NUMBER : $Revision: 1.1 $
+** VERSION NUMBER : $Revision: 1.6 $
**
** DESCRIPTION : Display and handle notifications.
** There are two major views to this page: either a list of
********************************
** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
** CREATION DATE : Dec 12, 2002
-** LAST UPDATE : Feb 04, 2003
+** LAST UPDATE : Feb 16, 2003
** MODIFICATIONS :
**************************************************************************/
/*****************************
$Log: notification.php,v $
- Revision 1.1 2003-02-05 09:48:14 arjen
+ Revision 1.6 2007-12-10 16:27:33 arjen
+ Added an option to perform one action on multiple notifications at once.
+
+ Revision 1.5 2007/11/21 14:38:06 arjen
+ The buttonbar at the top of each page is now a fixed 'div' element
+ instead of a framed page.
+ Contributed by Edwin Nadorp.
+
+ Revision 1.4 2007/01/11 13:44:29 arjen
+ Manually edit parameters.
+ View logs from abusing IP addresses.
+
+ Revision 1.3 2003/02/21 08:49:16 arjen
+ Keep a record of each time a notification
+ is displayed. Either on a listing or in detail.
+
+ Revision 1.2 2003/02/13 09:01:29 arjen
+ All web interface pages use the page class.
+
+ Revision 1.1 2003/02/05 09:48:14 arjen
Added display and handling of notifications
******************************/
-// RCSID = "$Id: notification.php,v 1.1 2003-02-05 09:48:14 arjen Exp $";
+// RCSID = "$Id: notification.php,v 1.6 2007-12-10 16:27:33 arjen Exp $";
-ini_set('include_path', './classes:../phpclasses');
+ini_set('include_path', '.:./classes:../phpclasses');
require_once('page.class.php');
{
?>
-<script language='JavaScript'>
+<script type='text/ecmascript'>
function CheckRemark(f)
{
function add_action($db, $note, $actionid, $remark)
{
- $r = pg_exec($db, "SELECT statuscode FROM action WHERE actionid=" . $actionid);
+ $r = pg_exec($db, "SELECT statuscode FROM action WHERE actionid=CAST('" . $actionid."' AS BIGINT)");
$action = pg_fetch_object($r, 0);
if ($action->statuscode != "" && $note->statuscode != $action->statuscode)
class notification_page extends page
{
+ function notification_list($objectid)
+ {
+
+ // Display a list of all notifications for this object['oid']
+
+ $res = pg_exec($this->database, "SELECT objectname FROM object WHERE objectid=" . $objectid);
+ $obj = pg_fetch_object($res, 0);
+ echo "<h1>Notifications for " . $obj->objectname . "</h1><hr>";
+
+ $res = pg_exec($this->database, "SELECT notificationid, timestamp, type_of_issueid,
+ statuscode, priority
+ FROM notification WHERE objectid= CAST ('"
+ . $objectid ."' AS BIGINT) AND statuscode != 'cls'"
+ . " ORDER BY notificationid");
+
+ echo "<table>";
+ echo '<tr><th>Time</th><th>Number</th><th>Issue</th><th>Status</th><th>Priority</th></tr>';
+ $row = 0;
+ while ($row < pg_num_rows($res))
+ {
+ $note = pg_fetch_object($res, $row);
+ $r = pg_exec($this->database, "SELECT name from type_of_issue WHERE type_of_issueid = CAST('"
+ . $note->type_of_issueid . "' AS BIGINT)");
+ $issue = pg_fetch_object($r, 0);
+ echo "<tr><td align='center'>\n";
+ echo $note->timestamp;
+ echo "</td><td>";
+ echo $note->notificationid;
+ echo "</td><td>";
+ echo "<a href='notification.php?notid=";
+ echo $note->notificationid;
+ echo "'>";
+ echo $issue->name;
+ echo "</a>";
+ echo "</td><td>";
+ echo $note->statuscode;
+ echo "</td><td>";
+ echo $note->priority;
+ echo "</td></tr>\n";
+ $row++;
+
+ //Save evidence that this notification was presented to the user.
+ //$note->statuscode = add_action($this->database, $note, 21,
+ // "This notification was displayed with others from the same object");
+ }
+ echo "</table>";
+ }
+
function display_notification($note)
{
- $res = pg_exec($this->database, "SELECT objectname FROM object WHERE objectid=" . $note->objectid);
+ $res = pg_exec($this->database, "SELECT objectname FROM object WHERE objectid= CAST ('" . $note->objectid . "' AS BIGINT)");
$obj = pg_fetch_object($res, 0);
echo "<h1>Notification " . $note->notificationid . " for " . $obj->objectname . "</h1><hr>";
+ echo "<script type='text/ecmascript'>document.getElementById('menu_title').innerHTML = '<h1>Notification " . $note->notificationid . " for " . $obj->objectname . "<\/h1>'</script><br>";
- $r = pg_exec($this->database, "SELECT description from type_of_issue WHERE type_of_issueid ="
- . $note->type_of_issueid);
+ $r = pg_exec($this->database, "SELECT description FROM type_of_issue WHERE type_of_issueid = CAST ('"
+ . $note->type_of_issueid . "' AS BIGINT)");
$issue = pg_fetch_object($r, 0);
$r = pg_exec($this->database, "SELECT statusname FROM status
echo "<tr><th>Time</th><th>User</th><th>Remarks</th></tr>";
$r = pg_exec($this->database, "SELECT actionid, username, timestamp, remarks
- FROM action_user WHERE notificationid=" . $note->notificationid
- ." ORDER BY timestamp");
+ FROM action_user WHERE notificationid= CAST ('"
+ . $note->notificationid . "' AS BIGINT )"
+ ." ORDER BY timestamp");
for ($row = 0; $row < pg_numrows($r); $row++)
{
$action_user = pg_fetch_object($r, $row);
- echo "<tr><td>";
+ echo "<tr><td class='time'>";
echo $action_user->timestamp;
echo "</td><td>";
echo $action_user->username;
$r = pg_exec($this->database, "SELECT * FROM parameter WHERE paramid IN
( SELECT paramid FROM parameter_notification
- WHERE notificationid = " . $note->notificationid . ")");
+ WHERE notificationid = CAST ('" . $note->notificationid
+ . "' AS BIGINT) )");
if (pg_numrows($r) > 0)
{
echo "<h2>Parameters involved in this notification</h2>";
for ($row = 0; $row < pg_numrows($r); $row++)
{
$p = pg_fetch_object($r, $row);
- $res = pg_exec($this->database, "SELECT * from history WHERE paramid=" . $p->paramid
- . " ORDER BY modified");
+ $res = pg_exec($this->database, "SELECT * from history WHERE paramid= CAST('" . $p->paramid
+ . "' AS BIGINT) ORDER BY modified");
echo "<tr><td>";
echo $p->class;
$r = pg_exec($this->database, "SELECT * FROM log WHERE logid IN
( SELECT logid FROM log_notification
- WHERE notificationid = " . $note->notificationid . ")");
+ WHERE notificationid = CAST ('"
+ . $note->notificationid . "' AS BIGINT)) ORDER BY object_timestamp");
if (pg_numrows($r) > 0)
{
echo "<h2>Log entries involved in this notification</h2>";
echo "</td><td>";
echo $p->servicecode;
echo "</td><td>";
- echo $p->rawdata;
+ echo htmlentities($p->rawdata);
echo "</td></tr>";
}
$possible_action = array
(
- "opn" => array (3, 6, 7),
+ "opn" => array (3, 6, 7, 13),
"pen" => array (3, 6, 7, 8, 11, 18),
"inv" => array (3, 9),
"vrf" => array (12, 13),
);
echo "<h2>Enter a remark for the next action</h2>";
- echo "<form method='post' onSubmit='return CheckRemark(this)'>";
- echo "<textarea name='remark'></textarea><br>";
+ echo "<form method='post' onSubmit='return CheckRemark(this)' action=''>";
+ echo "<textarea name='remark' cols='30' rows='5'></textarea><br>";
/* Display a list of possible actions */
- echo "<h2>Select on of the actions to take below</h2>";
+ echo "<h2>Select one of the actions to take below</h2>";
$first = true;
foreach ($possible_action[$note->statuscode] as $act)
{
- $action = pg_fetch_object(pg_exec("SELECT description FROM action WHERE actionid=$act"),0);
+ $action = pg_fetch_object(pg_exec("SELECT description FROM action WHERE actionid= CAST('"
+ . $act . "' AS BIGINT)"),0);
echo "<input type='radio' name='actionid'";
if ($first)
{
$first = false;
- echo " checked='on'";
+ echo " CHECKED";
}
echo " value='$act'>" . $action->description . "<br>";
}
+ echo "<input type='checkbox' name='act_on_all'>Perform this action on all notifications with the same issue.<br>";
echo "<input type='submit' value='Submit action'>";
echo "</form>";
}
$res = pg_exec($this->database, "SELECT objectname FROM object WHERE objectid=" . $_GET['oid']);
$obj = pg_fetch_object($res, 0);
- echo "<h1>Notifications for " . $obj->objectname . "</h1><hr>";
+ echo "<script type='text/ecmascript'>document.getElementById('menu_title').innerHTML = '<h1>Notifications for " . $obj->objectname . "<\/h1>'</script><br>";
$res = pg_exec($this->database, "SELECT notificationid, timestamp, type_of_issueid,
statuscode, priority
- FROM notification WHERE objectid=" . $_GET['oid']
- . " ORDER BY notificationid");
+ FROM notification WHERE objectid= CAST ('"
+ . $_GET['oid'] ."' AS BIGINT) AND statuscode != 'cls'"
+ . " ORDER BY notificationid");
echo "<table>";
+ echo '<tr><th>Time</th><th>Number</th><th>Issue</th><th>Status</th><th>Priority</th></tr>';
$row = 0;
while ($row < pg_numrows($res))
{
$note = pg_fetch_object($res, $row);
- $r = pg_exec($this->database, "SELECT name from type_of_issue WHERE type_of_issueid ="
- . $note->type_of_issueid);
+ $r = pg_exec($this->database, "SELECT name from type_of_issue WHERE type_of_issueid = CAST('"
+ . $note->type_of_issueid . "' AS BIGINT)");
$issue = pg_fetch_object($r, 0);
echo "<tr><td align='center'>\n";
echo $note->timestamp;
echo $note->priority;
echo "</td></tr>\n";
$row++;
+
+ //Save evidence that this notification was presented to the user.
+ //$note->statuscode = add_action($this->database, $note, 21,
+ // "This notification was displayed with others from the same object");
}
echo "</table>";
}
// Display all information about a single notification['notid']
- $res = pg_exec($this->database, "SELECT * from notification
- WHERE notificationid=" . $_GET['notid']);
+ $local_sql = "SELECT * from notification
+ WHERE notificationid = CAST('" . $_GET['notid'] . "' AS BIGINT)";
+ $res = pg_exec($this->database, $local_sql);
$note = pg_fetch_object($res, 0);
+ //Gather proof that the notification has been presented
if ($note->statuscode == 'new')
{
- $note->statuscode = add_action($this->database, $note, 2, "Displayed through web interface");
+ $note->statuscode = add_action($this->database, $note, 2,
+ "Notification displayed in detail through web interface");
}
-
+ else
+ {
+ $note->statuscode = add_action($this->database, $note, 20,
+ "Notification redisplayed in detail through web interface");
+ }
$this->display_notification($note);
echo "<hr>";
$this->notification_form($note);
+ $this->notification_list($note->objectid);
}
else if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_GET['notid']))
{
WHERE notificationid=" . $_GET['notid']);
$note = pg_fetch_object($res, 0);
- $note->statuscode = add_action($this->database, $note, $_POST['actionid'], $_POST['remark']);
+ if (!empty($_POST['act_on_all']))
+ {
+ // Perform the action on all notifications with the same object and issue.
+ $res = pg_exec($this->database, "SELECT notificationid, timestamp, type_of_issueid, statuscode
+ FROM notification WHERE objectid= CAST ('"
+ . $note->objectid ."' AS BIGINT) AND statuscode != 'cls'
+ AND type_of_issueid = '" . $note->type_of_issueid
+ . "' ORDER BY notificationid");
+ for ($row = 0; $row < pg_num_rows($res); $row++)
+ {
+ $similar_note = pg_fetch_object($res, $row);
+ $new_statuscode = add_action($this->database, $similar_note,
+ $_POST['actionid'], $_POST['remark']);
+ if ($similar_note->notificationid == $note->notificationid)
+ {
+ $note->statuscode = $new_statuscode;
+ }
+ }
+ }
+ else
+ {
+ $note->statuscode = add_action($this->database, $note, $_POST['actionid'], $_POST['remark']);
+ }
$this->display_notification($note);
echo "<hr>";
$this->notification_form($note);
+ $this->notification_list($note->objectid);
}
else
{