From 5d80d5c623742684c03edd928e536f1cc09bf012 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 24 Jun 2006 16:17:54 +0000 Subject: [PATCH] r867: Finished new bug notices --- includes/class_notification.php | 51 +++++++++++++++++++++++++++++++++ newreport.php | 5 ++++ 2 files changed, 56 insertions(+) diff --git a/includes/class_notification.php b/includes/class_notification.php index e07b0d4..d7bdec8 100644 --- a/includes/class_notification.php +++ b/includes/class_notification.php @@ -459,6 +459,57 @@ View: %6$s } } + // ################################################################### + /** + * Sends a new bug notification notice to all those who have the option + * turned no. This does not use fetch_users_with_on_bit() because a + * query is more effective. + * + * @access public + * + * @param array Bug values array + * @param array Comment values array + */ + function send_new_bug_notice($bug, $comment) + { + $userinfo = $this->registry->db->query(" + SELECT user.*, useremail.* + FROM " . TABLE_PREFIX . "useremail AS useremail + LEFT JOIN " . TABLE_PREFIX . "user AS user + ON (user.userid = useremail.userid) + WHERE useremail.relation = 0 + AND useremail.mask & " . $this->registry->emailoptions['notifications']['newbug'] . " + "); + while ($user = $this->registry->db->fetch_array($userinfo)) + { + if (!is_array($this->users["$user[userid]"])) + { + $this->notices["$user[userid]"][] = sprintf( +$this->registry->lang->string(' +This bug has been added to the database: +============================================ +Bug ID: %1$s +Summary: %2$s +Reporter: %3$s +Product/Component/Version: %4$s +Initial report: +-------------------------------------------- +%5$s +-------------------------------------------- +============================================'), + $bug['bugid'], + $bug['summary'], + construct_user_display($this->registry->userinfo, false), + $this->registry->datastore['product']["$bug[productid]"]['title'] . '/' . (($bug['componentid']) ? $this->registry->datastore['product']["$bug[componentid]"]['title'] . '/' : '') . $this->registry->datastore['version']["$bug[versionid]"]['version'], + $comment['comment'] + ); + $this->users["$user[userid]"] = $user; + unset($this->users["$user[userid]"]['mask'], $this->users["$user[userid]"]['relation']); + } + $this->users["$user[userid]"]['options']["$user[relation]"] = $user['mask']; + } + } + // ################################################################### /** * Generates an array of users who have a given email notification flag diff --git a/newreport.php b/newreport.php index 05dee84..489b237 100755 --- a/newreport.php +++ b/newreport.php @@ -29,6 +29,7 @@ $focus['newreport'] = 'focus'; require_once('./global.php'); require_once('./includes/functions_product.php'); +require_once('./includes/class_notification.php'); require_once('./includes/api_bug.php'); require_once('./includes/api_comment.php'); @@ -51,6 +52,8 @@ if ($_POST['do'] == 'insert') $bug = new BugAPI($bugsys); $comment = new CommentAPI($bugsys); + $notif = new NotificationCenter; + $bug->set('userid', $bugsys->userinfo['userid']); $bug->set('username', $bugsys->userinfo['displayname']); $bug->set('summary', $bugsys->in['summary']); @@ -101,6 +104,8 @@ if ($_POST['do'] == 'insert') $comment->set('bugid', $bug->insertid); $comment->insert(); + $notif->send_new_bug_notice($bug->values, $comment->values); + $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