diff options
author | Dries Buytaert <dries@buytaert.net> | 2004-10-31 07:34:47 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2004-10-31 07:34:47 +0000 |
commit | b3adcf05a31fef1d86b8ef87c73c9f3ade3585b2 (patch) | |
tree | 906ba3dd9ce31d3268812a8dc6dd190f2556d44f /modules/forum/forum.module | |
parent | 8daed9cbf353de947bc3916f103206edd121de33 (diff) | |
download | brdo-b3adcf05a31fef1d86b8ef87c73c9f3ade3585b2.tar.gz brdo-b3adcf05a31fef1d86b8ef87c73c9f3ade3585b2.tar.bz2 |
- Patch #11875 by Neil Drumm: block module configuration improvements.
The primary goal of this patch is to take the 'custom' and 'path' columns of the block overview page and make them into something understandable. As of Drupal 4.5 'custom' lacked an explanation which wasn't buried in help text and path required dealing with regular expressions.
Every block now has a configuration page to control these options. This gives more space to make form controls which do not require a lengthy explanation. This page also gives modules a chance to put their block configuration options in a place that makes sense using new operations in the block hook.
The only required changes to modules implementing hook_block() is to be careful about what is returned. Do not return anything if $op is not 'list' or 'view'. Once this change is made, modules will still be compatible with Drupal 4.5. Required changes to core modules are included in this path.
An additional optional change to modules is to implement the additional $op options added. 'configure' should return a string containing the configuration form for the block with the appropriate $delta. 'configure save' will come with an additional $edit argument, which will contain the submitted form data for saving. These changes to core modules are also included in this patch.
Diffstat (limited to 'modules/forum/forum.module')
-rw-r--r-- | modules/forum/forum.module | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/modules/forum/forum.module b/modules/forum/forum.module index 897e90f1e..74baed433 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -78,9 +78,6 @@ function forum_settings() { $group .= form_select(t('Topics per page'), 'forum_per_page', variable_get('forum_per_page', 25), drupal_map_assoc(array(10, 25, 50, 75, 100)), t('The default number of topics displayed per page; links to browse older messages are automatically being displayed.')); $group .= form_radios(t('Default order'), 'forum_order', variable_get('forum_order', '1'), array(1 => t('Date - newest first'), 2 => t('Date - oldest first'), 3 => t('Posts - most active first'), 4=> t('Posts - least active first')), t('The default display order for topics.')); $output .= form_group(t('Forum viewing options'), $group); - - $group = form_select(t('Number of topics in block'), 'forum_block_num', variable_get('forum_block_num', '5'), drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)), t('The number of topics to show in the "Forum topics" block. To enable the block, go to the <a href="%block-administration">block administration</a> page.', array('%block-administration' => url('admin/block')))); - $output .= form_group(t('"Forum topic" block settings'), $group); } } @@ -114,27 +111,36 @@ function forum_load($node) { * Generates a block containing the currently active forum topics and the * most recently added forum topics. */ -function forum_block($op = 'list', $delta = 0) { +function forum_block($op = 'list', $delta = 0, $edit = array()) { + switch ($op) { + case 'list': + $blocks[0]['info'] = t('Forum topics'); + return $blocks; + + case 'configure': + $output = form_select(t('Number of topics in block'), 'forum_block_num', variable_get('forum_block_num', '5'), drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20))); + return $output; + + case 'save': + variable_set('forum_block_num', $edit['forum_block_num']); + break; - if ($op == 'list') { - $blocks[0]['info'] = t('Forum topics'); - } - else { - if (user_access('access content')) { - $content = node_title_list(db_query_range("SELECT n.nid, n.title, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid ". node_access_join_sql() ." WHERE n.status = 1 AND n.type='forum' AND ". node_access_where_sql() ." ORDER BY l.last_comment_timestamp DESC", 0, variable_get('forum_block_num', '5')), t('Active forum topics:')); + case 'view': + if (user_access('access content')) { + $content = node_title_list(db_query_range("SELECT n.nid, n.title, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid ". node_access_join_sql() ." WHERE n.status = 1 AND n.type='forum' AND ". node_access_where_sql() ." ORDER BY l.last_comment_timestamp DESC", 0, variable_get('forum_block_num', '5')), t('Active forum topics:')); - $content .= node_title_list(db_query_range("SELECT n.nid, n.title FROM {node} n ". node_access_join_sql() ." WHERE n.type = 'forum' AND n.status = 1 AND ". node_access_where_sql() ." ORDER BY n.nid DESC", 0, variable_get('forum_block_num', '5')), t('New forum topics:')); + $content .= node_title_list(db_query_range("SELECT n.nid, n.title FROM {node} n ". node_access_join_sql() ." WHERE n.type = 'forum' AND n.status = 1 AND ". node_access_where_sql() ." ORDER BY n.nid DESC", 0, variable_get('forum_block_num', '5')), t('New forum topics:')); - if ($content) { - $content .= '<div class="more-link">'. l(t('more'), 'forum', array('title' => t('Read the latest forum topics.'))) .'</div>'; - } + if ($content) { + $content .= '<div class="more-link">'. l(t('more'), 'forum', array('title' => t('Read the latest forum topics.'))) .'</div>'; + } - $blocks['subject'] = t('Forum topics'); - $blocks['content'] = $content; - } - } + $block['subject'] = t('Forum topics'); + $block['content'] = $content; - return $blocks; + return $block; + } + } } /** |