function restrict_by_ip_role_settings in Restrict Login or Role Access by IP Address 6.3
Same name and namespace in other branches
- 7.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 319 - 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(
'#value' => t('No roles configured. <a href="@add-role">Add a role</a>.', array(
'@add-role' => url('admin/user/roles'),
)),
'#prefix' => '<p>',
'#suffix' => '</p>',
);
}
foreach ($user_roles as $rid => $name) {
$form['restrict_role_by_ip_' . $rid] = array(
'#type' => 'fieldset',
'#title' => t($name),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['restrict_role_by_ip_' . $rid]['restrict_by_ip_role' . $rid] = array(
'#type' => 'textfield',
'#title' => t('Allowed IP range'),
'#description' => t('Enter IP Address Ranges in CIDR Notation seperated 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' . $rid, ''),
);
}
return system_settings_form($form);
}