/**
  * Method used to send an email notification when an issue is
  * assigned to an user.
  *
  * @param   array $users The list of users
  * @param   integer $issue_id The issue ID
  */
 public static function notifyNewAssignment($users, $issue_id)
 {
     $prj_id = Issue::getProjectID($issue_id);
     $emails = array();
     foreach ($users as $usr_id) {
         if ($usr_id == Auth::getUserID()) {
             continue;
         }
         $prefs = Prefs::get($usr_id);
         if (!empty($prefs) && isset($prefs['receive_assigned_email'][$prj_id]) && $prefs['receive_assigned_email'][$prj_id] && $usr_id != Auth::getUserID()) {
             $emails[] = User::getFromHeader($usr_id);
         }
     }
     if (!$emails) {
         return;
     }
     // get issue details
     $issue = Issue::getDetails($issue_id);
     // open text template
     $tpl = new Template_Helper();
     $tpl->setTemplate('notifications/assigned.tpl.text');
     $tpl->assign(array('app_title' => Misc::getToolCaption(), 'issue' => $issue, 'current_user' => User::getFullName(Auth::getUserID())));
     foreach ($emails as $email) {
         $text_message = $tpl->getTemplateContents();
         Language::set(User::getLang(User::getUserIDByEmail(Mail_Helper::getEmailAddress($email))));
         $subject = "[#{$issue_id}] New Assignment: " . $issue['iss_summary'];
         $from = self::getFixedFromHeader($issue_id, '', 'issue');
         // send email (use PEAR's classes)
         $mail = new Mail_Helper();
         $mail->setTextBody($text_message);
         $mail->setHeaders(Mail_Helper::getBaseThreadingHeaders($issue_id));
         $mail->send($from, $email, $subject, true, $issue_id, 'assignment');
     }
     Language::restore();
 }