You are here

function vppr_taxonomy_overview_vocabularies in Vocabulary Permissions Per Role 7

Replacement page callback for the taxonomy overview page.

Either return the default form or our own page.

1 string reference to 'vppr_taxonomy_overview_vocabularies'
vppr_menu_alter in ./vppr.module
Implements hook_menu_alter().

File

./vppr.admin.inc, line 12
Vocabulary Permissions Per Role - UI.

Code

function vppr_taxonomy_overview_vocabularies() {
  if (user_access('administer taxonomy')) {
    module_load_include('inc', 'taxonomy', 'taxonomy.admin');
    return drupal_get_form('taxonomy_overview_vocabularies');
  }
  $vocabularies = taxonomy_get_vocabularies();
  $rows = array();
  foreach ($vocabularies as $vocabulary) {
    if (user_access('administer terms in all vocabularies') || user_access('administer ' . $vocabulary->machine_name . ' vocabulary terms')) {
      $row = array();
      $row[] = check_plain($vocabulary->name);
      $row[] = l(t('list terms'), "admin/structure/taxonomy/{$vocabulary->machine_name}");
      $row[] = l(t('add terms'), "admin/structure/taxonomy/{$vocabulary->machine_name}/add");
      $rows[] = $row;
    }
  }
  $header = array(
    t('Vocabulary name'),
  );
  $header[] = array(
    'data' => t('Operations'),
    'colspan' => '2',
  );

  // TODO: Return a render array instead; this is a page callback, at last.
  return theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'empty' => t('No vocabularies available.'),
    'attributes' => array(
      'id' => 'vppr-vocabularies',
    ),
  ));
}