Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.907
diff -u -r1.907 user.module
--- modules/user/user.module	7 May 2008 19:34:24 -0000	1.907
+++ modules/user/user.module	10 May 2008 21:43:57 -0000
@@ -690,123 +690,64 @@
 /**
  * Implementation of hook_block().
  */
-function user_block($op = 'list', $delta = '', $edit = array()) {
-  global $user;
-
-  if ($op == 'list') {
-    $blocks['login']['info'] = t('User login');
-    // Not worth caching.
-    $blocks['login']['cache'] = BLOCK_NO_CACHE;
-
-    $blocks['navigation']['info'] = t('Navigation');
+function user_blocks() {
+  $blocks['login'] = array(
+    'info' => t('User login'),
+    'description' => t('Provides the user login box'), 
+    'cache' => BLOCK_NO_CACHE // Not worth caching.
+  ); 
+  
+  $blocks['navigation'] = array(
+    'info' => t('Navigation'),
+    'description' => t('Provides the default navigation menu') ,
     // Menu blocks can't be cached because each menu item can have
-    // a custom access callback. menu.inc manages its own caching.
-    $blocks['navigation']['cache'] = BLOCK_NO_CACHE;
-
-    $blocks['new']['info'] = t('Who\'s new');
-
-    // Too dynamic to cache.
-    $blocks['online']['info'] = t('Who\'s online');
-    $blocks['online']['cache'] = BLOCK_NO_CACHE;
-    return $blocks;
-  }
-  else if ($op == 'configure' && $delta == 'new') {
-    $form['user_block_whois_new_count'] = array(
-      '#type' => 'select',
-      '#title' => t('Number of users to display'),
-      '#default_value' => variable_get('user_block_whois_new_count', 5),
-      '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)),
-    );
-    return $form;
-  }
-  else if ($op == 'configure' && $delta == 'online') {
-    $period = drupal_map_assoc(array(30, 60, 120, 180, 300, 600, 900, 1800, 2700, 3600, 5400, 7200, 10800, 21600, 43200, 86400), 'format_interval');
-    $form['user_block_seconds_online'] = array('#type' => 'select', '#title' => t('User activity'), '#default_value' => variable_get('user_block_seconds_online', 900), '#options' => $period, '#description' => t('A user is considered online for this long after they have last viewed a page.'));
-    $form['user_block_max_list_count'] = array('#type' => 'select', '#title' => t('User list length'), '#default_value' => variable_get('user_block_max_list_count', 10), '#options' => drupal_map_assoc(array(0, 5, 10, 15, 20, 25, 30, 40, 50, 75, 100)), '#description' => t('Maximum number of currently online users to display.'));
+    // a custom access callback. menu.inc manages its own caching.  
+    'cache' => BLOCK_NO_CACHE  
+  );
+  
+  $blocks['new'] = array(
+    'info' => t('Who\'s new'), 
+    'description' => t('Shows users recently registered'), 
+  );
+  
+  $blocks['online'] = array(
+    'info' => t('Who\'s online'), 
+    'description' => t('Shows online users'),
+    'cache' => BLOCK_NO_CACHE // Too dynamic to cache.
+  ); 
+  
+  return $blocks;
+}
 
-    return $form;
-  }
-  else if ($op == 'save' && $delta == 'new') {
-    variable_set('user_block_whois_new_count', $edit['user_block_whois_new_count']);
-  }
-  else if ($op == 'save' && $delta == 'online') {
-    variable_set('user_block_seconds_online', $edit['user_block_seconds_online']);
-    variable_set('user_block_max_list_count', $edit['user_block_max_list_count']);
+/**
+ * Block callback; generates the navigation menu
+ */
+function user_block_navigation() {
+  global $user;
+  if ($menu = menu_tree()) {
+    $block['subject'] = $user->uid ? check_plain($user->name) : t('Navigation');
+    $block['content'] = $menu;
+    return $block;
   }
-  else if ($op == 'view') {
-    $block = array();
-
-    switch ($delta) {
-      case 'login':
-        // For usability's sake, avoid showing two login forms on one page.
-        if (!$user->uid && !(arg(0) == 'user' && !is_numeric(arg(1)))) {
-
-          $block['subject'] = t('User login');
-          $block['content'] = drupal_get_form('user_login_block');
-        }
-        return $block;
-
-      case 'navigation':
-        if ($menu = menu_tree()) {
-          $block['subject'] = $user->uid ? check_plain($user->name) : t('Navigation');
-          $block['content'] = $menu;
-        }
-        return $block;
-
-      case 'new':
-        if (user_access('access content')) {
-          // Retrieve a list of new users who have subsequently accessed the site successfully.
-          $result = db_query_range('SELECT uid, name FROM {users} WHERE status != 0 AND access != 0 ORDER BY created DESC', 0, variable_get('user_block_whois_new_count', 5));
-          while ($account = db_fetch_object($result)) {
-            $items[] = $account;
-          }
-          $output = theme('user_list', $items);
-
-          $block['subject'] = t('Who\'s new');
-          $block['content'] = $output;
-        }
-        return $block;
-
-      case 'online':
-        if (user_access('access content')) {
-          // Count users active within the defined period.
-          $interval = time() - variable_get('user_block_seconds_online', 900);
-
-          // Perform database queries to gather online user lists.  We use s.timestamp
-          // rather than u.access because it is much faster.
-          $anonymous_count = sess_count($interval);
-          $authenticated_users = db_query('SELECT DISTINCT u.uid, u.name, s.timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 ORDER BY s.timestamp DESC', $interval);
-          $authenticated_count = 0;
-          $max_users = variable_get('user_block_max_list_count', 10);
-          $items = array();
-          while ($account = db_fetch_object($authenticated_users)) {
-            if ($max_users > 0) {
-              $items[] = $account;
-              $max_users--;
-            }
-            $authenticated_count++;
-          }
-
-          // Format the output with proper grammar.
-          if ($anonymous_count == 1 && $authenticated_count == 1) {
-            $output = t('There is currently %members and %visitors online.', array('%members' => format_plural($authenticated_count, '1 user', '@count users'), '%visitors' => format_plural($anonymous_count, '1 guest', '@count guests')));
-          }
-          else {
-            $output = t('There are currently %members and %visitors online.', array('%members' => format_plural($authenticated_count, '1 user', '@count users'), '%visitors' => format_plural($anonymous_count, '1 guest', '@count guests')));
-          }
-
-          // Display a list of currently online users.
-          $max_users = variable_get('user_block_max_list_count', 10);
-          if ($authenticated_count && $max_users) {
-            $output .= theme('user_list', $items, t('Online users'));
-          }
+}
 
-          $block['subject'] = t('Who\'s online');
-          $block['content'] = $output;
-        }
-        return $block;
+/**
+ * Block callback; generates a list of recently registered users
+ */
+function user_block_new() {
+  global $user;
+  if (user_access('access content')) {
+    // Retrieve a list of new users who have subsequently accessed the site successfully.
+    $result = db_query_range('SELECT uid, name FROM {users} WHERE status != 0 AND access != 0 ORDER BY created DESC', 0, variable_get('user_block_whois_new_count', 5));
+    while ($account = db_fetch_object($result)) {
+      $items[] = $account;
     }
+    $output = theme('user_list', $items);
+
+    $block['subject'] = t('Who\'s new');
+    $block['content'] = $output;
   }
+  return $block;
 }
 
 /**
Index: modules/block/block.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.admin.inc,v
retrieving revision 1.16
diff -u -r1.16 block.admin.inc
--- modules/block/block.admin.inc	16 Apr 2008 11:35:51 -0000	1.16
+++ modules/block/block.admin.inc	10 May 2008 21:43:41 -0000
@@ -157,7 +157,10 @@
 
 
   // Module-specific block configurations.
-  if ($settings = module_invoke($module, 'block', 'configure', $delta)) {
+  require_once drupal_get_path('module', $module) . "/{$module}.blocks.inc";  
+  $function = "{$module}_block_{$delta}_settings"; 
+  if (drupal_function_exists($function)) {
+    $settings = $function();
     foreach ($settings as $k => $v) {
       $form['block_settings'][$k] = $v;
     }
@@ -268,7 +271,13 @@
     foreach (array_filter($form_state['values']['roles']) as $rid) {
       db_query("INSERT INTO {blocks_roles} (rid, module, delta) VALUES (%d, '%s', '%s')", $rid, $form_state['values']['module'], $form_state['values']['delta']);
     }
-    module_invoke($form_state['values']['module'], 'block', 'save', $form_state['values']['delta'], $form_state['values']);
+    
+    //module_invoke($form_state['values']['module'], 'block', 'save', $form_state['values']['delta'], $form_state['values']);
+    require_once drupal_get_path('module', $form_state['values']['module']) . "/{$form_state['values']['module']}.blocks.inc";  
+    $function = "{$form_state['values']['module']}_block_{$form_state['values']['delta']}_settings_submit";
+    if (drupal_function_exists($function)) {     
+      $function($form_state['values']);
+    } 
     drupal_set_message(t('The block configuration has been saved.'));
     cache_clear_all();
     $form_state['redirect'] = 'admin/build/block';
Index: modules/block/block.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.module,v
retrieving revision 1.305
diff -u -r1.305 block.module
--- modules/block/block.module	6 May 2008 12:18:46 -0000	1.305
+++ modules/block/block.module	10 May 2008 21:43:45 -0000
@@ -235,7 +235,7 @@
   $regions = system_region_list($theme_key);
 
   foreach (module_list() as $module) {
-    $module_blocks = module_invoke($module, 'block', 'list');
+    $module_blocks = module_invoke($module, 'blocks');
     if ($module_blocks) {
       foreach ($module_blocks as $delta => $block) {
         if (empty($old_blocks[$module][$delta])) {
@@ -483,7 +483,10 @@
           $array = $cache->data;
         }
         else {
-          $array = module_invoke($block->module, 'block', 'view', $block->delta);
+          $function = "{$block->module}_block_{$block->delta}"; 
+          if (drupal_function_exists($function)) {
+             $array = $function();
+          }
           if (isset($cid)) {
             cache_set($cid, $array, 'cache_block', CACHE_TEMPORARY);
           }
Index: modules/user/user.blocks.inc
===================================================================
RCS file: modules/user/user.blocks.inc
diff -N modules/user/user.blocks.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/user/user.blocks.inc	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,31 @@
+<?php
+// $Id;
+
+/**
+ * @file
+ * User blocks settings callbacks
+ */
+
+/**
+ * Block settings callback; Generates settings form for the <i>Who's new</i> block
+ *
+ * @return 
+ *  the form array
+ */
+function user_block_new_settings() {
+  $form['user_block_whois_new_count'] = array(
+    '#type' => 'select',
+    '#title' => t('Number of users to display'),
+    '#default_value' => variable_get('user_block_whois_new_count', 5),
+    '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)),
+  );
+  return $form; 
+}
+
+/**
+ * Block settings submit callback; Process the settings form submission for the <i>Who's new</i> block
+ */
+function user_block_new_settings_submit($edit) {
+  variable_set('user_block_whois_new_count', $edit['user_block_whois_new_count']);
+}
+
