function taxonomy_access_grant_table in Taxonomy Access Control 7
Generates a grant table for multiple access rules.
Parameters
array $rows: An array of grant row data, keyed by an ID (term, vocab, role, etc.). Each row should include the following keys:
- name: (optional) The label for the row (e.g., a term, vocabulary, or role name).
- view: The View grant value select box for the element.
- update: The Update grant value select box for the element.
- delete: The Delete grant value select box for the element.
- create: The Add tag grant value select box for the element.
- list: The View tag grant value select box for the element.
int $parent_vid: The parent ID for the table in the form tree structure (typically a vocabulary id).
string $first_col: The header for the first column (in the 'name' key for each row).
bool $delete: (optional) Whether to add a deletion checkbox to each row along with a "Check all" box in the table header. The checbox is automatically disabled for TAXONOMY_ACCESS_VOCABULARY_DEFAULT. Defaults to TRUE.
Return value
Renderable array containing the table.
See also
1 call to taxonomy_access_grant_table()
- taxonomy_access_admin_role in ./
taxonomy_access.admin.inc - Form constructor for a form to manage grants by role.
File
- ./
taxonomy_access.admin.inc, line 390 - Administrative interface for taxonomy access control.
Code
function taxonomy_access_grant_table(array $rows, $parent_vid, $first_col, $delete = TRUE) {
$header = taxonomy_access_grant_table_header();
if ($first_col) {
array_unshift($header, array(
'data' => $first_col,
'class' => array(
'taxonomy-access-label',
),
));
}
if ($delete) {
drupal_add_js('misc/tableselect.js');
array_unshift($header, array(
'class' => array(
'select-all',
),
));
}
$table = array(
'#type' => 'taxonomy_access_grant_table',
'#tree' => TRUE,
'#header' => $header,
);
foreach ($rows as $id => $row) {
$table[$parent_vid][$id] = taxonomy_access_admin_build_row($row, 'name', $delete);
}
// Disable the delete checkbox for the default.
if ($delete && isset($table[$parent_vid][TAXONOMY_ACCESS_VOCABULARY_DEFAULT])) {
$table[$parent_vid][TAXONOMY_ACCESS_VOCABULARY_DEFAULT]['remove']['#disabled'] = TRUE;
}
return $table;
}