You are here

function activity_tokens in Activity 7

Implements hook_tokens().

File

./activity.tokens.inc, line 34
Builds placeholder replacement tokens for activity data.

Code

function activity_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $replacements = array();
  if ($type == 'user' && !empty($data['user'])) {
    foreach ($tokens as $name => $original) {
      switch ($name) {
        case 'activity-profile-link':
          $replacements[$original] = theme('activity_username', array(
            'account' => $data['user'],
          ));
          break;
      }
    }
  }
  if ($type == 'node' && !empty($data['node'])) {
    foreach ($tokens as $name => $original) {
      switch ($name) {
        case 'activity-node-link':
          $replacements[$original] = l($data['node']->title, 'node/' . $data['node']->nid);
          break;
      }
    }
  }
  return $replacements;
}