function restrict_by_ip_role_settings in Restrict Login or Role Access by IP Address 7.3
Same name and namespace in other branches
- 6.3 restrict_by_ip.module \restrict_by_ip_role_settings()
Menu callback for restrict role settings
1 string reference to 'restrict_by_ip_role_settings'
- restrict_by_ip_menu in ./
restrict_by_ip.module - Implementation of hook_menu().
File
- ./
restrict_by_ip.module, line 316 - Allows the admin to select which ip addresses role or a user can login from for this site Some of the code below is taken from the cck_ipaddress_module
Code
function restrict_by_ip_role_settings() {
drupal_set_title(t('Restrict role by IP'));
$form = array();
$user_roles = user_roles(TRUE);
// Get all roles except anonymous
unset($user_roles[array_search(t('authenticated user'), $user_roles)]);
// Remove default authenticated user role
if (count($user_roles) === 0) {
$form['no_roles'] = array(
'#markup' => t('No roles configured. <a href="@add-role">Add a role</a>.', array(
'@add-role' => url('admin/people/permissions/roles'),
)),
'#prefix' => '<p>',
'#suffix' => '</p>',
);
}
foreach ($user_roles as $rid => $name) {
$form_name = _restrict_by_ip_hash_role_name($name);
$form['restrict_role_by_ip_' . $form_name] = array(
'#type' => 'fieldset',
'#title' => t($name),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['restrict_role_by_ip_' . $form_name]['restrict_by_ip_role_' . $form_name] = array(
'#type' => 'textfield',
'#title' => t('Allowed IP range'),
'#maxlength' => NULL,
'#description' => t('Enter IP Address Ranges in CIDR Notation separated with semi-colons, with no trailing semi-colon. E.G. 10.20.30.0/24;192.168.199.1/32;1.0.0.0/8<br />For more information on CIDR notation click <a href="http://www.brassy.net/2007/mar/cidr_basic_subnetting">here</a>.<br />Leave field blank to disable IP restrictions for ' . $name),
'#default_value' => variable_get('restrict_by_ip_role_' . $form_name, ''),
);
}
return system_settings_form($form);
}