You are here

function comment_links in Drupal 4

Same name and namespace in other branches
  1. 5 modules/comment/comment.module \comment_links()
  2. 6 modules/comment/comment.module \comment_links()
  3. 7 modules/comment/comment.module \comment_links()
1 call to comment_links()
comment_link in modules/comment.module
Implementation of hook_link().

File

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

Code

function comment_links($comment, $return = 1) {
  global $user;
  $links = array();

  // If we are viewing just this comment, we link back to the node.
  if ($return) {
    $links[] = l(t('parent'), comment_node_url(), NULL, NULL, "comment-{$comment->cid}");
  }
  if (node_comment_mode($comment->nid) == COMMENT_NODE_READ_WRITE) {
    if (user_access('administer comments') && user_access('post comments')) {
      $links[] = l(t('delete'), "comment/delete/{$comment->cid}");
      $links[] = l(t('edit'), "comment/edit/{$comment->cid}");
      $links[] = l(t('reply'), "comment/reply/{$comment->nid}/{$comment->cid}");
    }
    else {
      if (user_access('post comments')) {
        if (comment_access('edit', $comment)) {
          $links[] = l(t('edit'), "comment/edit/{$comment->cid}");
        }
        $links[] = l(t('reply'), "comment/reply/{$comment->nid}/{$comment->cid}");
      }
      else {
        $links[] = theme('comment_post_forbidden', $comment->nid);
      }
    }
  }
  return $links;
}