function cas_roles_admin_settings in CAS roles 7.2
Same name and namespace in other branches
- 8 cas_roles.admin.inc \cas_roles_admin_settings()
- 6 cas_roles.admin.inc \cas_roles_admin_settings()
- 7 cas_roles.admin.inc \cas_roles_admin_settings()
Administrative settings form.
1 string reference to 'cas_roles_admin_settings'
- cas_roles_menu in ./
cas_roles.module - Implements hook_menu().
File
- ./
cas_roles.admin.inc, line 11 - Provides settings pages for the CAS Attributes module.
Code
function cas_roles_admin_settings() {
$form['cas_roles_sync_every_login'] = array(
'#type' => 'radios',
'#title' => t('Fetch CAS Roles'),
'#default_value' => variable_get('cas_roles_sync_every_login', 1),
'#options' => array(
0 => t('only when a CAS account is created (i.e., the first login of a CAS user).'),
1 => t('every time a CAS user logs in.'),
),
'#weight' => -10,
);
$form['cas_roles_roles'] = array(
'#type' => 'textfield',
'#title' => t('Attribute for roles'),
'#default_value' => variable_get('cas_roles_roles', ''),
'#size' => 50,
'#description' => t('CAS Attributes may be arrays, use the tokens syntax starting with "[cas:attribute:" global tokens are also replaced.<br />Example: [cas:attribute:drupal_roles]'),
'#weight' => -8,
);
$form['cas_roles_require_a_role_create'] = array(
'#type' => 'checkbox',
'#title' => t('Require at least one CAS managed role for new users'),
'#default_value' => variable_get('cas_roles_require_a_role_create', FALSE),
'#description' => t('New users will only be added to the system if at least one CAS managed role matches (one of the fields below which is not empty)'),
'#weight' => -7,
);
$form['cas_roles_require_a_role_login'] = array(
'#type' => 'checkbox',
'#title' => t('Require at least one CAS managed role for any user to log in'),
'#default_value' => variable_get('cas_roles_require_a_role_login', FALSE),
'#description' => t('Users will be denied access if not at least one CAS managed role matches (one of the fields below which is not empty)'),
'#weight' => -7,
);
$form['cas_roles_relations'] = array(
'#type' => 'fieldset',
'#title' => t('CAS roles mappings'),
'relations' => array(),
'#tree' => TRUE,
'#weight' => -6,
);
$form['cas_roles_relations']['help'] = array(
'#markup' => t('Regular expression to map <a href="@url">user roles</a>. The role is assigned if one of the roles in the attribute array matches the expression. An empty field means the role is not administrated by CAS.', array(
'@url' => url('admin/people/permissions/roles'),
)),
);
$relations = variable_get('cas_roles_relations', array());
$authenticated_role = user_roles(TRUE);
$authenticated_role = $authenticated_role[DRUPAL_AUTHENTICATED_RID];
$form['cas_roles_relations'][$authenticated_role] = array(
'#type' => 'textfield',
'#title' => t('authenticated user'),
'#default_value' => isset($relations[$authenticated_role]) ? $relations[$authenticated_role] : '',
'#size' => 50,
'#maxlength' => 1024,
'#element_validate' => array(
'_cas_roles_preg_validate',
),
'#states' => array(
'visible' => array(
array(
':input[name="cas_roles_require_a_role_create"]' => array(
'checked' => TRUE,
),
),
array(
':input[name="cas_roles_require_a_role_login"]' => array(
'checked' => TRUE,
),
),
),
),
'#description' => t('The "authenticated user" role will be assigned to all users that are allowed to log in.'),
);
foreach (cas_roles_cutsom_user_roles() as $rid => $role) {
$form['cas_roles_relations'][$role] = array(
'#type' => 'textfield',
'#title' => $role,
'#default_value' => isset($relations[$role]) ? $relations[$role] : '',
'#size' => 50,
'#maxlength' => 1024,
'#element_validate' => array(
'_cas_roles_preg_validate',
),
);
}
return system_settings_form($form);
}