function path_access_admin_configure_form in Path Access 7
Same name and namespace in other branches
- 6 path_access.module \path_access_admin_configure_form()
Define role access form.
1 string reference to 'path_access_admin_configure_form'
- path_access_menu in ./
path_access.module - Implements hook_menu().
File
- ./
path_access.module, line 139 - Restricts access to any Drupal path on a per-role basis.
Code
function path_access_admin_configure_form($form, &$form_state, $role) {
$settings = db_query('SELECT * FROM {path_access} pa INNER JOIN {role} r ON pa.rid = r.rid WHERE pa.rid = :rid', array(
':rid' => $role->rid,
))
->fetchObject();
// Set up the database entry ready for updating.
if (!$settings) {
db_query("INSERT INTO {path_access} (rid, pages, visibility) VALUES (:rid, '', 0)", array(
':rid' => $role->rid,
));
}
drupal_set_title(t("Path access for '@role' role", array(
'@role' => $role->name,
)));
$form['page_vis_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Page specific visibility settings'),
'#collapsible' => FALSE,
);
$form['page_vis_settings']['visibility'] = array(
'#type' => 'radios',
'#title' => t('Allow users to view specific pages'),
'#options' => array(
t('Access every page except the listed pages.'),
t('Access only the listed pages.'),
),
'#default_value' => !empty($settings->visibility) ? $settings->visibility : '',
);
$form['page_vis_settings']['pages'] = array(
'#type' => 'textarea',
'#title' => t('Pages'),
'#default_value' => !empty($settings->pages) ? $settings->pages : '',
'#description' => t("Enter one page per line as a path. The '*' character is a wildcard. Example paths are '<em>blog</em>' for the blog page and '<em>blog/*</em>' for every personal blog. '<em><front></em>' is the front page."),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save path access'),
);
$form['rid'] = array(
'#type' => 'value',
'#value' => $role->rid,
);
return $form;
}