Manually edit parameters.
[gnucomo.git] / src / web / notification.php
index c687b6d..d779819 100644 (file)
@@ -9,7 +9,7 @@
 ***********************
 **      FILE NAME      : notification.php
 **      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
-**      VERSION NUMBER : $Revision: 1.3 $
+**      VERSION NUMBER : $Revision: 1.4 $
 **
 **  DESCRIPTION      : Display and handle notifications.
 **                     There are two major views to this page: either a list of
 
 /*****************************
    $Log: notification.php,v $
-   Revision 1.3  2003-02-21 08:49:16  arjen
+   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.
 
@@ -48,7 +52,7 @@
 
 ******************************/
 
-// RCSID = "$Id: notification.php,v 1.3 2003-02-21 08:49:16 arjen Exp $";
+// RCSID = "$Id: notification.php,v 1.4 2007-01-11 13:44:29 arjen Exp $";
 
 ini_set('include_path', '.:./classes:../phpclasses');
 
@@ -109,6 +113,53 @@ function add_action($db, $note, $actionid, $remark)
 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>";
+      $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 "<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= CAST ('" . $note->objectid . "' AS BIGINT)");
@@ -197,7 +248,7 @@ class notification_page extends page
       $r = pg_exec($this->database, "SELECT * FROM log WHERE logid IN
                                      ( SELECT logid FROM log_notification
                                      WHERE notificationid = CAST ('" 
-                                     . $note->notificationid . "' AS BIGINT))");
+                                     . $note->notificationid . "' AS BIGINT)) ORDER BY object_timestamp");
       if (pg_numrows($r) > 0)
       {
          echo "<h2>Log entries involved in this notification</h2>";
@@ -213,7 +264,7 @@ class notification_page extends page
             echo "</td><td>";
             echo $p->servicecode;
             echo "</td><td>";
-            echo $p->rawdata;
+            echo htmlentities($p->rawdata);
             echo "</td></tr>";
 
          }
@@ -233,7 +284,7 @@ class notification_page extends page
 
       $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),
@@ -311,8 +362,8 @@ class notification_page extends page
             $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");
+           //$note->statuscode = add_action($this->database, $note, 21,
+            //            "This notification was displayed with others from the same object");
          }
          echo "</table>";
       }
@@ -341,6 +392,7 @@ class notification_page extends page
          $this->display_notification($note);
          echo "<hr>";
          $this->notification_form($note);
+         $this->notification_list($note->objectid);
       }
       else if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_GET['notid']))
       {
@@ -356,6 +408,7 @@ class notification_page extends page
          $this->display_notification($note);
          echo "<hr>";
          $this->notification_form($note);
+         $this->notification_list($note->objectid);
       }
       else
       {