Chris@0
|
1 /**
|
Chris@0
|
2 * Implements hook_mail().
|
Chris@0
|
3 */
|
Chris@0
|
4 function {{ machine_name }}_mail($key, &$message, $params) {
|
Chris@0
|
5 $account = $params['account'];
|
Chris@0
|
6 $context = $params['context'];
|
Chris@0
|
7 $variables = array(
|
Chris@0
|
8 '%site_name' => variable_get('site_name', 'Drupal'),
|
Chris@0
|
9 '%username' => format_username($account),
|
Chris@0
|
10 );
|
Chris@0
|
11 if ($context['hook'] == 'taxonomy') {
|
Chris@0
|
12 $entity = $params['entity'];
|
Chris@0
|
13 $vocabulary = taxonomy_vocabulary_load($entity->vid);
|
Chris@0
|
14 $variables += array(
|
Chris@0
|
15 '%term_name' => $entity->name,
|
Chris@0
|
16 '%term_description' => $entity->description,
|
Chris@0
|
17 '%term_id' => $entity->tid,
|
Chris@0
|
18 '%vocabulary_name' => $vocabulary->name,
|
Chris@0
|
19 '%vocabulary_description' => $vocabulary->description,
|
Chris@0
|
20 '%vocabulary_id' => $vocabulary->vid,
|
Chris@0
|
21 );
|
Chris@0
|
22 }
|
Chris@0
|
23
|
Chris@0
|
24 // Node-based variable translation is only available if we have a node.
|
Chris@0
|
25 if (isset($params['node'])) {
|
Chris@0
|
26 $node = $params['node'];
|
Chris@0
|
27 $variables += array(
|
Chris@0
|
28 '%uid' => $node->uid,
|
Chris@0
|
29 '%node_url' => url('node/' . $node->nid, array('absolute' => TRUE)),
|
Chris@0
|
30 '%node_type' => node_type_get_name($node),
|
Chris@0
|
31 '%title' => $node->title,
|
Chris@0
|
32 '%teaser' => $node->teaser,
|
Chris@0
|
33 '%body' => $node->body,
|
Chris@0
|
34 );
|
Chris@0
|
35 }
|
Chris@0
|
36 $subject = strtr($context['subject'], $variables);
|
Chris@0
|
37 $body = strtr($context['message'], $variables);
|
Chris@0
|
38 $message['subject'] .= str_replace(array("\r", "\n"), '', $subject);
|
Chris@0
|
39 $message['body'][] = drupal_html_to_text($body);
|
Chris@0
|
40 }
|