You are here

function taxonomy_access_admin_build_row in Taxonomy Access Control 7

Same name and namespace in other branches
  1. 5.2 taxonomy_access_admin.inc \taxonomy_access_admin_build_row()
  2. 6 taxonomy_access.admin.inc \taxonomy_access_admin_build_row()

Assembles a row of grant options for a term or default on the admin form.

Parameters

array $grants: An array of grants to use as form defaults.

$label_key: (optional) Key of the column to use as a label in each grant row. Defaults to NULL.

2 calls to taxonomy_access_admin_build_row()
taxonomy_access_grant_add_table in ./taxonomy_access.admin.inc
Generates a grant table for adding access rules with one set of values.
taxonomy_access_grant_table in ./taxonomy_access.admin.inc
Generates a grant table for multiple access rules.

File

./taxonomy_access.admin.inc, line 519
Administrative interface for taxonomy access control.

Code

function taxonomy_access_admin_build_row(array $grants, $label_key = NULL, $delete = FALSE) {
  $form['#tree'] = TRUE;
  if ($delete) {
    $form['remove'] = array(
      '#type' => 'checkbox',
      '#title' => t('Delete access rule for @name', array(
        '@name' => $grants[$label_key],
      )),
      '#title_display' => 'invisible',
    );
  }
  if ($label_key) {
    $form[$label_key] = array(
      '#type' => 'markup',
      '#markup' => check_plain($grants[$label_key]),
    );
  }
  foreach (array(
    'view',
    'update',
    'delete',
    'create',
    'list',
  ) as $grant) {
    $for = $label_key ? $grants[$label_key] : NULL;
    $form[$grant] = array(
      '#type' => 'select',
      '#title' => _taxonomy_access_grant_field_label($grant, $for),
      '#title_display' => 'invisible',
      '#default_value' => is_string($grants['grant_' . $grant]) ? $grants['grant_' . $grant] : TAXONOMY_ACCESS_NODE_IGNORE,
      '#required' => TRUE,
    );
  }
  foreach (array(
    'view',
    'update',
    'delete',
  ) as $grant) {
    $form[$grant]['#options'] = array(
      TAXONOMY_ACCESS_NODE_ALLOW => t('Allow'),
      TAXONOMY_ACCESS_NODE_IGNORE => t('Ignore'),
      TAXONOMY_ACCESS_NODE_DENY => t('Deny'),
    );
  }
  foreach (array(
    'create',
    'list',
  ) as $grant) {
    $form[$grant]['#options'] = array(
      TAXONOMY_ACCESS_TERM_ALLOW => t('Allow'),
      TAXONOMY_ACCESS_TERM_DENY => t('Deny'),
    );
  }
  return $form;
}