You are here

function tca_execute in Token Content Access 7

Determines the action that should be executed.

This will actually execute the action, and should be used when the entity is being viewed.

Parameters

string $entity_type: The entity type that's being viewed, e.g. 'node'.

object $entity: The entity that is being viewed.

2 calls to tca_execute()
tca_node_ctools_render_alter in tca_node/tca_node.module
Implements hook_ctools_render_alter().
tca_node_node_view in tca_node/tca_node.module
Implements hook_node_view().

File

./tca.module, line 462
The Token Content Access module file.

Code

function tca_execute($entity_type, $entity) {

  // Make sure Token Content Access is enabled for this entity.
  if (tca_get_active_entity($entity_type, $entity)) {

    // Get query parameters.
    $query = drupal_get_query_parameters();

    // Get the token value for this entity.
    $token = tca_get_token_entity($entity_type, $entity);

    // Check to see that a token was provided via the URL and that this node has
    // a token set and check to see if these values match.
    if (isset($query['tca']) && !empty($token) && $query['tca'] == $token) {

      // Proceed with viewing the entity.
      return;
    }
    else {

      // Deliver a 403, and exit.
      drupal_access_denied();
      drupal_exit();
    }
  }
}