You are here

function library_mail in Library 6

Same name and namespace in other branches
  1. 5.2 library.actions.inc \library_mail()
  2. 6.2 library.actions.inc \library_mail()
  3. 7 library.actions.inc \library_mail()

Implementation of hook_mail()

File

./library.actions.inc, line 95
Hooks into core Drupal actions module

Code

function library_mail($key, &$message, $params) {
  $language = $message['language'];
  switch ($key) {
    case 'notify_overdue':
      $variables = library_mail_tokens($params, $language);
      $message['subject'] .= _library_mail_text($key . '_subject', $language, $variables);
      $message['body'][] = _library_mail_text($key . '_body', $language, $variables);
      break;
    case 'action_send_email':
      $context = $params['context'];
      $variables = array(
        '%site_name' => variable_get('site_name', 'Drupal'),
        '%patron_name' => $context['patron']['name'],
        '%patron_email' => $context['patron']['email'],
        '%patron_id' => $context['patron']['nid'],
        '%node_url' => url('node/' . $context['item']['nid'], array(
          'absolute' => TRUE,
        )),
        '%node_type' => $context['item']['node_type'],
        '%title' => $context['item']['title'],
        '%item_id' => $context['item']['id'],
        '%barcode' => $context['item']['barcode'],
        '%transaction_name' => $context['transaction']['action_name'],
        '%notes' => $context['transaction']['notes'],
      );
      $subject = strtr($context['subject'], $variables);
      $body = strtr($context['message'], $variables);
      $message['subject'] .= str_replace(array(
        "\r",
        "\n",
      ), '', $subject);
      $message['body'][] = drupal_html_to_text($body);
      break;
  }
}