Keep a record of each time a notification
authorarjen <arjen>
Fri, 21 Feb 2003 08:49:16 +0000 (08:49 +0000)
committerarjen <arjen>
Fri, 21 Feb 2003 08:49:16 +0000 (08:49 +0000)
is displayed. Either on a listing or in detail.

src/web/notification.php

index c2791e8..c687b6d 100644 (file)
@@ -9,7 +9,7 @@
 ***********************
 **      FILE NAME      : notification.php
 **      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
-**      VERSION NUMBER : $Revision: 1.2 $
+**      VERSION NUMBER : $Revision: 1.3 $
 **
 **  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.2  2003-02-13 09:01:29  arjen
+   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
@@ -44,7 +48,7 @@
 
 ******************************/
 
-// RCSID = "$Id: notification.php,v 1.2 2003-02-13 09:01:29 arjen Exp $";
+// RCSID = "$Id: notification.php,v 1.3 2003-02-21 08:49:16 arjen Exp $";
 
 ini_set('include_path', '.:./classes:../phpclasses');
 
@@ -78,7 +82,7 @@ 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)
@@ -107,12 +111,12 @@ class notification_page extends page
 
    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>";
 
-      $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
@@ -131,13 +135,14 @@ class notification_page extends page
       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;
@@ -151,7 +156,8 @@ class notification_page extends page
 
       $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>";
@@ -161,8 +167,8 @@ class notification_page extends page
          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;
@@ -190,7 +196,8 @@ class notification_page extends page
 
       $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))");
       if (pg_numrows($r) > 0)
       {
          echo "<h2>Log entries involved in this notification</h2>";
@@ -239,13 +246,14 @@ class notification_page extends page
 
       /*  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)
          {
@@ -273,16 +281,17 @@ class notification_page extends page
 
          $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>";
          $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;
@@ -300,6 +309,10 @@ class notification_page extends page
             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>";
       }
@@ -309,15 +322,22 @@ class notification_page extends page
 
          //  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);