Getting newreport.php to work, sans notifications
authorRobert Sesek <rsesek@bluestatic.org>
Sat, 23 Aug 2008 17:11:46 +0000 (13:11 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Sat, 23 Aug 2008 17:11:46 +0000 (13:11 -0400)
includes/api_bug.php
includes/class_notification.php
includes/init.php
includes/permissions.php
newreport.php

index 5d51140c8b3309c056f97694718b122a5a580151..a6866234f247bc669e9cc52e78f0c2c70d56bf01 100644 (file)
@@ -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']);
        }
        
        // ###################################################################
index 5d71cea740a48ba0e6970fa872462b6e661d8bc5..8b6b3c5f39f992e1e7cbe9b2eb94cc1e38ed3b34 100644 (file)
@@ -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'];
                                }
index 2640ab63d9050fa9b07461da03c638a8df3339a3..f65826ee392237e6ff2a88a5614ee8e30c4b0dc4 100755 (executable)
@@ -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() {}
 }
 
 // ###################################################################
index 1dda26042280075e4219231147e8ce3826d22bba..dae3b09b3581bce92e73e4d879f79a53c598722a 100644 (file)
@@ -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
index 1b77ead9923fc726e416cb9e55469954f13ed38a..02cc8825718aecb8a9f6ce3f5bc0c05eda7c75c1 100755 (executable)
@@ -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);