1.20.x comment.module comment_links(Comment $comment, Node $node)

Adds reply, edit, delete, etc. links, depending on user permissions.

Parameters

Comment $comment: The comment object.

Node $node: The node the comment is attached to.

Return value

A structured array of links.:

File

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

Code

function comment_links(Comment $comment, Node $node) {
  $links = array();
  if ($node->comment == COMMENT_NODE_OPEN) {
    if ($comment->access('delete')) {
      $links['comment-delete'] = array(
        'title' => t('delete'),
        'href' => "comment/$comment->cid/delete",
        'html' => TRUE,
      );
    }
    if ($comment->access('update')) {
      $links['comment-edit'] = array(
        'title' => t('edit'),
        'href' => "comment/$comment->cid/edit",
        'html' => TRUE,
      );
    }
    if (Comment::createAccess()) {
      $links['comment-reply'] = array(
        'title' => t('reply'),
        'href' => "comment/reply/$comment->nid/$comment->cid",
        'html' => TRUE,
      );
    }
    if ($comment->status == COMMENT_NOT_PUBLISHED && $comment->access('approve')) {
      $links['comment-approve'] = array(
        'title' => t('approve'),
        'href' => "comment/$comment->cid/approve",
        'html' => TRUE,
        'query' => array('token' => backdrop_get_token("comment/$comment->cid/approve")),
      );
    }
    if (empty($links)) {
      $links['comment-forbidden']['title'] = theme('comment_post_forbidden', array('node' => $node));
      $links['comment-forbidden']['html'] = TRUE;
    }
  }
  return $links;
}