You are here

function commentactivity_token_values in Activity 6

Same name and namespace in other branches
  1. 5.4 contrib/commentactivity/commentactivity.module \commentactivity_token_values()
  2. 5.3 contrib/commentactivity/commentactivity.module \commentactivity_token_values()

Token module integration. Defines available default token values.

File

contrib/commentactivity/commentactivity.module, line 85

Code

function commentactivity_token_values($type, $data = NULL, $options = array()) {
  static $authors;
  if ($type == 'commentactivity' && !empty($data)) {
    if (!isset($authors[$data['parent-node-author-uid']])) {
      $authors[$data['parent-node-author-uid']] = activity_user_load($data['parent-node-author-uid']);
    }
    $parent_node_author = $authors[$data['parent-node-author-uid']];
    if (isset($data['parent-comment-author-uid'])) {
      if (!isset($authors[$data['parent-comment-author-uid']])) {
        $authors[$data['parent-comment-author-uid']] = activity_user_load($data['parent-comment-author-uid']);
      }
      $parent_comment_author = $authors[$data['parent-comment-author-uid']];
    }
    $data['comment-link'] = l($data['comment-subject'], 'node/' . $data['parent-node-id'], array(
      'fragment' => 'comment-' . $data['comment-cid'],
    ));
    $data['parent-node-author'] = theme('activity_username', $parent_node_author, TRUE);
    $data['parent-node-author-name'] = $parent_node_author->name;
    $data['parent-node-type'] = theme('activity_node_type', $data['parent-node-type']);
    $data['parent-node-link'] = l($data['parent-node-title'], 'node/' . $data['parent-node-id']);
    if ($parent_comment_author) {
      $data['parent-comment-author'] = theme('activity_username', $parent_comment_author, TRUE);
      $data['parent-comment-author-name'] = $parent_comment_author->name;
      $data['parent-comment-link'] = l($data['parent-comment-subject'], 'node/' . $data['parent-node-id'], array(
        'fragment' => 'comment-' . $data['parent-comment-cid'],
      ));
    }
    return $data;
  }
}