Example #1
0
 /**
  * Build notification list based on user preferences
  *
  * @param Array                  $addresses
  * @param String                 $subject
  * @param Codendi_Mail_Interface $text_mail
  * @param Codendi_Mail_Interface $html_mail
  */
 function sendNotification($addresses, $subject, $text_mail, $html_mail)
 {
     $html_addresses = array();
     $text_addresses = array();
     $mailMgr = new MailManager();
     $mailPrefs = $mailMgr->getMailPreferencesByEmail($addresses);
     foreach ($mailPrefs['html'] as $user) {
         $html_addresses[] = $user->getEmail();
     }
     foreach ($mailPrefs['text'] as $user) {
         $text_addresses[] = $user->getEmail();
     }
     $mail = null;
     if ($text_mail && count($text_addresses)) {
         $this->sendMail($text_mail, $subject, $text_addresses);
     }
     if ($html_mail && count($html_addresses)) {
         if ($text_mail) {
             $html_mail->setBodyText($text_mail->getBody());
         }
         $this->sendMail($html_mail, $subject, $html_addresses);
     }
 }