r867: Finished new bug notices
authorRobert Sesek <rsesek@bluestatic.org>
Sat, 24 Jun 2006 16:17:54 +0000 (16:17 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Sat, 24 Jun 2006 16:17:54 +0000 (16:17 +0000)
includes/class_notification.php
newreport.php

index e07b0d48707163032af3ad32b75cc32d2e289c02..d7bdec8ea612073f9c2ab5236334b4520459a09d 100644 (file)
@@ -459,6 +459,57 @@ View: %6$s
                }
        }
        
+       // ###################################################################
+       /**
+       * 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
index 05dee84ec18ea28a1ad0dd9709cf5a6826a7ce69..489b2377f6e39eb18b9252f25967fdd610be44b7 100755 (executable)
@@ -29,6 +29,7 @@ $focus['newreport'] = 'focus';
 
 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');
 
@@ -51,6 +52,8 @@ if ($_POST['do'] == 'insert')
        $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']);
@@ -101,6 +104,8 @@ if ($_POST['do'] == 'insert')
                $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();