From f77b886efaa9e1bbb2e5590bc25ace45a26379ba Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 23 Aug 2008 13:11:46 -0400 Subject: [PATCH] Getting newreport.php to work, sans notifications --- includes/api_bug.php | 10 ++++---- includes/class_notification.php | 45 +++++---------------------------- includes/init.php | 5 ++++ includes/permissions.php | 2 +- newreport.php | 2 -- 5 files changed, 18 insertions(+), 46 deletions(-) diff --git a/includes/api_bug.php b/includes/api_bug.php index 5d51140..a686623 100644 --- a/includes/api_bug.php +++ b/includes/api_bug.php @@ -116,7 +116,7 @@ class BugAPI extends BSApi */ function post_insert() { - $this->registry->db->query("INSERT INTO " . TABLE_PREFIX . "vote (bugid, votefor, voteagainst) VALUES (" . $this->insertid . ", 0, 0)"); + BSApp::$db->query("INSERT INTO " . TABLE_PREFIX . "vote (bugid, votefor, voteagainst) VALUES (" . $this->insertid . ", 0, 0)"); } // ################################################################### @@ -127,10 +127,10 @@ class BugAPI extends BSApi */ function post_delete() { - $this->registry->db->query("DELETE FROM " . TABLE_PREFIX . "comment WHERE bugid = " . $this->values['bugid']); - $this->registry->db->query("DELETE FROM " . TABLE_PREFIX . "favorite WHERE bugid = " . $this->values['bugid']); - $this->registry->db->query("DELETE FROM " . TABLE_PREFIX . "history WHERE bugid = " . $this->values['bugid']); - $this->registry->db->query("DELETE FROM " . TABLE_PREFIX . "vote WHERE bugid = " . $this->values['bugid']); + BSApp::$db->query("DELETE FROM " . TABLE_PREFIX . "comment WHERE bugid = " . $this->values['bugid']); + BSApp::$db->query("DELETE FROM " . TABLE_PREFIX . "favorite WHERE bugid = " . $this->values['bugid']); + BSApp::$db->query("DELETE FROM " . TABLE_PREFIX . "history WHERE bugid = " . $this->values['bugid']); + BSApp::$db->query("DELETE FROM " . TABLE_PREFIX . "vote WHERE bugid = " . $this->values['bugid']); } // ################################################################### diff --git a/includes/class_notification.php b/includes/class_notification.php index 5d71cea..8b6b3c5 100644 --- a/includes/class_notification.php +++ b/includes/class_notification.php @@ -54,13 +54,6 @@ class NotificationCenter */ var $modified = array(); - /** - * Global bugsys registry - * @var object - * @access private - */ - var $registry = null; - /** * Role list: a list of user IDs with their relations to the bug * @var array @@ -89,30 +82,6 @@ class NotificationCenter */ var $notices = array(); - // ################################################################### - /** - * Constructor: set database objects - * - * @access public - */ - function __construct() - { - global $bugsys; - - $this->registry =& $bugsys; - } - - // ################################################################### - /** - * (PHP 4) Constructor - * - * @access public - */ - function NotificationCenter() - { - $this->__construct(); - } - // ################################################################### /** * Sets the bug data so that all methods in this class have access to @@ -153,7 +122,7 @@ class NotificationCenter */ function fetch_user_cache() { - $newbuggers = $this->registry->db->query("SELECT userid FROM " . TABLE_PREFIX . "useremail WHERE relation = " . $this->registry->emailoptions['relations']['-notapplicable-'] . " AND mask & " . $this->registry->emailoptions['notifications']['newbug']); + $newbuggers = $this->registry->db->query("SELECT userid FROM " . TABLE_PREFIX . "useremail WHERE relation = " . bugdar::$emailOptions['relations']['-notapplicable-'] . " AND mask & " . bugdar::$emailOptions['notifications']['newbug']); foreach ($newbuggers as $newbug) { $this->roles['-notapplicable-']["$newbug[userid]"] = $newbug['userid']; @@ -278,7 +247,7 @@ class NotificationCenter */ function notice_no_longer_assigned($userid) { - if ($this->users["$userid"]['options'][0] & $this->registry->emailoptions['notifications']['assignedto'] AND in_array($userid, $this->roles['-notapplicable-'])) + if ($this->users["$userid"]['options'][0] & bugdar::$emailOptions['notifications']['assignedto'] AND in_array($userid, $this->roles['-notapplicable-'])) { $user = construct_user_display(bugdar::$userinfo, false); eval('$part = "' . $this->registry->template->fetch(FetchEmailPath('notice_unassigned.part', $this->_localeFromUserId($userid))) . '";'); @@ -296,7 +265,7 @@ class NotificationCenter */ function notice_now_assigned($userid) { - if ($this->users["$userid"]['options'][0] & $this->registry->emailoptions['notifications']['assignedto'] AND in_array($userid, $this->roles['-notapplicable-'])) + if ($this->users["$userid"]['options'][0] & bugdar::$emailOptions['notifications']['assignedto'] AND in_array($userid, $this->roles['-notapplicable-'])) { $user = construct_user_display(bugdar::$userinfo, false); eval('$email = "' . $this->registry->template->fetch(FetchEmailPath('notice_assigned.part', $this->_localeFromUserId($userid))) . '";'); @@ -503,13 +472,13 @@ class NotificationCenter */ function send_new_bug_notice($bug, $comment) { - $userinfo = $this->registry->db->query(" + $userinfo = BSApp::$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'] . " + AND useremail.mask & " . bugdar::$emailOptions['notifications']['newbug'] . " "); foreach ($userinfo as $userInfo) { @@ -543,9 +512,9 @@ class NotificationCenter foreach ($this->users AS $user) { - foreach ($this->registry->emailoptions['relations'] AS $name => $bit) + foreach (bugdar::$emailOptions['relations'] AS $name => $bit) { - if (in_array($user['userid'], $this->roles["$name"]) AND $user['options']["$bit"] & $this->registry->emailoptions['notifications']["$bitname"]) + if (in_array($user['userid'], $this->roles["$name"]) AND $user['options']["$bit"] & bugdar::$emailOptions['notifications']["$bitname"]) { $idlist[] = $user['userid']; } diff --git a/includes/init.php b/includes/init.php index 2640ab6..f65826e 100755 --- a/includes/init.php +++ b/includes/init.php @@ -77,6 +77,11 @@ class bugdar public static $options = array(); public static $userinfo = array(); public static $datastore = array(); + + public static $permissions = array(); + public static $emailOptions = array(); + + private function __construct() {} } // ################################################################### diff --git a/includes/permissions.php b/includes/permissions.php index 1dda260..dae3b09 100644 --- a/includes/permissions.php +++ b/includes/permissions.php @@ -48,7 +48,7 @@ $bugsys->permissions = array( 'canviewownhidden' => 33554432 // can view own hidden bugs ); -$bugsys->emailoptions = array( +bugdar::$emailOptions = array( 'relations' => array( // a user's relation to the bug '-notapplicable-' => 0, // not applicable diff --git a/newreport.php b/newreport.php index 1b77ead..02cc882 100755 --- a/newreport.php +++ b/newreport.php @@ -107,9 +107,7 @@ if ($_POST['do'] == 'insert') $notif->send_new_bug_notice($bug->values, $comment->values); $bug = new BugAPI(); // need to destroy because update will think the insert fields need to be changed, too - $bug->dorelations = array(); $bug->set('bugid', $comment->values['bugid']); - $bug->set_condition(); $bug->fetch(); $bug->set('dateline', $comment->values['dateline']); $bug->set('initialreport', $comment->insertid); -- 2.43.5