private function TripalContentService_v0_1::checkAccess

3.x TripalContentService_v0_1.inc private TripalContentService_v0_1::checkAccess($entity)

Ensures that user's only have access to content they should see.

Denies access to an entity if it is unpublished or if the user does not have permission to see it.

Parameters

$entity: The full entity object.

Throws

Exception

2 calls to TripalContentService_v0_1::checkAccess()
TripalContentService_v0_1::doEntity in tripal_ws/includes/TripalWebService/TripalContentService_v0_1.inc
Creates a resource for a single entity.
TripalContentService_v0_1::doExpandedField in tripal_ws/includes/TripalWebService/TripalContentService_v0_1.inc
Creates a resource for an expanded field of an entity.

File

tripal_ws/includes/TripalWebService/TripalContentService_v0_1.inc, line 231

Class

TripalContentService_v0_1

Code

private function checkAccess($entity) {
  global $user;

  if (!tripal_entity_access('view', $entity, $user, 'TripalEntity')) {
    throw new Exception("Permission Denied.");
  }
  // Don't show entities that aren't published
  if ($entity->status == 0) {
    throw new Exception("This record is currently unavailable.");
  }
}