diff options
Diffstat (limited to 'modules/comment')
-rw-r--r-- | modules/comment/comment.module | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module index b474cff7d..63abc01d1 100644 --- a/modules/comment/comment.module +++ b/modules/comment/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); } |