You are here

function _autologout_by_role in Automated Logout 5

Same name and namespace in other branches
  1. 6 autologout.module \_autologout_by_role()
  2. 7.2 autologout.module \_autologout_by_role()

_autologout_by_role()

Is the user in a role that we exclude from features defined by this module

Parameters

$passed_user: A drupal "user" object or default FALSE (use global $user)

Return value

bool TRUE if user s to be excluded, FALSE otherwise

2 calls to _autologout_by_role()
autologout_block in ./autologout.module
Implementation of hook_block()
autologout_footer in ./autologout.module
Implementation of hook_footer()

File

./autologout.module, line 420
Used to automagically log out a user after a preset time, AjK May 2006

Code

function _autologout_by_role($passed_user = FALSE) {
  global $user;

  // this bit I am unsure about, if I don't user the
  // user_load() function here, I don't see my inserted
  // value "autologout" in the global $user object ??
  if (FALSE == $passed_user) {
    $local_user = user_load(array(
      'uid' => $user->uid,
    ));
  }
  else {
    $local_user = $passed_user;
  }
  foreach (user_roles(TRUE) as $role) {
    switch (_autologout_local_settings($role)) {
      case 0:

        // Enforce for all in this role
        break;
      case 1:

        // Exclude all users in this role
        if (in_array($role, $local_user->roles)) {
          return TRUE;
        }
        break;
      case 2:

        // Exclude user if user set to disable
        if (in_array($role, $local_user->roles)) {
          if (isset($local_user->autologout) && $local_user->autologout != 0) {
            return TRUE;
          }
        }
        break;
    }
  }
  return FALSE;
}