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');
'componentid' => 'component'
);
+$notif = new NotificationCenter;
+
// ###################################################################
if ($_POST['do'] == 'update')
$comment->set('comment', $commenttext);
$comment->insert();
+ $notif->send_new_comment_notice($comment->values);
+
$bugapi->set('lastposttime', $comment->values['dateline']);
$bugapi->set('lastpostby', $bugsys->userinfo['userid']);
$bugapi->set('lastpostbyname', $bugsys->userinfo['displayname']);
$log->update_history();
+ $notif->send_bug_changes_notice($bugapi->objdata, $bugapi->values);
+
+ print_r($notif);
+
$message->redirect($lang->string('Your changes to the bug have been saved.'), "showreport.php?bugid=$bug[bugid]");
}
*/
var $users = array();
+ /**
+ * A list of notices per-user that are combined together in NotificationCenter::finalize()
+ * @var array
+ * @access private
+ */
+ var $notices = array();
+
// ###################################################################
/**
* Constructor: set database objects
*/
function notice_no_longer_assigned($userid)
{
- if ($this->users["$userid"]['options'][0] & $this->registry->emailoptions['notifications']['assignedto'])
+ if ($this->users["$userid"]['options'][0] & $this->registry->emailoptions['notifications']['assignedto'] AND in_array($userid, $this->roles['-notapplicable-']))
{
-
+ $this->notices["$userid"][] = sprintf(
+$this->registry->lang->string('You are no longer assigned to this bug, per %1$s\'s changes.'),
+
+ construct_user_display($this->registry->userinfo, false)
+ );
}
}
*/
function notice_now_assigned($userid)
{
- if ($this->users["$userid"]['options'][0] & $this->registry->emailoptions['notifications']['assignedto'])
+ if ($this->users["$userid"]['options'][0] & $this->registry->emailoptions['notifications']['assignedto'] AND in_array($userid, $this->roles['-notapplicable-']))
{
-
+ $this->notices["$userid"][] = sprintf(
+$this->registry->lang->string('You have been assigned to this bug by %1$s.'),
+
+ construct_user_display($this->registry->userinfo, false)
+ );
}
}
*/
function notice_status_change($old, $new)
{
-
+ $userlist = $this->fetch_users_with_on_bit('statusresolve');
+ foreach ($userlist AS $userid => $user)
+ {
+ $this->notices["$user[userid]"][] = sprintf(
+$this->registry->lang->string('The status field has changed from "%1$s" to "%2$s".'),
+
+ $this->registry->datastore['status']["$old"]['status'],
+ $this->registry->datastore['status']["$new"]['status']
+ );
+ }
}
// ###################################################################
*/
function notice_resolution_change($old, $new)
{
-
+ $userlist = $this->fetch_users_with_on_bit('statusresolve');
+ foreach ($userlist AS $userid => $user)
+ {
+ $this->notices["$user[userid]"][] = sprintf(
+$this->registry->lang->string('The resolution field has changed from "%1$s" to "%2$s".'),
+
+ $this->registry->datastore['resolution']["$old"]['resolution'],
+ $this->registry->datastore['resolution']["$new"]['resolution']
+ );
+ }
}
// ###################################################################
*/
function notice_duplicates_change($old, $new)
{
+
+ }
+
+ // ###################################################################
+ /**
+ * Sends the appropriate users information about a new comment being
+ * posted to the bug report.
+ *
+ * @access public
+ *
+ * @param array CommentAPI->values array
+ */
+ function send_new_comment_notice($comment)
+ {
+
+ }
+
+ // ###################################################################
+ /**
+ * Generates an array of users who have a given email notification flag
+ * turned on in their bitfields.
+ *
+ * @access private
+ *
+ * @param string Notification bitfield name
+ *
+ * @return array Array of users and their data
+ */
+ function fetch_users_with_on_bit($bitname)
+ {
+ $idlist = array();
+
+ foreach ($this->users AS $user)
+ {
+ foreach ($this->registry->emailoptions['relations'] AS $name => $bit)
+ {
+ if (in_array($user['userid'], $this->roles["$name"]) AND $user['options']["$bit"] & $this->registry->emailoptions['notifications']["$bitname"])
+ {
+ $idlist[] = $user['userid'];
+ }
+ }
+ }
+
+ $masters = array_unique($idlist);
+
+ $return = array();
+ foreach ($masters AS $userid)
+ {
+ $return["$userid"] =& $this->users["$userid"];
+ }
+ return $return;
}
}