Exemplo n.º 1
0
 /**
  * Method used to send an email notification when an issue is
  * assigned to an user.
  *
  * @access  public
  * @param   array $users The list of users
  * @param   integer $issue_id The issue ID
  * @return  void
  */
 function notifyNewAssignment($users, $issue_id)
 {
     $prj_id = Issue::getProjectID($issue_id);
     $emails = array();
     for ($i = 0; $i < count($users); $i++) {
         $prefs = Prefs::get($users[$i]);
         if (!empty($prefs) && @$prefs["receive_assigned_emails"][$prj_id]) {
             $emails[] = User::getFromHeader($users[$i]);
         }
     }
     if (count($emails) == 0) {
         return false;
     }
     // get issue details
     $issue = Notification::getIssueDetails($issue_id);
     // open text template
     $tpl = new Template_API();
     $tpl->setTemplate('notifications/assigned.tpl.text');
     $tpl->bulkAssign(array("app_title" => Misc::getToolCaption(), "issue" => $issue, "current_user" => User::getFullName(Auth::getUserID())));
     $text_message = $tpl->getTemplateContents();
     for ($i = 0; $i < count($emails); $i++) {
         // send email (use PEAR's classes)
         $mail = new Mail_API();
         $mail->setTextBody($text_message);
         $mail->setHeaders(Mail_API::getBaseThreadingHeaders($issue_id));
         $mail->send(Notification::getFixedFromHeader($issue_id, '', 'issue'), $emails[$i], "[#{$issue_id}] New Assignment: " . $issue['iss_summary'], TRUE, $issue_id, 'assignment');
     }
 }