From 11287e11470e834ab06d6e8965b96c0d4ee28d27 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 24 Jun 2006 17:29:29 +0000 Subject: [PATCH] r868: We now actually send emails out. This means that the notification system is pretty much done. --- attachment.php | 2 +- editreport.php | 2 +- includes/class_notification.php | 37 +++++++++++++++++++++++++++++++++ newreport.php | 2 ++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/attachment.php b/attachment.php index 41e66c1..4a08ea3 100755 --- a/attachment.php +++ b/attachment.php @@ -147,7 +147,7 @@ if ($_POST['do'] == 'insert') // update the last post data $db->query("UPDATE " . TABLE_PREFIX . "bug SET lastposttime = " . $attachapi->values['dateline'] . ", hiddenlastposttime = " . $attachapi->values['dateline'] . ", lastpostby = " . $bugsys->userinfo['userid'] . ", hiddenlastpostby = " . $bugsys->userinfo['userid'] . " WHERE bugid = $bug[bugid]"); - print_r($notif); + $notif->finalize(); $message->redirect($lang->string('The attachment has been added to the bug.'), "showreport.php?bugid=$bug[bugid]"); } diff --git a/editreport.php b/editreport.php index 71ac01e..0dd57ea 100644 --- a/editreport.php +++ b/editreport.php @@ -198,7 +198,7 @@ if ($_POST['do'] == 'update') $notif->send_bug_changes_notice($fields, $fieldsnew); - print_r($notif); + $notif->finalize(); $message->redirect($lang->string('Your changes to the bug have been saved.'), "showreport.php?bugid=$bug[bugid]"); } diff --git a/includes/class_notification.php b/includes/class_notification.php index d7bdec8..3c460cd 100644 --- a/includes/class_notification.php +++ b/includes/class_notification.php @@ -546,6 +546,43 @@ Initial report: return $return; } + + // ################################################################### + /** + * Compiles and sends the actual emails to users. + * + * @access public + */ + function finalize() + { + $this->registry->mail->set('subject', sprintf($this->registry->lang->string('%1$s Bug Notification'), $this->registry->options['trackertitle'])); + foreach ($this->notices AS $userid => $noticelist) + { + if ($userid == $this->registry->userinfo['userid']) + { + continue; + } + + $this->registry->mail->to_add($this->users["$userid"]['displayname'], $this->users["$userid"]['email']); + $this->registry->mail->set('bodytext', sprintf($this->registry->lang->string('Hi %1$s, + +You are receiving this email because you have opted to get notifications for the %2$s bug tracker. Here are the notices: +################################################################### + +%3$s + +################################################################### +If you no longer want to receive email from us, please log into your account and click the "My Controls" tab at the top of the screen to change email preferences. + +%4$s'), + $this->users["$userid"]['displayname'], + $this->registry->options['trackertitle'], + implode("\n\n", $noticelist), + $this->registry->options['trackerurl'] + )); + $this->registry->mail->send(true); + } + } } /*=====================================================================*\ diff --git a/newreport.php b/newreport.php index 489b237..ca96da2 100755 --- a/newreport.php +++ b/newreport.php @@ -106,6 +106,8 @@ if ($_POST['do'] == 'insert') $notif->send_new_bug_notice($bug->values, $comment->values); + $notif->finalize(); + $bug = new BugAPI($bugsys); // need to destroy because update will think the insert fields need to be changed, too $bug->set('bugid', $comment->values['bugid']); $bug->set_condition(); -- 2.22.5