summaryrefslogtreecommitdiff
path: root/modules/comment.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2004-07-07 20:18:22 +0000
committerDries Buytaert <dries@buytaert.net>2004-07-07 20:18:22 +0000
commit3568ed57e1fc0b0a46ad683b529ea5823a7b78d4 (patch)
tree2a7271215466e90c67bca910bde224e9f405c8cf /modules/comment.module
parentbddcee534fb666890d82089742ec709a718588dc (diff)
downloadbrdo-3568ed57e1fc0b0a46ad683b529ea5823a7b78d4.tar.gz
brdo-3568ed57e1fc0b0a46ad683b529ea5823a7b78d4.tar.bz2
- Moving the title.module from core to contrib as discussed on the mailing list.
Diffstat (limited to 'modules/comment.module')
-rw-r--r--modules/comment.module23
1 files changed, 23 insertions, 0 deletions
diff --git a/modules/comment.module b/modules/comment.module
index b474cff7d..63abc01d1 100644
--- a/modules/comment.module
+++ b/modules/comment.module
@@ -167,6 +167,29 @@ function comment_access($op, $comment) {
}
}
+/**
+ * Implementation of hook_block().
+ *
+ * Generates a block with the most recent comments.
+ */
+function comment_block($op = 'list', $delta = 0) {
+ if ($op == 'list') {
+ $blocks[0]['info'] = t('Recent comments');
+ return $blocks;
+ }
+ else if (user_access('access comments')) {
+ $result = db_query_range('SELECT * FROM {comments} WHERE status = 0 ORDER BY timestamp DESC', 0, 10);
+ $items = array();
+ while ($comment = db_fetch_object($result)) {
+ $items[] = l($comment->subject, "node/$comment->nid", NULL, NULL, "comment-$comment->cid") .'<br />'. format_interval(time() - $comment->timestamp) .' '. t('ago');
+ }
+
+ $block['subject'] = t('Recent comments');
+ $block['content'] = theme('item_list', $items);
+ return $block;
+ }
+}
+
function comment_node_url() {
return arg(0) .'/'. arg(1) .'/'. arg(2);
}