Index: shoutbox.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/shoutbox/shoutbox.module,v
retrieving revision 1.25.2.5
diff -u -p -r1.25.2.5 shoutbox.module
--- shoutbox.module 12 May 2008 13:59:23 -0000 1.25.2.5
+++ shoutbox.module 15 May 2008 15:53:24 -0000
@@ -68,6 +68,12 @@ function shoutbox_menu() {
     'access arguments' => array('administer site configuration'),
     'type' => MENU_NORMAL_ITEM,
   );
+  $items['shouts'] = array(
+    'title' => 'All Shouts',
+    'page callback' => 'shoutbox_page_view',
+    'access arguments' => array('access content'),
+    'type' => MENU_CALLBACK,
+  );

   return $items;
 }
@@ -115,7 +121,7 @@ function shoutbox_block($op = 'list', $d
       switch ($delta) {
         case 0:
           if (user_access("access content")) {
-            if (!stristr($_GET['q'], 'shoutbox')) {
+            if (!stristr($_GET['q'], 'shoutbox') && !stristr($_GET['q'], 'shouts')) {
               // Bind submission to submit.
               drupal_add_js('misc/jquery.form.js');
               drupal_add_js(drupal_get_path('module', 'shoutbox') .'/shoutbox-form.js', 'module');
@@ -265,8 +271,11 @@ function theme_shoutbox_links() {
  * @param links
  *   Links of possible actions that can be performed on this shout
  *   by the current user.
+ * @param $alter_row_color
+ *   Whether or not to alternate the row color for posts.  Should be set to
+ *   FALSE for the page view.
  */
-function theme_shoutbox_post($shout, $links = array()) {
+function theme_shoutbox_post($shout, $links = array(), $alter_row_color=TRUE) {
   // Get the registered username of the person who posted the shout.
   if ($shout->uid > 0) {
     $user = user_load(array("uid" => $shout->uid));
@@ -296,6 +305,9 @@ function theme_shoutbox_post($shout, $li

   $title = 'Posted '. format_date($shout->created, 'custom', 'm/d/y') .' at '. format_date($shout->created, 'custom', 'h:ia') .' by '. $shout->username;
   $shout_class = (($shout->color) ? ("odd") : ("even"));
+  if (!$alter_row_color) {
+    $shout_class = 'none';
+  }

   return "<div class=\"shoutbox-$shout_class shoutbox-msg\" title=\"$title\">$img_links<b>$shout->url</b>: $shout->shout</div>\n";
 }
@@ -759,6 +771,7 @@ function _shoutbox_block_view() {

   drupal_add_js(array('shoutbox' => $js_settings), 'setting');

+  $output .= l(t('All Shouts'), 'shouts');
   return theme('shoutbox_page', $output, $title);
 }

@@ -769,19 +782,33 @@ function _shoutbox_block_view() {
  *
  * @param $show_amount
  *   The number of posts to show.
+ * @param $wrap
+ *   Whether or not to wrap posts in <div id="shoutbox-posts">
+ * @param $pager
+ *   Whether or not to use pager_query() instead of db_query_range(), defaults
+ *   to FALSE.
  * @return
  *   HTML for show_amount number of posts.
  */
-function _shoutbox_display_posts($show_amount, $wrap=TRUE) {
+function _shoutbox_display_posts($show_amount, $wrap=TRUE, $pager=FALSE) {
   global $user;

   $color = 0;
   $count = 0;

-  // Get the shoust from the database.
-  $result = db_query_range("SELECT * FROM {shoutbox} WHERE status=1 ORDER BY created DESC", 0, $show_amount);
+  // Figure out if we should display it in ascending or descending order.
+  $ascending = variable_get('shoutbox_ascending', false);
+
+  // Get the shouts from the database.
+  if (!$pager) {
+    $result = db_query_range("SELECT * FROM {shoutbox} WHERE status=1 ORDER BY created DESC", 0, $show_amount);
+  }
+  else {
+    $result = pager_query("SELECT * FROM {shoutbox} WHERE status=1 ORDER BY created DESC", $show_amount);
+  }

   $output = '';
+  $rows = array();
   while ($shout = db_fetch_object($result)) {
     _shoutbox_sanitize_shout($shout);

@@ -797,8 +824,6 @@ function _shoutbox_display_posts($show_a
     }

     $shout->color = $color;
-    // Figure out if we should display it in ascending or descending order.
-    $ascending = variable_get('shoutbox_ascending', false);

     // Theme the shoutbox post.
     if ($ascending) {
@@ -807,20 +832,25 @@ function _shoutbox_display_posts($show_a
     else {
       $output = theme('shoutbox_post', $shout, $shoutlinks) . $output;
     }
+    $rows[] = array(theme('shoutbox_post', $shout, $shoutlinks, FALSE));

     ++$count;
   }
+  if (!$ascending) {
+    $rows = array_reverse($rows);
+  }

   if (!$count) {
     $output .= '<div class="shoutbox-even" title="no shouts">'. t("There are no shouts to view.") ."</div>\n";
   }
-  // don't wrap for ahah refreshes
+  // Don't wrap for ahah refreshes.
   if ($wrap) {
     // Wrap shout box messages.
     $output = "<div id=\"shoutbox-posts\">\n". $output ."</div>\n";
-    }
+  }
   $output_data['count'] = $count;
   $output_data['output'] = $output;
+  $output_data['rows'] = $rows;
   return $output_data;
 }

@@ -974,3 +1004,19 @@ function _shoutbox_sanitize_shout(&$shou
   $shout->color = check_plain($shout->color);
 }

+/**
+ * Show paged view of full list of shouts.
+ */
+function shoutbox_page_view() {
+  global $user;
+
+  drupal_add_css(drupal_get_path('module', 'shoutbox') .'/shoutbox.css');
+
+  // Output the existing shoutbox posts.
+  $shoutbox_ascending = variable_get('shoutbox_ascending', FALSE);
+  $shoutbox_posts_data = _shoutbox_display_posts(20, TRUE, TRUE);
+  $output .= theme('table', array(), $shoutbox_posts_data['rows']);
+  $output .= theme('pager', NULL, 3, 0);
+
+  return $output;
+}
