You are here

function protected_node_mail in Protected Node 6

Same name and namespace in other branches
  1. 7 protected_node.mail.inc \protected_node_mail()
  2. 1.0.x protected_node.mail.inc \protected_node_mail()

Implementation of hook_mail().

This is the function that builds the actual message body.

File

./protected_node.mail.inc, line 42

Code

function protected_node_mail($key, &$message, $params) {
  global $user;
  $has_token = module_exists('token');
  $node = $params['node'];
  switch ($key) {
    case 'password':
      module_load_include('settings.inc', 'protected_node');
      $subject = variable_get('protected_node_email_subject', protected_node_email_subject());
      if ($has_token) {
        $subject = token_replace($subject, 'node', $node);
        $subject = token_replace($subject, 'user', $user);
      }
      $message['subject'] = $subject;
      $body = variable_get('protected_node_email_body', protected_node_email_body());
      if ($has_token) {
        $body = token_replace($body, 'node', $node);
        $body = token_replace($body, 'user', $user);
      }
      $message['body'] = $body;
      break;
  }
}