You are here

function session_limit_user_max_sessions_byrole in Session Limit 7.2

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

Get the maximum number of sessions allowed by the roles of an account.

Parameters

user $account: The account to check the roles of.

Return value

int The maximum number of sessions the user is allowed by their roles. A value of 0 means that no role limit exists for this user and so the default should be used.

2 calls to session_limit_user_max_sessions_byrole()
session_limit_tokens in ./session_limit.tokens.inc
Implements hook_tokens().
session_limit_user_max_sessions in ./session_limit.module
Get the maximum number of sessions for a user.

File

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

Code

function session_limit_user_max_sessions_byrole($account) {
  $limits = array();
  foreach ($account->roles as $rid => $name) {
    $role_limit = variable_get("session_limit_rid_{$rid}", FALSE);
    if (!empty($role_limit)) {
      $limits[] = (int) $role_limit;
    }
  }
  return empty($limits) ? 0 : max($limits);
}