You are here

function _role_watchdog_remove_role in Role Watchdog 6

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. 7.2 role_watchdog.module \_role_watchdog_remove_role()
  4. 7 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 261
Logs changes to user roles.

Code

function _role_watchdog_remove_role($rid, $old_roles = array(), $account, $in_array = TRUE, $vars = array()) {
  if (in_array($rid, $old_roles) xor !$in_array) {
    global $user;
    $roles = user_roles();
    $record = array(
      'aid' => $account->uid,
      'rid' => $rid,
      'action' => 0,
      'uid' => $user->uid,
      'stamp' => $_SERVER['REQUEST_TIME'],
    );
    if (drupal_write_record('role_watchdog', $record)) {
      $vars += array(
        'body' => 'Role !role!role_modifier removed from !account by !user',
        '!role' => check_plain($roles[$rid]),
        '!role_modifier' => '',
        '!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;
    }
  }
  return ROLE_WATCHDOG_ROLE_NOCHANGE;
}