From 652a4934041a224486c7d732bc931d802ce58f42 Mon Sep 17 00:00:00 2001 From: arjen Date: Sat, 10 Jan 2004 20:04:12 +0000 Subject: [PATCH] Send email about open notifications to an object's users. --- src/gcm_daemon/gcm_daemon.php | 44 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/src/gcm_daemon/gcm_daemon.php b/src/gcm_daemon/gcm_daemon.php index 440d723..3ad8240 100755 --- a/src/gcm_daemon/gcm_daemon.php +++ b/src/gcm_daemon/gcm_daemon.php @@ -20,7 +20,10 @@ 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. @@ -63,7 +66,7 @@ */ -// $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'); @@ -206,6 +209,7 @@ do process_log (); service_check(); find_notifications(); + mail_notifications(); // Gather the statistics for each object @@ -570,5 +574,41 @@ function find_notifications () } } +/* + * 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); + } + } +} + ?> -- 2.11.0