You are here

function node_authlink_tokens in Node authorize link 7

Same name and namespace in other branches
  1. 8 node_authlink.module \node_authlink_tokens()

Implements hook_tokens().

File

./node_authlink.module, line 346
Provides functionality for the node_authlink module.

Code

function node_authlink_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $replacements = array();
  if ($type == 'node' && !empty($data['node']->authkey)) {
    $node = $data['node'];
    foreach ($tokens as $name => $original) {
      switch ($name) {
        case 'authlink:authkey':
          $replacements[$original] = $node->authkey;
          break;
        case 'authlink:view-url':
          $replacements[$original] = node_authlink_get_url($node, 'view');
          break;
        case 'authlink:edit-url':
          $replacements[$original] = node_authlink_get_url($node, 'edit');
          break;
        case 'authlink:delete-url':
          $replacements[$original] = node_authlink_get_url($node, 'delete');
          break;
      }
    }
  }
  return $replacements;
}