Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save HelenaEksler/92b8bc56c0de379af449 to your computer and use it in GitHub Desktop.
Save HelenaEksler/92b8bc56c0de379af449 to your computer and use it in GitHub Desktop.
checkEntityAccess()
/**
* Overrides \RestfulEntityBaseTaxonomyTerm::checkEntityAccess().
*
* Allow access to create "Tags" resource for privileged users, as
* we can't use entity_access() since entity_metadata_taxonomy_access()
* denies it for a non-admin user.
*/
protected function checkEntityAccess($op, $entity_type, $entity) {
$account = $this->getAccount();
$resource_name = $this->getResourceName();
if ($resource_name == 'tags') {
$group = c4m_restful_get_group_by_og_vocab_name($entity->vocabulary_machine_name);
$gid = $group[0]->gid;
return og_user_access('node', $gid, 'edit terms', $account);
}
elseif ($resource_name == 'categories') {
$group = c4m_restful_get_group_by_og_vocab_name($entity->vocabulary_machine_name);
$gid = $group[0]->gid;
return og_user_access('node', $gid, 'administer group', $account);
}
return user_access('create content', $account);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment