You are here

function _role_watchdog_user_roles_cache in Role Watchdog 6

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

Cache the user roles on the first call to hook_user('load') to guard against modules that may incorrectly edit the $account object before calling user_save().

2 calls to _role_watchdog_user_roles_cache()
role_watchdog_user in ./role_watchdog.module
Implementation of hook_user().
role_watchdog_user_save in ./role_watchdog.module
Process role add/remove.

File

./role_watchdog.module, line 117
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];
  }
}