You are here

function session_limit_user_max_sessions in Session Limit 7.2

Same name and namespace in other branches
  1. 6.2 session_limit.module \session_limit_user_max_sessions()
  2. 6 session_limit.module \session_limit_user_max_sessions()

Get the maximum number of sessions for a user.

Parameters

user $account: (optional) The user account to check. If not supplied the active user account is used.

4 calls to session_limit_user_max_sessions()
session_limit_help in ./session_limit.module
Implements hook_help().
session_limit_init in ./session_limit.module
Implements hook_init().
session_limit_session_limit in ./session_limit.module
Implements hook_session_limit().
session_limit_tokens in ./session_limit.tokens.inc
Implements hook_tokens().

File

./session_limit.module, line 509
Limits multiple sessions per user.

Code

function session_limit_user_max_sessions($account = NULL) {
  $limits =& drupal_static(__FUNCTION__, array());
  if (empty($account)) {
    $account = $GLOBALS['user'];
  }
  if (!isset($limits[$account->uid])) {
    $limits[$account->uid] = (int) variable_get('session_limit_max', 1);
    $limit_account = session_limit_user_max_sessions_byuser($account);
    $limit_role = session_limit_user_max_sessions_byrole($account);
    if ($limit_account > 0) {
      $limits[$account->uid] = $limit_account;
    }
    elseif ($limit_role > 0) {
      $limits[$account->uid] = $limit_role;
    }
    $limits[$account->uid] = (int) $limits[$account->uid];
  }
  return $limits[$account->uid];
}