You are here

function faq_ask_mail in FAQ_Ask 6

Same name and namespace in other branches
  1. 8 faq_ask.module \faq_ask_mail()
  2. 6.2 faq_ask.module \faq_ask_mail()
  3. 7 faq_ask.module \faq_ask_mail()

Implementation of hook_mail(). This function completes the email, allowing for placeholder substitution. @TODO: notify_asker. @TODO: define messages & subjects on settings page, with list of tokens. how to handle newlines?

File

./faq_ask.module, line 393
This module is an add-on to the FAQ module that allows users with the 'ask question' permission to create a question which will be queued for an 'expert' to answer.

Code

function faq_ask_mail($key, &$message, $params) {
  $newline = "\n<br/><br/>";
  $body = array();
  $message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
  $language = $message['language'];
  $variables = user_mail_tokens($params['account'], $language);
  switch ($key) {
    case 'notify_expert':
      $variables = array_merge($variables, array(
        '!cat' => $params['category'],
        '@question' => $params['question'],
        '!answer_uri' => url('faq_ask/answer/' . $params['nid'], array(
          'absolute' => TRUE,
        )),
        '!asker' => $params['creator'],
      ));
      $subject = t('You have a question waiting on !site', $variables, $language->language);
      $body[] = t('Dear !username,', $variables, $language->language);

      // should %newline really be in translatable text? replace "\n" with %newline?
      if ($params['category'] == -1) {
        $body[] = t('The following question has been posted.', NULL, $language->language);
      }
      else {
        $body[] = t('The following question has been posted in the "!cat" category by !asker.', $variables, $language->language);
      }

      //      $body[] = t('The following question has been posted in the "!cat" category.', $variables, $language->language);
      $body[] = $params['question'];
      $body[] = t('In order to answer it you will first need to <a href="!login_uri">login</a> to the site.', $variables, $language->language);
      $body[] = t('Once logged in, you may proceed <a href="!answer_uri">directly to the question</a> to answer it.', $variables, $language->language);
      break;
  }
  $message['body'] = drupal_wrap_mail(implode($newline, $body));
  $message['subject'] = $subject;
}