function theme__taxonomy_access_permissions_form in Taxonomy Access Control 5
Renders the permission matrix user form for choosen user role.
File
- ./
taxonomy_access_admin.inc, line 159 - Administrative interface for taxonomy access control.
Code
function theme__taxonomy_access_permissions_form($form) {
global $tac_user_roles;
$rid = arg(3);
$vids = array_keys($form['taxonomy_access']);
$node_grant_types = array(
'view',
'update',
'delete',
);
$header = array();
$header[] = array(
'data' => t('Category'),
);
$header[] = array(
'data' => t('View'),
'colspan' => 4,
);
$header[] = array(
'data' => t('Update'),
'colspan' => 4,
);
$header[] = array(
'data' => t('Delete'),
'colspan' => 4,
);
$header[] = array(
'data' => t('Create'),
);
$header[] = array(
'data' => t('List'),
);
$sub_header[] = ' <strong>' . t('A') . '</strong>';
$sub_header[] = ' <strong>' . t('I') . '</strong>';
$sub_header[] = ' <strong>' . t('D') . '</strong>';
$sub_header[] = ' ';
$radios = array(
'1' => t('Allow'),
'0' => t('Ignore'),
'2' => t('Deny'),
);
$output = '<h2>' . t('Permissions for') . " '" . $tac_user_roles[$rid] . "'</h2><p>";
foreach ($vids as $vid) {
if (is_integer($vid)) {
$rows = array();
if ($vid == 0) {
// Do the row for uncategorized nodes
$row = array();
$row[] = '<strong>' . t('Uncategorized nodes') . '</strong>';
foreach ($node_grant_types as $grant) {
$row[] = array(
'data' => drupal_render($form['taxonomy_access'][0]['term'][0][$grant]),
'colspan' => 4,
);
}
$row[] = ' ';
$row[] = ' ';
$rows[] = $row;
$output_table = theme('table', $header, $rows);
$output .= theme_fieldset(array(
'#title' => 'Uncategorized nodes',
'#value' => $output_table,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
));
}
else {
//1st row: 'Allow all'... 'Select All'...
unset($row);
$row = array();
$row[] = array(
'data' => '<strong>' . $form['taxonomy_access'][$vid]['#title'] . '</strong>',
);
foreach ($node_grant_types as $grant) {
$row[] = array(
'data' => drupal_render($form['taxonomy_access'][$vid]['vocab'][$grant]),
'colspan' => 4,
);
}
foreach (array(
'create',
'list',
) as $grant) {
$row[] = array(
'data' => drupal_render($form['taxonomy_access'][$vid]['vocab'][$grant]),
);
}
$rows[] = $row;
//2nd row: 'A' 'I' 'D'
$row = array();
$row[] = ' ';
foreach ($node_grant_types as $grant) {
$row = array_merge($row, $sub_header);
}
$row[] = array(
'data' => ' ',
'colspan' => 2,
);
$rows[] = $row;
//3rd row: Defaults
$row = array();
$row[] = '<blockquote><em>' . t('Default') . '</em></blockquote>';
foreach (array(
'view',
'update',
'delete',
) as $grant) {
foreach (array_keys($radios) as $key) {
// I need this hack to display radio buttons horizontally (instead of standard form 'radios')
$row[] = array(
'data' => drupal_render($form['taxonomy_access'][$vid]['default'][$grant][$key]),
);
}
$row[] = ' ';
}
foreach (array(
'create',
'list',
) as $grant) {
$row[] = array(
'data' => drupal_render($form['taxonomy_access'][$vid]['default'][$grant]),
'align' => 'center',
);
}
$rows[] = $row;
//4th row: Empty row
$row = array();
$row[] = array(
'data' => ' ',
'colspan' => 15,
);
$rows[] = $row;
// Rows for each term in vocabulary
$terms = array();
$terms = taxonomy_get_tree($vid);
if ($terms) {
foreach ($terms as $term) {
$row = array();
$row[] = str_repeat('-', $term->depth) . $term->name;
foreach ($node_grant_types as $grant) {
// I need this hack to display radio buttons horizontally (instead of standard form 'radios')
foreach (array_keys($radios) as $key) {
$row[] = drupal_render($form['taxonomy_access'][$vid]['term'][$term->tid][$grant][$key]);
}
$row[] = ' ';
}
foreach (array(
'create',
'list',
) as $grant) {
$row[] = array(
'data' => drupal_render($form['taxonomy_access'][$vid]['term'][$term->tid][$grant]),
'align' => 'center',
);
}
$rows[] = $row;
}
}
$output_table = theme('table', $header, $rows);
$output .= theme_fieldset(array(
'#title' => $form['taxonomy_access'][$vid]['#title'],
'#value' => $output_table,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
));
}
}
}
$output .= drupal_render($form);
return $output;
}