You are here

function tca_get_token in Token Content Access 7

Generates and Token Content Access Token access token for use in URLs.

This is a modified version of drupal_get_token that uses a combination of the entity id, current revision id, bundle.

Parameters

string $entity_type: The entity type; e.g. 'node' or 'user'.

object $entity: The entity from which to extract values.

mixed $value: An additional value to base the token on.

Return value

mixed string A 43-character URL-safe token for validation, based on the properties from an entity, the current time, the hash salt provided from drupal_get_hash_salt(), and the 'drupal_private_key' configuration variable. Else, return FALSE.

3 calls to tca_get_token()
tca_form in ./tca.module
Form structure for the Token Content Access configuration.
tca_node_node_insert in tca_node/tca_node.module
Implements hook_node_insert().
tca_token_replace in ./tca.module
Submit handler for the "Regenerate Token" button.

File

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

Code

function tca_get_token($entity_type, $entity, $value = '') {
  list($entity_id, $revision_id, $bundle) = entity_extract_ids($entity_type, $entity);
  if (!empty($entity_id)) {
    return drupal_hmac_base64($value, $entity_id . $revision_id . $entity_type . microtime() . drupal_get_private_key() . drupal_get_hash_salt());
  }
  else {
    return FALSE;
  }
}