From c57ad18a2b6b39df25b4f74713ba28e168b93f8e Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 28 May 2006 18:49:21 +0000 Subject: [PATCH] r855: Adding the base notification center --- includes/class_notification.php | 256 ++++++++++++++++++++++++++++++++ 1 file changed, 256 insertions(+) create mode 100644 includes/class_notification.php diff --git a/includes/class_notification.php b/includes/class_notification.php new file mode 100644 index 0000000..e57c416 --- /dev/null +++ b/includes/class_notification.php @@ -0,0 +1,256 @@ + array(), + 'reporter' => array(), + 'assignee' => array(), + 'favourite' => array(), + 'voter' => array(), + 'commenter' => array() + ); + + /** + * User cache list + * @var array + * @access private + */ + var $users = array(); + + // ################################################################### + /** + * Constructor: set database objects + * + * @access public + */ + function __construct() + { + global $bugsys; + + $this->registry =& $bugsys; + } + + // ################################################################### + /** + * (PHP 4) Constructor + * + * @access public + */ + function NotificationCenter() + { + $this->__construct(); + } + + // ################################################################### + /** + * Fetches all the users who could be related to the bug and sticks + * their information into an array. + * + * @access private + */ + function fetch_user_cache() + { + $favourites = $this->registry->db->query("SELECT userid FROM " . TABLE_PREFIX . "favourite WHERE bugid = " . $this->registry->clean($bug['bugid'], TYPE_UINT)); + while ($fav = $this->registry->db->fetch_array($favourites)) + { + $this->roles['favourite']["$fav[userid]"] = $fav['userid']; + } + + $voters = $this->regisry->db->query_first("SELECT userids FROM " . TABLE_PREFIX . "vote WHERE bugid = " . $this->registry->clean($bug['bugid'], TYPE_UINT)); + $this->roles['voter'] = explode(',', $voters['userids']); + + $commenters = $this->registry->db->query("SELECT userid FROM " . TABLE_PREFIX . "comment WHERE bugid = " . $this->registry->clean($bug['bugid'], TYPE_UINT)); + while ($comment = $this->registry->db->fetch_array($commenters)) + { + $this->roles['commenter']["$comment[userid]"] = $comment['userid']; + } + + $masterids = array_merge($this->roles['-notapplicable-'], $this->roles['reporter'], $this->roles['assignee'], $this->roles['favourite'], $this->roles['voter'], $this->roles['commenter']); + $masterids = array_unique($masterids); + + print_r($masterids); + } + + // ################################################################### + /** + * Sends the appropriate emails for changes to bugs. This function + * works a lot like the Logging class by taking BugAPI->objdata and + * BugAPI->values and then comparing the two arries and sending emails + * with the differences. + * + * @access public + * + * @param array Original data (BugAPI->objdata) + * @param array Modified data (BugAPI->values) + */ + function send_bug_changes_notice($original, $modified) + { + $this->bug = $modified; + + $this->roles['-notapplicable-'] = array($original['assignedto'], $modified['assignedto']); + $this->roles['reporter'] = array($original['userid']); + $this->roles['assignee'] = array($modified['assignedto']); + + $this->fetch_user_cache(); + + if ($original['assignedto'] != $modified['assignedto']) + { + if ($original['assignedto'] != '') + { + $this->notice_no_longer_assigned($original['assignedto']); + } + if ($modified['assignedto'] != '') + { + $this->notice_now_assigned($modified['assignedto']); + } + } + + if ($original['status'] != $modified['status']) + { + $this->notice_status_change($original['status'], $modified['status']); + } + if ($original['resolution'] != $modified['resoultion']) + { + $this->notice_resolution_change($original['resolution'], $modified['resolution']); + } + + if ($original['duplicates'] != $modified['duplicates']) + { + $this->notice_duplicates_change($original['duplicates'], $modified['duplicates']); + } + } + + // ################################################################### + /** + * Sends an email to the specified user ID that they are no longer the + * person assigned to the bug. + * + * @access private + * + * @param integer User ID to send to + */ + function notice_no_longer_assigned($userid) + { + if ($this->users["$userid"]['options'][0] & $this->registry->emailoptions['notifications']['assignedto']) + { + + } + } + + // ################################################################### + /** + * Informs the user that they have been made the assignee of the bug. + * + * @access private + * + * @param integer User ID + */ + function notice_now_assigned($userid) + { + if ($this->users["$userid"]['options'][0] & $this->registry->emailoptions['notifications']['assignedto']) + { + + } + } + + // ################################################################### + /** + * Sends a message to inform users that the status has changed. + * + * @access private + * + * @param integer Old status + * @param integer New status + */ + function notice_status_change($old, $new) + { + + } + + // ################################################################### + /** + * Sends an email to inform users that the resolution has changed. + * + * @access private + * + * @param integer Old resolution + * @param integer New resolution + */ + function notice_resolution_change($old, $new) + { + + } + + // ################################################################### + /** + * Informs users that the duplicates list has changed. + * + * @access private + * + * @param string Old duplicates list + * @param string New duplicates list + */ + function notice_duplicates_change($old, $new) + { + + } +} + +/*=====================================================================*\ +|| ################################################################### +|| # $HeadURL$ +|| # $Id$ +|| ################################################################### +\*=====================================================================*/ +?> \ No newline at end of file -- 2.22.5