function menu_position_menu_position_rule_user_role_form in Menu Position 7
Same name and namespace in other branches
- 7.2 plugins/menu_position.user_roles.inc \menu_position_menu_position_rule_user_role_form()
Adds form elements for the "user role" plugin to the rule configuration form.
Parameters
$form: A reference to the "add/edit rule" form array. New form elements should be added directly to this array.
$form_state: A reference to the current form state.
File
- plugins/
menu_position.user_roles.inc, line 35 - Provides the "User roles" rule plugin for the Menu Position module.
Code
function menu_position_menu_position_rule_user_role_form(&$form, &$form_state) {
// If this is an existing rule, load the variables stored in the rule for this plugin.
$variables = !empty($form_state['#menu-position-rule']['conditions']['user_role']) ? $form_state['#menu-position-rule']['conditions']['user_role'] : array();
$form['conditions']['user_role'] = array(
'#type' => 'fieldset',
'#title' => t('User roles'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#attached' => array(
'js' => array(
drupal_get_path('module', 'menu_position') . '/plugins/menu_position.user_roles.js',
),
),
);
$form['conditions']['user_role']['user_role'] = array(
'#type' => 'checkboxes',
'#title' => t('User roles'),
'#default_value' => !empty($variables['user_role']) ? $variables['user_role'] : array(),
'#options' => user_roles(TRUE),
'#description' => t('Apply this rule on pages when the currently logged in user has this role(s).'),
'#weight' => -20,
);
// Add a submit handler.
$form['#submit'][] = 'menu_position_menu_position_rule_user_role_form_submit';
}