You are here

function _role_watchdog_user_roles_cache in Role Watchdog 7

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

Cache user roles in case a poorly-behave module modifies $account before calling user save.

2 calls to _role_watchdog_user_roles_cache()
role_watchdog_user_load in ./role_watchdog.module
Implements hook_user_load().
role_watchdog_user_save in ./role_watchdog.module
Process role add/remove.

File

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

Code

function _role_watchdog_user_roles_cache($uid, $roles = FALSE) {
  static $user_roles = array();
  if (!isset($user_roles[$uid]) && is_array($roles)) {
    $user_roles[$uid] = $roles;
  }
  if (!isset($user_roles[$uid])) {
    return array();
  }
  else {
    return $user_roles[$uid];
  }
}