Gnucomo-0.0.8: September 4th 2003
$Log: gcm_daemon.php,v $
- Revision 1.18 2003-12-03 08:07:21 arjen
+ Revision 1.19 2004-01-10 20:04:12 arjen
+ Send email about open notifications to an object's users.
+
+ Revision 1.18 2003/12/03 08:07:21 arjen
Changed the type of log_adv_daemon_email.delay and log_adv_daemon_email.xdelay
from time to interval. These delays can be more than 24 hours.
*/
-// $Id: gcm_daemon.php,v 1.18 2003-12-03 08:07:21 arjen Exp $
+// $Id: gcm_daemon.php,v 1.19 2004-01-10 20:04:12 arjen Exp $
ini_set('include_path', '.:./classes:../phpclasses');
ini_set('html_errors', 'false');
process_log ();
service_check();
find_notifications();
+ mail_notifications();
// Gather the statistics for each object
}
}
+/*
+ * find open notifications and send an email to the object's users.
+ */
+
+function mail_notifications ()
+{
+ global $dbms;
+
+ $notifres = $dbms->query("SELECT notificationid, objectid, type_of_issueid FROM notification
+ WHERE statuscode != 'cls'");
+
+ for ($notifrow = 0; $notifrow < pg_numrows($notifres); $notifrow++)
+ {
+ $notification = pg_fetch_object($notifres, $notifrow);
+
+ $issue = pg_fetch_object($dbms->query("SELECT description FROM type_of_issue
+ WHERE type_of_issueid='" . $notification->type_of_issueid . "'"), 0);
+ $object = pg_fetch_object($dbms->query("SELECT objectname FROM object
+ WHERE objectid='" . $notification->objectid ."'"), 0);
+
+ $users = $dbms->query("SELECT username FROM object_user WHERE objectid='" . $notification->objectid . "'");
+
+ for ($userrow = 0; $userrow < pg_numrows($users); $userrow++)
+ {
+ $objusr = pg_fetch_object($users, $userrow);
+ $usr = pg_fetch_object($dbms->query("SELECT email FROM usr
+ WHERE username='" . $objusr->username . "'"), 0);
+
+ $message = "Notification " . $notification->notificationid . ": " . $issue->description;
+ $message .= " for object " . $object->objectname . "\n";
+
+ mail($usr->email, "GnuCoMo Notification", $message);
+ }
+ }
+}
+
?>