You are here

function library_send_email_action in Library 7

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

Implementation of a configurable Drupal action. Sends an email.

File

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

Code

function library_send_email_action(&$object, $context) {
  $recipient = $context['recipient'];
  $patron = $context['patron'];
  $account = user_load($patron->uid);
  $language = user_preferred_language($account);
  if ($recipient == '%patron_mail') {
    $recipient = $context['patron']['mail'];
  }
  $params = array(
    'context' => $context,
  );
  if (drupal_mail('library', 'action_send_email', $recipient, $language, $params)) {
    watchdog('library', 'Sent email to %recipient', array(
      '%recipient' => $recipient,
    ));
  }
  else {
    watchdog('error', 'Unable to send email to %recipient', array(
      '%recipient' => $recipient,
    ));
  }
}