You are here

function _access_unpublished_check_hash in Access unpublished 7

Check whether a hash is present in the current URL, and if so, verify that the hash is correct.

Parameters

int: The node id to check.

Return value

boolean TRUE if the hash is present and correct, otherwise FALSE.

2 calls to _access_unpublished_check_hash()
access_unpublished_node_access in ./access_unpublished.module
Implements hook_node_access().
access_unpublished_workbench_moderation_access_alter in ./access_unpublished.module
Implements hook_workbench_moderation_access_alter().

File

./access_unpublished.module, line 168
Drupal module: Access unpublished.

Code

function _access_unpublished_check_hash($nid) {
  $au_url_key = variable_get('access_unpublished_url_key', 'hash');

  // Check hash key in url.
  $url_query = drupal_get_query_parameters();
  if (isset($url_query[$au_url_key])) {
    $url_hash = $url_query[$au_url_key];

    // Generate reference hash.
    $hash = _access_unpublished_get_hash_from_nodeid($nid);

    // Check hash match and return access state.
    if ($url_hash == $hash) {
      return TRUE;
    }
  }
}