You are here

function ajax_comments_preprocess_comment in AJAX Comments 6

Same name and namespace in other branches
  1. 8 ajax_comments.module \ajax_comments_preprocess_comment()
  2. 7 ajax_comments.module \ajax_comments_preprocess_comment()

Process variables for comment.tpl.php.

File

./ajax_comments.module, line 252
Implements AJAX handling for Drupal comment forms.

Code

function ajax_comments_preprocess_comment(&$variables) {
  $comment = $variables['comment'];

  // Insert proper delete links (fix until hook_link_alter will not work propertly)
  if ($variables['links'] && user_access('administer comments')) {
    $links = module_invoke_all('link', 'comment', $comment, 0);
    $links['comment_delete'] = array(
      'title' => t('delete'),
      'href' => 'comment/delete/' . $comment->cid,
      'query' => 'token=' . drupal_get_token($comment->cid),
    );
    $variables['links'] = isset($links) ? theme('links', $links) : '';
  }
  if (!$comment->cid) {
    $variables['new'] = t('preview');
    $variables['comment']->new = TRUE;
  }
  else {
    $variables['title'] = l($comment->subject, 'node/' . $comment->nid, array(
      'attributes' => array(
        'class' => 'active',
      ),
      'fragment' => "comment-{$comment->cid}",
    ));
  }
}