function theme_nodeaccess_grants_form in Nodeaccess 6
Same name and namespace in other branches
- 5 nodeaccess.module \theme_nodeaccess_grants_form()
- 6.2 nodeaccess.module \theme_nodeaccess_grants_form()
- 7 nodeaccess.module \theme_nodeaccess_grants_form()
Theme function for nodeaccess_grants_form.
File
- ./
nodeaccess.module, line 557
Code
function theme_nodeaccess_grants_form($form) {
$allowed_roles = variable_get('nodeaccess-roles', array());
$allowed_grants = variable_get('nodeaccess-grants', array());
// Roles table.
$roles = element_children($form['rid']);
if (count($roles) && count($allowed_roles)) {
$header = array();
$header[] = t('Role');
if ($allowed_grants['view']) {
$header[] = t('View');
}
if ($allowed_grants['edit']) {
$header[] = t('Edit');
}
if ($allowed_grants['delete']) {
$header[] = t('Delete');
}
foreach ($roles as $key) {
if ($allowed_roles[$key]) {
$row = array();
$row[] = $form['rid'][$key]['name']['#value'] . drupal_render($form['rid'][$key]['name']);
if ($allowed_grants['view']) {
$row[] = drupal_render($form['rid'][$key]['grant_view']);
}
if ($allowed_grants['edit']) {
$row[] = drupal_render($form['rid'][$key]['grant_update']);
}
if ($allowed_grants['delete']) {
$row[] = drupal_render($form['rid'][$key]['grant_delete']);
}
$rows[] = $row;
}
}
$output .= theme('table', $header, $rows);
}
// Search form.
$output .= '<p><div class="search-form">';
$output .= '<strong>' . t('Enter names to search for users:') . '</strong>';
$output .= '<div class="container-inline">';
$output .= drupal_render($form['keys']);
$output .= drupal_render($form['search']);
$output .= '</div></div></p>';
// Users table.
unset($rows);
$users = element_children($form['uid']);
if (count($users) > 0) {
$header = array();
$header[] = t('User');
$header[] = t('Keep?');
if ($allowed_grants['view']) {
$header[] = t('View');
}
if ($allowed_grants['edit']) {
$header[] = t('Edit');
}
if ($allowed_grants['delete']) {
$header[] = t('Delete');
}
foreach ($users as $key) {
$row = array();
$row[] = $form['uid'][$key]['name']['#value'];
$row[] = drupal_render($form['uid'][$key]['keep']);
if ($allowed_grants['view']) {
$row[] = drupal_render($form['uid'][$key]['grant_view']);
}
if ($allowed_grants['edit']) {
$row[] = drupal_render($form['uid'][$key]['grant_update']);
}
if ($allowed_grants['delete']) {
$row[] = drupal_render($form['uid'][$key]['grant_delete']);
}
$rows[] = $row;
}
$output .= theme('table', $header, $rows);
}
$output .= drupal_render($form);
return $output;
}