summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-02-21 19:38:07 +0000
committerDries Buytaert <dries@buytaert.net>2008-02-21 19:38:07 +0000
commit657935c263486b801b4eb13e6e96a24fff4b3500 (patch)
tree357f4dd77549dd5930d1a3737a5437147d07c432
parent2526e41fdb090c472a48f44d9a84115567a8f639 (diff)
downloadbrdo-657935c263486b801b4eb13e6e96a24fff4b3500.tar.gz
brdo-657935c263486b801b4eb13e6e96a24fff4b3500.tar.bz2
- Patch #81931 by webchick et al: made the recent comments block configurable. Somme minor changes by me.
-rw-r--r--modules/comment/comment.module38
1 files changed, 28 insertions, 10 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 2eb985559..a6166a89d 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -284,15 +284,32 @@ function comment_perm() {
*
* 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 ($op == 'view' && user_access('access comments')) {
- $block['subject'] = t('Recent comments');
- $block['content'] = theme('comment_block');
- return $block;
+function comment_block($op = 'list', $delta = 0, $edit = array()) {
+ switch ($op) {
+ case 'list':
+ $blocks[0]['info'] = t('Recent comments');
+ return $blocks;
+
+ case 'configure':
+ $form['comment_block_count'] = array(
+ '#type' => 'select',
+ '#title' => t('Number of recent comments'),
+ '#default_value' => variable_get('comment_block_count', 10),
+ '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)),
+ '#description' => t('Number of comments to display in block with recent comments.'),
+ );
+ return $form;
+
+ case 'save':
+ variable_set('comment_block_count', (int)$edit['comment_block_count']);
+ break;
+
+ case 'view':
+ if (user_access('access comments')) {
+ $block['subject'] = t('Recent comments');
+ $block['content'] = theme('comment_block');
+ return $block;
+ }
}
}
@@ -396,7 +413,8 @@ function comment_new_page_count($num_comments, $new_replies, $node) {
*/
function theme_comment_block() {
$items = array();
- foreach (comment_get_recent() as $comment) {
+ $number = variable_get('comment_block_count', 10);
+ foreach (comment_get_recent($number) as $comment) {
$items[] = l($comment->subject, 'node/'. $comment->nid, array('fragment' => 'comment-'. $comment->cid)) .'<br />'. t('@time ago', array('@time' => format_interval(time() - $comment->timestamp)));
}
if ($items) {