summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-08-08 22:52:59 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-08-08 22:52:59 +0000
commit0355caac417d92973f4913efbb19342ae352bf2e (patch)
treee3e384c5213206b93d50e08be2c2c0e5bf530e41 /modules
parent1da6ef52c44fd38785391d3a94af8e969344bc12 (diff)
downloadbrdo-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')
-rw-r--r--modules/comment/comment.module134
-rw-r--r--modules/node/node.module21
-rw-r--r--modules/system/system.api.php65
3 files changed, 60 insertions, 160 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.
*
diff --git a/modules/node/node.module b/modules/node/node.module
index 725891d9f..b66b423f0 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -1594,27 +1594,6 @@ function theme_node_search_admin($form) {
return $output;
}
-/**
- * Implement hook_link().
- */
-function node_link($type, $node, $build_mode) {
- $links = array();
-
- if ($type == 'node') {
- if ($build_mode == 'teaser') {
- $links['node_read_more'] = array(
- 'title' => t('Read more'),
- 'href' => "node/$node->nid",
- // The title attribute gets escaped when the links are processed, so
- // there is no need to escape here.
- 'attributes' => array('title' => t('Read the rest of !title.', array('!title' => $node->title)))
- );
- }
- }
-
- return $links;
-}
-
function _node_revision_access($node, $op = 'view') {
static $access = array();
if (!isset($access[$node->vid])) {
diff --git a/modules/system/system.api.php b/modules/system/system.api.php
index 9c5435275..37d37ea15 100644
--- a/modules/system/system.api.php
+++ b/modules/system/system.api.php
@@ -512,71 +512,6 @@ function hook_image_toolkits() {
}
/**
- * Define internal Drupal links.
- *
- * This hook enables modules to add links to many parts of Drupal. Links
- * may be added in the navigation block, for example.
- *
- * The returned array should be a keyed array of link entries. Each link can
- * be in one of two formats.
- *
- * The first format will use the l() function to render the link:
- * - attributes: Optional. See l() for usage.
- * - fragment: Optional. See l() for usage.
- * - href: Required. The URL of the link.
- * - html: Optional. See l() for usage.
- * - query: Optional. See l() for usage.
- * - title: Required. The name of the link.
- *
- * The second format can be used for non-links. Leaving out the href index will
- * select this format:
- * - title: Required. The text or HTML code to display.
- * - attributes: Optional. An associative array of HTML attributes to apply to the span tag.
- * - html: Optional. If not set to true, check_plain() will be run on the title before it is displayed.
- *
- * @param $type
- * An identifier declaring what kind of link is being requested.
- * Possible values:
- * - comment: Links to be placed below a comment being viewed.
- * @param $object
- * A comment object.
- * @param $build_mode
- * Build mode for the node, e.g. 'full', 'teaser'...
- * @return
- * An array of the requested links.
- *
- */
-function hook_link($type, $object, $build_mode) {
- $links = array();
-
- if ($type == 'comment') {
- $links = comment_links($object, FALSE);
- return $links;
- }
-
- return $links;
-}
-
-/**
- * Perform alterations before links on a comment are rendered. One popular use of
- * this hook is to modify/remove links from other modules. If you want to add a link
- * to the links section of a node, use hook_link instead.
- *
- * @param $links
- * Nested array of links for the node keyed by providing module.
- * @param $node
- * A node object that contains the links.
- */
-function hook_link_alter(array &$links, $node) {
- foreach ($links as $module => $link) {
- if (strpos($module, 'taxonomy_term') !== FALSE) {
- // Link back to the forum and not the taxonomy term page
- $links[$module]['href'] = str_replace('taxonomy/term', 'forum', $link['href']);
- }
- }
-}
-
-/**
* Perform alterations profile items before they are rendered. You may omit/add/re-sort/re-categorize, etc.
*
* @param $account