You are here

function _role_watchdog_notification in Role Watchdog 5

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

Internal function

Handles notification of changes in selected roles.

2 calls to _role_watchdog_notification()
_role_watchdog_add_role in ./role_watchdog.module
Internal function
_role_watchdog_remove_role in ./role_watchdog.module
Internal function

File

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

Code

function _role_watchdog_notification($rid, $message) {
  $monitor_roles = variable_get('role_watchdog_monitor_roles', NULL);
  if (in_array($rid, $monitor_roles)) {
    $site_name = variable_get('site_name', 'Drupal');
    $from = "{$site_name} <" . variable_get('site_mail', ini_get('sendmail_from')) . '>';
    $subject = t('Role Watchdog notification on !site_name', array(
      '!site_name' => $site_name,
    ));
    $message = strip_tags($message);
    foreach (_role_watchdog_get_notification_list() as $recipient) {
      if (drupal_mail('role_watchdog_notification', $recipient, $subject, $message, $from)) {
        watchdog('action', t('Sent email to %recipient', array(
          '%recipient' => $recipient,
        )));
      }
      else {
        watchdog('error', t('Unable to send email to %recipient', array(
          '%recipient' => $recipient,
        )));
      }
    }
  }
}