You are here

function _role_watchdog_process_role_changes in Role Watchdog 6

Same name and namespace in other branches
  1. 6.2 role_watchdog.module \_role_watchdog_process_role_changes()
  2. 7.2 role_watchdog.module \_role_watchdog_process_role_changes()
  3. 7 role_watchdog.module \_role_watchdog_process_role_changes()
3 calls to _role_watchdog_process_role_changes()
role_watchdog_user_block in ./role_watchdog.module
Process user block / unblock
role_watchdog_user_save in ./role_watchdog.module
Process role add/remove.
_og_role_watchdog_process_role_changes in modules/og_role_watchdog/og_role_watchdog.module
Internal function

File

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

Code

function _role_watchdog_process_role_changes($account, $new_roles, $old_roles, $vars = array()) {
  $result = array();
  $count = 0;

  // Is role added?
  foreach ($new_roles as $rid) {
    $record = _role_watchdog_add_role($rid, $old_roles, $account, ROLE_WATCHDOG_ROLE_ADD, $vars);
    if (is_array($record)) {
      $result[] = $record;
      $count = $count + 1;
    }
  }

  // Is role removed?
  foreach ($old_roles as $rid) {
    $record = _role_watchdog_remove_role($rid, $new_roles, $account, FALSE, $vars);
    if (is_array($record)) {
      $result[] = $record;
      $count = $count + 1;
    }
  }
  if ($count) {
    drupal_set_message(format_plural($count, t('Role change has been logged.'), t('Role changes have been logged.')));
  }
  return $result;
}