You are here

function role_watchdog_mail in Role Watchdog 7

Same name and namespace in other branches
  1. 8 role_watchdog.module \role_watchdog_mail()
  2. 6.2 role_watchdog.module \role_watchdog_mail()
  3. 6 role_watchdog.module \role_watchdog_mail()
  4. 7.2 role_watchdog.module \role_watchdog_mail()

Implements hook_mail().

File

./role_watchdog.module, line 210
Logs changes to user roles.

Code

function role_watchdog_mail($key, &$message, $params) {
  global $base_url;
  $language = $message['language'];
  $variables = array(
    '!site' => variable_get('site_name', 'Drupal'),
    '!uri' => $base_url,
  );
  $variables += $params;
  $variables['!user'] .= ' (' . $variables['!uri'] . '/user/' . $params['!user_id'] . ')';
  $variables['!account'] .= ' (' . $variables['!uri'] . '/user/' . $params['!account_id'] . ')';
  switch ($key) {
    case 'notification':
      $message['subject'] = str_replace(array(
        "\r",
        "\n",
      ), '', t('Role watchdog notification on !site', $variables, array(
        'langcode' => $language->language,
      )));
      $message['body'][] = strtr($params['body'], $variables);
      break;
  }
}