summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/comment.module26
-rw-r--r--modules/comment/comment.module26
-rw-r--r--modules/node.module12
-rw-r--r--modules/node/node.module12
4 files changed, 62 insertions, 14 deletions
diff --git a/modules/comment.module b/modules/comment.module
index c45dfd924..e0ef2e2c7 100644
--- a/modules/comment.module
+++ b/modules/comment.module
@@ -14,11 +14,35 @@ function comment_perm() {
return array("access comments", "post comments", "administer comments");
}
-function comment_link($type) {
+function comment_link($type, $node = 0, $main = 0) {
if ($type == "admin" and user_access("administer comments")) {
$links[] = "<a href=\"admin.php?mod=comment\">comments</a>";
}
+ if ($node->comment) {
+
+ if ($main) {
+
+ /*
+ ** Main page: display the number of comments that have been posted.
+ */
+
+ if (user_access("access comments")) {
+ $links[] = "<a href=\"node.php?id=$node->nid#comment\">". format_plural(node_get_comments($node->nid), "comment", "comments") ."</a>";
+ }
+ }
+ else {
+ /*
+ ** Node page: add a "post comment" link if the user is allowed to
+ ** post comments.
+ */
+
+ if (user_access("post comments")) {
+ $links[] = "<a href=\"node.php?id=$node->nid&op=comment#comment\">". t("add new comment") ."</a>";
+ }
+ }
+ }
+
return $links ? $links : array();
}
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index c45dfd924..e0ef2e2c7 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -14,11 +14,35 @@ function comment_perm() {
return array("access comments", "post comments", "administer comments");
}
-function comment_link($type) {
+function comment_link($type, $node = 0, $main = 0) {
if ($type == "admin" and user_access("administer comments")) {
$links[] = "<a href=\"admin.php?mod=comment\">comments</a>";
}
+ if ($node->comment) {
+
+ if ($main) {
+
+ /*
+ ** Main page: display the number of comments that have been posted.
+ */
+
+ if (user_access("access comments")) {
+ $links[] = "<a href=\"node.php?id=$node->nid#comment\">". format_plural(node_get_comments($node->nid), "comment", "comments") ."</a>";
+ }
+ }
+ else {
+ /*
+ ** Node page: add a "post comment" link if the user is allowed to
+ ** post comments.
+ */
+
+ if (user_access("post comments")) {
+ $links[] = "<a href=\"node.php?id=$node->nid&op=comment#comment\">". t("add new comment") ."</a>";
+ }
+ }
+ }
+
return $links ? $links : array();
}
diff --git a/modules/node.module b/modules/node.module
index 53de72abf..6b0dd88fe 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -143,16 +143,16 @@ function node_link($type, $node = 0, $main = 0) {
$links = $node->links;
}
- if ($node->teaser != $node->body && $main) {
- $links[] = "<a href=\"node.php?id=". $node->nid ."\">". t("read more") ."</a>";
+ if ($main && $node->teaser != $node->body) {
+ $links[] = "<a href=\"node.php?id=$node->nid\">". t("read more") ."</a>";
}
- if ($node->comment) {
- $links[] = "<a href=\"node.php?id=". $node->nid ."\">". format_plural(node_get_comments($node->nid), "comment", "comments") ."</a>";
+ if (module_invoke($node->type, "access", "update", $node)) {
+ $links[] = "<a href=\"module.php?mod=node&op=edit&id=$node->nid\">". t("edit") ."</a>";
}
-
+
if (user_access("administer nodes")) {
- $links[] = "<a href=\"admin.php?mod=node&op=edit&id=". $node->nid ."\">". t("edit") ."</a>";
+ $links[] = "<a href=\"admin.php?mod=node&op=edit&id=$node->nid\">". t("administer") ."</a>";
}
}
diff --git a/modules/node/node.module b/modules/node/node.module
index 53de72abf..6b0dd88fe 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -143,16 +143,16 @@ function node_link($type, $node = 0, $main = 0) {
$links = $node->links;
}
- if ($node->teaser != $node->body && $main) {
- $links[] = "<a href=\"node.php?id=". $node->nid ."\">". t("read more") ."</a>";
+ if ($main && $node->teaser != $node->body) {
+ $links[] = "<a href=\"node.php?id=$node->nid\">". t("read more") ."</a>";
}
- if ($node->comment) {
- $links[] = "<a href=\"node.php?id=". $node->nid ."\">". format_plural(node_get_comments($node->nid), "comment", "comments") ."</a>";
+ if (module_invoke($node->type, "access", "update", $node)) {
+ $links[] = "<a href=\"module.php?mod=node&op=edit&id=$node->nid\">". t("edit") ."</a>";
}
-
+
if (user_access("administer nodes")) {
- $links[] = "<a href=\"admin.php?mod=node&op=edit&id=". $node->nid ."\">". t("edit") ."</a>";
+ $links[] = "<a href=\"admin.php?mod=node&op=edit&id=$node->nid\">". t("administer") ."</a>";
}
}