statuscode != "" && $note->statuscode != $action->statuscode) { // Update the status of the notification. $note->statuscode = $action->statuscode; pg_exec($db, "UPDATE notification SET statuscode='" . $note->statuscode . "' WHERE notificationid = " . $note->notificationid); } // Add the action to the action_user table. pg_exec($db, "INSERT INTO action_user (actionid, username, notificationid, timestamp, statuscode, remarks) values ('$actionid', '" . $_SESSION['username'] . "', '" . $note->notificationid . "', '" . date('Y-m-d H:i:s') . "', '" . $note->statuscode . "', '" . $remark . "')"); return $note->statuscode; } class notification_page extends page { function display_notification($note) { $res = pg_exec($this->database, "SELECT objectname FROM object WHERE objectid= CAST ('" . $note->objectid . "' AS BIGINT)"); $obj = pg_fetch_object($res, 0); echo "

Notification " . $note->notificationid . " for " . $obj->objectname . "


"; $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 WHERE statuscode = '" . $note->statuscode . "'"); $status = pg_fetch_object($r, 0); echo "Issue : " . $issue->description . ", Priority " . $note->priority . "
"; echo "Creation time : " . $note->timestamp . "
"; echo "Current status : " . $status->statusname . "
"; // List all actions that occurred on this notification echo "

Action history for notification " . $note->notificationid . "

"; echo ""; echo ""; $r = pg_exec($this->database, "SELECT actionid, username, timestamp, remarks 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 ""; } echo "
TimeUserRemarks
"; echo $action_user->timestamp; echo ""; echo $action_user->username; echo ""; echo htmlspecialchars(stripslashes($action_user->remarks)); echo "
"; // See if we can list any parameters for this notification $r = pg_exec($this->database, "SELECT * FROM parameter WHERE paramid IN ( SELECT paramid FROM parameter_notification WHERE notificationid = CAST ('" . $note->notificationid . "' AS BIGINT) )"); if (pg_numrows($r) > 0) { echo "

Parameters involved in this notification

"; echo ""; echo ""; for ($row = 0; $row < pg_numrows($r); $row++) { $p = pg_fetch_object($r, $row); $res = pg_exec($this->database, "SELECT * from history WHERE paramid= CAST('" . $p->paramid . "' AS BIGINT) ORDER BY modified"); echo ""; } echo "
ClassNameDescriptionHistory
"; echo $p->class; echo ""; echo $p->name; echo ""; echo $p->description; echo ""; for ($hrow = 0; $hrow < pg_numrows($res); $hrow++) { $hist = pg_fetch_object($res, $hrow); echo $hist->modified . " "; echo $hist->change_nature . " "; echo $hist->changed_property . " "; echo $hist->new_value; echo "
"; } echo "
"; } // See if we can list any log entries for this notification $r = pg_exec($this->database, "SELECT * FROM log WHERE logid IN ( SELECT logid FROM log_notification WHERE notificationid = CAST ('" . $note->notificationid . "' AS BIGINT))"); if (pg_numrows($r) > 0) { echo "

Log entries involved in this notification

"; echo ""; echo ""; for ($row = 0; $row < pg_numrows($r); $row++) { $p = pg_fetch_object($r, $row); echo ""; } echo "
TimeServiceLog entry
"; echo $p->object_timestamp; echo ""; echo $p->servicecode; echo ""; echo $p->rawdata; echo "
"; } } function notification_form($note) { /* * Depending on the state of the notification, specific actions * are possible. One such actions determines a transition to * the next state. The array $possible_action lists the state transitions * for each state. */ $possible_action = array ( "opn" => array (3, 6, 7), "pen" => array (3, 6, 7, 8, 11, 18), "inv" => array (3, 9), "vrf" => array (12, 13), "cls" => array (19) ); echo "

Enter a remark for the next action

"; echo "
"; echo "
"; /* Display a list of possible actions */ echo "

Select one of the actions to take below

"; $first = true; foreach ($possible_action[$note->statuscode] as $act) { $action = pg_fetch_object(pg_exec("SELECT description FROM action WHERE actionid= CAST('" . $act . "' AS BIGINT)"),0); echo "" . $action->description . "
"; } echo ""; echo "
"; } function Body() { if ($_SERVER['REQUEST_METHOD'] == 'GET' && !empty($_GET['oid'])) { // Display a list of all notifications for this object['oid'] $res = pg_exec($this->database, "SELECT objectname FROM object WHERE objectid=" . $_GET['oid']); $obj = pg_fetch_object($res, 0); echo "

Notifications for " . $obj->objectname . "


"; $res = pg_exec($this->database, "SELECT notificationid, timestamp, type_of_issueid, statuscode, priority FROM notification WHERE objectid= CAST ('" . $_GET['oid'] ."' AS BIGINT) AND statuscode != 'cls'" . " ORDER BY notificationid"); echo ""; $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 = CAST('" . $note->type_of_issueid . "' AS BIGINT)"); $issue = pg_fetch_object($r, 0); echo "\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 "
\n"; echo $note->timestamp; echo ""; echo $note->notificationid; echo ""; echo ""; echo $issue->name; echo ""; echo ""; echo $note->statuscode; echo ""; echo $note->priority; echo "
"; } else if ($_SERVER['REQUEST_METHOD'] == 'GET' && !empty($_GET['notid'])) { clientscripts(); // Display all information about a single notification['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, "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 "
"; $this->notification_form($note); } else if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_GET['notid'])) { clientscripts(); // Display all information about a single notification['notid'] $res = pg_exec($this->database, "SELECT * from notification WHERE notificationid=" . $_GET['notid']); $note = pg_fetch_object($res, 0); $note->statuscode = add_action($this->database, $note, $_POST['actionid'], $_POST['remark']); $this->display_notification($note); echo "
"; $this->notification_form($note); } else { echo "

Insufficient input to create page

"; phpinfo(); } } } $notif_page = new notification_page("Gnucomo Notifications"); $notif_page->Showpage(); ?>