function theme_merci_permissions_form in MERCI (Manage Equipment Reservations, Checkout and Inventory) 8.2
Same name and namespace in other branches
- 6.2 modules/merci_permissions/merci_permissions.module \theme_merci_permissions_form()
- 6 modules/merci_permissions/merci_permissions.module \theme_merci_permissions_form()
- 7.2 modules/merci_permissions/merci_permissions.module \theme_merci_permissions_form()
@todo Please document this function.
See also
File
- modules/
merci_permissions/ merci_permissions.module, line 41 - Provides functions for resetting permissions on the permission page.
Code
function theme_merci_permissions_form($variables) {
$form = $variables['form'];
$roles = user_roles();
$rows = array();
foreach (element_children($form['permission']) as $key) {
// Don't take form control structures
if (is_array($form['permission'][$key])) {
// Module name
$row = array();
if (is_numeric($key)) {
$row[] = array(
'data' => drupal_render($form['permission'][$key]),
'class' => array(
'module',
),
'id' => 'module-' . $form['permission'][$key]['#id'],
'colspan' => count($form['role_names']['#value']) + 1,
);
}
else {
$row[] = array(
'data' => drupal_render($form['permission'][$key]),
'class' => array(
'permission',
),
);
foreach (element_children($form['checkboxes']) as $rid) {
if (is_array($form['checkboxes'][$rid])) {
$form['checkboxes'][$rid][$key]['#title'] = $roles[$rid] . ': ' . $form['permission'][$key]['#markup'];
$form['checkboxes'][$rid][$key]['#title_display'] = 'invisible';
$row[] = array(
'data' => drupal_render($form['checkboxes'][$rid][$key]),
'class' => array(
'checkbox',
),
);
}
}
}
$rows[] = $row;
}
}
$header[] = t('Permission');
foreach (element_children($form['role_names']) as $rid) {
if (is_array($form['role_names'][$rid])) {
$header[] = array(
'data' => drupal_render($form['role_names'][$rid]),
'class' => array(
'checkbox',
),
);
}
}
$output = theme('table', array(
'header' => $header,
'rows' => $rows,
'attributes' => array(
'id' => 'permissions',
),
));
$output .= drupal_render_children($form);
return $output;
}