You are here

function _autologout_by_role in Automated Logout 7.2

Same name and namespace in other branches
  1. 5 autologout.module \_autologout_by_role()
  2. 6 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_view in ./autologout.module
Implements hook_block_view().
autologout_init in ./autologout.module
Implements hook_init().

File

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

Code

function _autologout_by_role($passed_user = NULL) {
  global $user;
  if ($passed_user === NULL) {
    $local_user = $user;
  }
  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, array_values($local_user->roles))) {
          return TRUE;
        }
        break;
      case 2:

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