}
}
+ // ###################################################################
+ /**
+ * 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
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');
$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']);
$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();