--- /home/guus/drupal-5.1/modules/comment/comment.module Mon Jan 29 22:51:53 2007 +++ comment.module Sat Mar 3 03:15:59 2007 @@ -240,12 +240,18 @@ function comment_block($op = 'list', $de * 2. Loading the information from the comments table based on the nids found * in step 1. * - * @param $number (optional) The maximum number of comments to find. + * @param $number (deprecated) The maximum number of comments to find. This + * number will be overwritten by the administrator's choice in the settings of the + * module. * @return $comments An array of comment objects each containing a nid, * subject, cid, and timstamp, or an empty array if there are no recent * comments visible to the current user. */ function comment_get_recent($number = 10) { + // number is now determined by the administrator, not by the calling + // method. + $number = variable_get('comment_block_display_amount', 10); + // Select the $number nodes (visible to the current user) with the most // recent comments. This is efficient due to the index on // last_comment_timestamp. @@ -498,6 +504,14 @@ function comment_admin_settings() { '#description' => t('The default sorting for new users and anonymous users while viewing comments. These users may change their view using the comment control panel. For registered users, this change is remembered as a persistent user preference.'), ); + $form['viewing_options']['comment_block_display_amount'] = array( + '#type' => 'select', + '#title' => t('Amount of comments in block'), + '#default_value' => variable_get('comment_block_display_amount', 10), + '#options' => _comment_display_amount(), + '#description' => t('Amount of comments to display in block with recent comments.'), + ); + $form['viewing_options']['comment_default_per_page'] = array( '#type' => 'select', '#title' => t('Default comments per page'), @@ -1878,6 +1892,14 @@ function _comment_get_orders() { COMMENT_ORDER_NEWEST_FIRST => t('Date - newest first'), COMMENT_ORDER_OLDEST_FIRST => t('Date - oldest first') ); +} + +/** + * Return an array of "amount of comments" for recent comment + * block from which the user can choose. + */ +function _comment_display_amount() { + return drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)); } /**