From 3568ed57e1fc0b0a46ad683b529ea5823a7b78d4 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 7 Jul 2004 20:18:22 +0000 Subject: - Moving the title.module from core to contrib as discussed on the mailing list. --- modules/comment.module | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'modules/comment.module') 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") .'
'. 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); } -- cgit v1.2.3