function comment_links in Drupal 6
Same name and namespace in other branches
- 4 modules/comment.module \comment_links()
- 5 modules/comment/comment.module \comment_links()
- 7 modules/comment/comment.module \comment_links()
Build command links for a comment (e.g.\ edit, reply, delete) with respect to the current user's access permissions.
Parameters
$comment: The comment to which the links will be related.
$return: Not used.
Return value
An associative array containing the links.
1 call to comment_links()
- comment_link in modules/
comment/ comment.module - Implementation of hook_link().
File
- modules/
comment/ comment.module, line 808 - 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['comment_parent'] = array(
'title' => t('parent'),
'href' => comment_node_url(),
'fragment' => "comment-{$comment->cid}",
);
}
if (node_comment_mode($comment->nid) == COMMENT_NODE_READ_WRITE) {
if (user_access('administer comments') && user_access('post comments')) {
$links['comment_delete'] = array(
'title' => t('delete'),
'href' => "comment/delete/{$comment->cid}",
);
$links['comment_edit'] = array(
'title' => t('edit'),
'href' => "comment/edit/{$comment->cid}",
);
$links['comment_reply'] = array(
'title' => t('reply'),
'href' => "comment/reply/{$comment->nid}/{$comment->cid}",
);
}
else {
if (user_access('post comments')) {
if (comment_access('edit', $comment)) {
$links['comment_edit'] = array(
'title' => t('edit'),
'href' => "comment/edit/{$comment->cid}",
);
}
$links['comment_reply'] = array(
'title' => t('reply'),
'href' => "comment/reply/{$comment->nid}/{$comment->cid}",
);
}
else {
$node = node_load($comment->nid);
$links['comment_forbidden']['title'] = theme('comment_post_forbidden', $node);
}
}
}
return $links;
}