Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.1017
diff -u -r1.1017 user.module
--- modules/user/user.module	4 Aug 2009 06:38:57 -0000	1.1017
+++ modules/user/user.module	4 Aug 2009 19:55:41 -0000
@@ -35,6 +35,10 @@
  */
 function user_theme() {
   return array(
+    'user_block_online' => array(
+      'arguments' => array('users' => array(), 'authenticated_count' => NULL, 'anonymous_count' => NULL),
+      'template' => 'user-block-online',
+    ),
     'user_picture' => array(
       'arguments' => array('account' => NULL),
       'template' => 'user-picture',
@@ -1117,33 +1121,55 @@
         // anonymous users when needed.
         if (variable_get('cache', CACHE_DISABLED) == CACHE_DISABLED) {
           $anonymous_count = drupal_session_count($interval);
-          // 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')));
-          }
-        }
-        else {
-          $output = format_plural($authenticated_count, 'There is currently 1 user online.', 'There are currently @count users online.');
         }
 
-        // Display a list of currently online users.
+        // Get a list of currently online users.
         $max_users = variable_get('user_block_max_list_count', 10);
         if ($authenticated_count && $max_users) {
-          $items = db_query_range('SELECT u.uid, u.name, MAX(s.timestamp) AS max_timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= :interval AND s.uid > 0 GROUP BY u.uid, u.name ORDER BY max_timestamp DESC', array(':interval' => $interval), 0, $max_users)->fetchAll();
-          $output .= theme('user_list', $items, t('Online users'));
+          $users = db_query_range('SELECT u.uid, u.name, MAX(s.timestamp) AS max_timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= :interval AND s.uid > 0 GROUP BY u.uid, u.name ORDER BY max_timestamp DESC', array(':interval' => $interval), 0, $max_users)->fetchAll();
+          $block['content'] = theme('user_block_online', $users, $authenticated_count, $anonymous_count);
         }
 
         $block['subject'] = t('Who\'s online');
-        $block['content'] = $output;
       }
       return $block;
   }
 }
 
 /**
+ * Process variables for user-block-online.tpl.php.
+ *
+ * The $variables array contains the following arguments:
+ * - $users: An array of users that are online.
+ * - $authenticated_count: The number of authenticated users currently
+ *   logged into the site.
+ * - $anonymous_count: The number of anonymous users currently visiting the
+ *   site.
+ *
+ * @see user-block-online.tpl.php.
+ */
+function template_preprocess_user_block_online(&$variables) {
+  // Format the $text variable depending on the number of authenticated
+  // and/or anonymous users currently visiting the site.
+  if ($variables['anonymous_count']) {
+    if ($variables['anonymous_count'] == 1 && $variables['authenticated_count'] == 1) {
+      $variables['text'] = t('There is currently %members and %visitors online.', array('%members' => format_plural($variables['authenticated_count'], '1 user', '@count users'), '%visitors' => format_plural($variables['anonymous_count'], '1 guest', '@count guests')));
+    }
+    else {
+      $variables['text'] = t('There are currently %members and %visitors online.', array('%members' => format_plural($variables['authenticated_count'], '1 user', '@count users'), '%visitors' => format_plural($variables['anonymous_count'], '1 guest', '@count guests')));
+    }
+  }
+  else {
+    $variables['text'] = format_plural($variables['authenticated_count'], 'There is currently 1 user online.', 'There are currently @count users online.');
+  }
+
+  // Format the registered users currently logged into the site into a list.
+  if (isset($variables['users']) && is_array($variables['users'])) {
+    $variables['online_users'] = theme('user_list', $variables['users'], t('Online users'));
+  }
+}
+
+/**
  * Process variables for user-picture.tpl.php.
  *
  * The $variables array contains the following arguments:
Index: modules/user/user-block-online.tpl.php
===================================================================
RCS file: modules/user/user-block-online.tpl.php
diff -N modules/user/user-block-online.tpl.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/user/user-block-online.tpl.php	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,20 @@
+<?php
+// $Id
+
+/**
+ * @file
+ * Default theme implementation to present a list of users currently online.
+ *
+ * Available variables:
+ * - $text: A string of text giving counts of authenticated and anonymous
+ *   users currently looking at the site.
+ * - $online_users: A list of registered users currently visiting the site.
+ *
+ * @see template_preprocess_user_picture()
+ */
+?>
+<?php if ($text): ?>
+<p><?php print $text; ?></p>
+<?php endif; ?>
+
+<?php print $online_users; ?>
\ No newline at end of file
