From b3adcf05a31fef1d86b8ef87c73c9f3ade3585b2 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 31 Oct 2004 07:34:47 +0000 Subject: - 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. --- modules/user.module | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'modules/user.module') diff --git a/modules/user.module b/modules/user.module index 716316f06..1e30d6f41 100644 --- a/modules/user.module +++ b/modules/user.module @@ -471,7 +471,7 @@ function user_user($type, &$edit, &$user, $category = NULL) { /** * Implementation of hook_block(). */ -function user_block($op = 'list', $delta = 0) { +function user_block($op = 'list', $delta = 0, $edit = array()) { global $user; if ($op == 'list') { @@ -482,7 +482,18 @@ function user_block($op = 'list', $delta = 0) { return $blocks; } - else { + else if ($op == 'configure' && $delta == 3) { + $period = drupal_map_assoc(array(30, 60, 120, 180, 300, 600, 900, 1800, 2700, 3600, 5400, 7200, 10800, 21600, 43200, 86400), 'format_interval'); + $output = form_select(t('User activity'), 'user_block_seconds_online', variable_get('user_block_seconds_online', 900), $period, t('A user is considered online for this long after they have last viewed a page.')); + $output .= form_select(t('User list length'), 'user_block_max_list_count', variable_get('user_block_max_list_count', 10), drupal_map_assoc(array(0, 5, 10, 15, 20, 25, 30, 40, 50, 75, 100)), t('Maximum number of currently online users to display.')); + + return $output; + } + else if ($op == 'save' && $delta == 3) { + variable_set('user_block_seconds_online', $edit['user_block_seconds_online']); + variable_set('user_block_max_list_count', $edit['user_block_max_list_count']); + } + else if ($op == 'view') { $block = array(); switch ($delta) { @@ -1287,12 +1298,6 @@ function user_configure_settings() { $output .= form_group(t('Pictures'), $group); - // "Who's online" block settings. - $period = drupal_map_assoc(array(30, 60, 120, 180, 300, 600, 900, 1800, 2700, 3600, 5400, 7200, 10800, 21600, 43200, 86400), 'format_interval'); - $group = form_select(t('User activity'), 'user_block_seconds_online', variable_get('user_block_seconds_online', 900), $period, t('Affects "Who\'s online" block. A user is considered online for this long after they have last viewed a page.')); - $group .= form_select(t('User list length'), 'user_block_max_list_count', variable_get('user_block_max_list_count', 10), drupal_map_assoc(array(0, 5, 10, 15, 20, 25, 30, 40, 50, 75, 100)), t('Affects "Who\'s online" block. Maximum number of currently online users to display.')); - $output .= form_group(t('"Who\'s online" block settings'), $group); - return $output; } -- cgit v1.2.3