1 taxonomy.module taxonomy_vocabulary_access($op, $vocabulary)

Access callback: Checks a user's permission for performing operations on taxonomy terms in a vocabulary.

@since 1.13.0 The "edit" $op option is deprecated. Use "update" instead.

Parameters

$op: The operation to be performed on taxonomy terms in the vocabulary, or FALSE to check access for any operation.

TaxonomyVocabulary $vocabulary: The $vocabulary object that contains the terms on which the operation is to be performed.

Return value

TRUE if the user has access, FALSE otherwise.:

See also

taxonomy_menu()

File

core/modules/taxonomy/taxonomy.module, line 500
Enables the organization of content into categories.

Code

function taxonomy_vocabulary_access($op, $vocabulary) {
  // Deny access if there is no vocabulary to check against.
  if (!$vocabulary) {
    return FALSE;
  }

  // Users with the 'administer taxonomy' permission always have access.
  if (user_access('administer taxonomy')) {
    return TRUE;
  }

  // Even though "edit" is deprecated it's still in the permissions
  // so log it as deprecated but still use it.
  if ($op == 'edit') {
    $message = 'The function taxonomy_vocabulary_access() was called with the operation <em>edit</em>. This operation is now named <em>update</em>. The <em>edit</em> operation will be removed in the next major release of Backdrop.';
    $variables = array();
    watchdog('taxonomy', $message, $variables, WATCHDOG_DEPRECATED);
  }
  elseif ($op == 'update') {
    return user_access("edit terms in $vocabulary->machine_name");
  }

  if ($op !== FALSE) {
    return user_access("$op terms in $vocabulary->machine_name");
  }
  else {
    // Check access for each create/update (edit)/delete operation for terms
    // in the vocabulary and return TRUE if any of them are allowed.
    $operations = array('create', 'edit', 'delete');
    foreach ($operations as $operation) {
      if (user_access("$operation terms in $vocabulary->machine_name")) {
        return TRUE;
      }
    }

    // Deny access if the user doesn't have any permissions for the vocabulary.
    return FALSE;
  }
}