You are here

function session_limit_settings_byrole in Session Limit 7.2

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

Settings by role form.

1 string reference to 'session_limit_settings_byrole'
session_limit_menu in ./session_limit.module
Implements hook_menu().

File

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

Code

function session_limit_settings_byrole() {
  $result = db_select('variable', 'v')
    ->fields('v', array(
    'name',
    'value',
  ))
    ->condition('name', 'session_limit_rid_%', 'LIKE')
    ->orderBy('name')
    ->execute();
  foreach ($result as $setting) {
    $role_limits[$setting->name] = unserialize($setting->value);
  }
  $roles = user_roles(TRUE);
  foreach ($roles as $rid => $role) {
    $form["session_limit_rid_{$rid}"] = array(
      '#type' => 'select',
      '#options' => _session_limit_user_options(),
      '#title' => check_plain($role),
      '#default_value' => empty($role_limits["session_limit_rid_{$rid}"]) ? 0 : $role_limits["session_limit_rid_{$rid}"],
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save permissions'),
  );
  return $form;
}