예제 #1
0
 /**
  * Method used to add a customized warning message to the body
  * of outgoing emails.
  *
  * @access  public
  * @param   integer $issue_id The issue ID
  * @param   string $to The recipient of the message
  * @param   string $body The body of the message
  * @return  string The body of the message with the warning message, if appropriate
  */
 function addWarningMessage($issue_id, $to, $body)
 {
     $setup = Setup::load();
     if (@$setup['email_routing']['status'] == 'enabled' && $setup['email_routing']['warning']['status'] == 'enabled') {
         // check if the recipient can send emails to the customer
         $recipient_email = Mail_API::getEmailAddress($to);
         $recipient_usr_id = User::getUserIDByEmail($recipient_email);
         // don't add the warning message if the recipient is an unknown email address
         if (empty($recipient_usr_id)) {
             return $body;
         } else {
             // don't add anything if the recipient is a known customer contact
             $recipient_role_id = User::getRoleByUser($recipient_usr_id, Issue::getProjectID($issue_id));
             if ($recipient_role_id == User::getRoleID('Customer')) {
                 return $body;
             } else {
                 if (!Support::isAllowedToEmail($issue_id, $recipient_email)) {
                     return Mail_API::getWarningMessage('blocked') . "\n\n" . $body;
                 } else {
                     return Mail_API::getWarningMessage('allowed') . "\n\n" . $body;
                 }
             }
         }
     } else {
         return $body;
     }
 }