function comment_links

Helper function, build links for an individual comment.

Adds reply, edit, delete etc. depending on the current user permissions.

Parameters

$comment: The comment object.

$node: The node the comment is attached to.

Return value

A structured array of links.

1 call to comment_links()
comment_build_content in drupal/modules/comment/comment.module
Builds a structured array representing the comment's content.

File

drupal/modules/comment/comment.module, line 1037
Enables users to comment on published content.

Code

function comment_links($comment, $node) {
  $links = array();
  if ($node->comment == COMMENT_NODE_OPEN) {
    if (user_access('administer comments') && user_access('post comments')) {
      $links['comment-delete'] = array(
        'title' => t('delete'),
        'href' => "comment/{$comment->cid}/delete",
        'html' => TRUE,
      );
      $links['comment-edit'] = array(
        'title' => t('edit'),
        'href' => "comment/{$comment->cid}/edit",
        'html' => TRUE,
      );
      $links['comment-reply'] = array(
        'title' => t('reply'),
        'href' => "comment/reply/{$comment->nid}/{$comment->cid}",
        'html' => TRUE,
      );
      if ($comment->status == COMMENT_NOT_PUBLISHED) {
        $links['comment-approve'] = array(
          'title' => t('approve'),
          'href' => "comment/{$comment->cid}/approve",
          'html' => TRUE,
          'query' => array(
            'token' => drupal_get_token("comment/{$comment->cid}/approve"),
          ),
        );
      }
    }
    elseif (user_access('post comments')) {
      if (comment_access('edit', $comment)) {
        $links['comment-edit'] = array(
          'title' => t('edit'),
          'href' => "comment/{$comment->cid}/edit",
          'html' => TRUE,
        );
      }
      $links['comment-reply'] = array(
        'title' => t('reply'),
        'href' => "comment/reply/{$comment->nid}/{$comment->cid}",
        'html' => TRUE,
      );
    }
    else {
      $links['comment_forbidden']['title'] = theme('comment_post_forbidden', array(
        'node' => $node,
      ));
      $links['comment_forbidden']['html'] = TRUE;
    }
  }
  return $links;
}