You are here

function _role_watchdog_remove_role in Role Watchdog 7

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

Internal function

Handles removal of roles.

1 call to _role_watchdog_remove_role()
_role_watchdog_process_role_changes in ./role_watchdog.module

File

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

Code

function _role_watchdog_remove_role($rid, $account) {
  global $user;
  $roles = user_roles();
  $record = array(
    'aid' => $account->uid,
    'rid' => $rid,
    'action' => ROLE_WATCHDOG_ROLE_REMOVE,
    'uid' => $user->uid,
    'stamp' => REQUEST_TIME,
  );
  if (drupal_write_record('role_watchdog', $record)) {
    $vars += array(
      'body' => 'Role !role removed from !account by !user',
      '!role' => check_plain($roles[$rid]),
      '!user' => check_plain($user->name),
      '!user_id' => $user->uid,
      '!account' => check_plain($account->name),
      '!account_id' => $account->uid,
    );
    watchdog('role_watchdog', $vars['body'], $vars, WATCHDOG_NOTICE, l(t('view'), 'user/' . $account->uid . '/track/role_history'));
    _role_watchdog_notification($rid, $vars);
    return $record;
  }
  else {
    watchdog('role_watchdog', 'Unable to save record in _role_watchdog_remove_role()', array(), WATCHDOG_ERROR, l(t('view'), 'user/' . $account->uid . '/track/role_history'));
    return ROLE_WATCHDOG_ROLE_NOCHANGE;
  }
}