diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-08-08 22:52:59 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-08-08 22:52:59 +0000 |
commit | 0355caac417d92973f4913efbb19342ae352bf2e (patch) | |
tree | e3e384c5213206b93d50e08be2c2c0e5bf530e41 /modules/comment/comment.module | |
parent | 1da6ef52c44fd38785391d3a94af8e969344bc12 (diff) | |
download | brdo-0355caac417d92973f4913efbb19342ae352bf2e.tar.gz brdo-0355caac417d92973f4913efbb19342ae352bf2e.tar.bz2 |
#537654 by catch: Tidy up comment links, and remove hook_link() in favour of hook_page_alter().
Diffstat (limited to 'modules/comment/comment.module')
-rw-r--r-- | modules/comment/comment.module | 134 |
1 files changed, 60 insertions, 74 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module index de26cb31a..6b54c4961 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -839,6 +839,66 @@ function comment_build_content($comment, $build_mode = 'full') { } /** + * Helper function, build links for an individual comment. + * + * Adds reply, edit, delete etc. depending on the current user permissions. + * + * @param $comment + * The comment object. + * @return + * A structured array of links. + */ +function comment_links($comment) { + $links = array(); + $node = node_load($comment->nid); + if ($node->comment == COMMENT_NODE_OPEN) { + if (user_access('administer comments') && user_access('post comments')) { + $links['comment_delete'] = array( + 'title' => t('delete'), + 'href' => "comment/delete/$comment->cid", + 'html' => TRUE, + ); + $links['comment_edit'] = array( + 'title' => t('edit'), + 'href' => "comment/edit/$comment->cid", + '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/approve/$comment->cid", + 'html' => TRUE, + ); + } + } + elseif (user_access('post comments')) { + if (comment_access('edit', $comment)) { + $links['comment_edit'] = array( + 'title' => t('edit'), + 'href' => "comment/edit/$comment->cid", + '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', $node); + $links['comment_forbidden']['html'] = TRUE; + } + } + return $links; +} + +/** * Construct a drupal_render() style array from an array of loaded comments. * * @param $comments @@ -1324,80 +1384,6 @@ function comment_delete_multiple($cids) { } /** - * Implement hook_link(). - */ -function comment_link($type, $object, $build_mode) { - if ($type == 'comment') { - $links = comment_links($object, FALSE); - return $links; - } -} - -/** - * Build command links for a comment (e.g.\ edit, reply, delete) with respect to the current user's access permissions. - * - * @param $comment - * The comment to which the links will be related. - * @return - * An associative array containing the links. - */ -function comment_links(&$comment) { - global $user; - $links = array(); - - $node = node_load($comment->nid); - if ($node->comment == COMMENT_NODE_OPEN) { - if (user_access('administer comments') && user_access('post comments')) { - $links['comment_delete'] = array( - 'title' => t('delete'), - 'href' => "comment/delete/$comment->cid", - 'html' => TRUE, - ); - $links['comment_edit'] = array( - 'title' => t('edit'), - 'href' => "comment/edit/$comment->cid", - '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/approve/$comment->cid", - 'html' => TRUE, - ); - } - } - elseif (user_access('post comments')) { - if (comment_access('edit', $comment)) { - $links['comment_edit'] = array( - 'title' => t('edit'), - 'href' => "comment/edit/$comment->cid", - 'html' => TRUE, - ); - } - $links['comment_reply'] = array( - 'title' => t('reply'), - 'href' => "comment/reply/$comment->nid/$comment->cid", - 'html' => TRUE, - ); - } - else { - $node = node_load($comment->nid); - $links['comment_forbidden']['title'] = theme('comment_post_forbidden', $node); - $links['comment_forbidden']['html'] = TRUE; - } - } - - - - return $links; -} - -/** * Comment operations. Offer different update operations depending on * which comment administration page is being viewed. * |