1 taxonomy.entity.inc public TaxonomyTerm::access($op, $account = NULL)

Overrides Entity::access().

Parameters

string $op: The operation to be performed on the taxonomy term. Possible values are:

  • create
  • view
  • update
  • delete

User|AnonymousUser|object $account: (optional) The user to check for. Leave it to NULL to check for the global user.

Return value

bool: TRUE if access is granted, FALSE otherwise.

Overrides Entity::access

File

core/modules/taxonomy/taxonomy.entity.inc, line 142
Entity classes and controllers for Taxonomy module.

Class

TaxonomyTerm
Defines the taxonomy term entity.

Code

public function access($op, $account = NULL) {
  if ($op == 'create') {
    return self::createAccess($this->bundle(), $account);
  }
  elseif (!in_array($op, array('view', 'update', 'delete'), TRUE)) {
    // If the $op was not one of the supported ones, we return access denied.
    return FALSE;
  }

  // If no user object is supplied, the access check is for the current user.
  if (empty($account)) {
    $account = $GLOBALS['user'];
  }

  if ($op == 'view') {
    return user_access('access content', $account);
  }
  elseif ($op == 'update') {
    return user_access("edit terms in $this->vocabulary", $account) || user_access('administer taxonomy', $account);
  }
  elseif ($op == 'delete') {
    return user_access("delete terms in $this->vocabulary", $account) || user_access('administer taxonomy', $account);
  }

  return FALSE;
}