--- quotes.module.orig	2007-02-14 07:28:35.000000000 -0800
+++ quotes.module	2007-04-15 15:20:56.000000000 -0700
@@ -393,23 +400,28 @@
 
       if ($block['cron_interval'] > 0) {
         if (!$block['vid'] || (($block['cron_last'] + ($block['cron_interval'] * $block['cron_step'])) < time())) {
-          $block['vid'] = quotes_get_quote($block, TRUE);
+          $quote = quotes_get_quote($block, TRUE);
+          $block['vid'] = $quote[0];
 
           db_query('UPDATE {quotes_blocks} SET vid = %d, cron_last = %d WHERE bid = %d', $block['vid'], time(), $delta);
           cache_clear_all();
         }
       }
       else {
-        $block['vid'] = quotes_get_quote($block, TRUE);
+        $block['vid'] = quotes_get_quote($block, TRUE, $block['count']);
       }
 
       if (!$block['vid']) {
         return NULL;
       }
 
-      $quote = quotes_view(node_load($block['vid']));
+	  $quotes = array();
+	  foreach ($block['vid'] as $nid) {
+		$n = quotes_view(node_load(array('nid' => $nid)), true);
+	  	$quotes[] = drupal_render($n->content);
+	  }
 
-      return array('subject' => t(str_replace('%title', $quote->title, $block['name'])), 'content' => $quote->body);
+      return array('subject' => t(str_replace('%title', $quote->title, $block['name'])), 'content' => implode("\n", $quotes));
 
     case 'configure':
       $block = db_fetch_object(db_query("SELECT qb.* FROM {quotes_blocks} qb WHERE bid = %d", $delta));
@@ -457,6 +469,14 @@
         '#default_value' => $block->name,
         '#description' => t('Enter a unique name for this block. This will identify the block on the !block administration page and be used for the default block title. If desired, you can include the string %title which will be replaced by the title of the quote being displayed in the block.', array('!block administration page' => l(t('block administration page'), 'admin/build/block'), '%title' => '%title'))
       );
+      $form['count'] = array(
+        '#type' => 'select',
+        '#title' => t('Quote count'),
+        '#required' => TRUE,
+        '#default_value' => $block->count,
+		'#description' => t('Enter the number of quotes you want to show up in this block.'),
+        '#options' => drupal_map_assoc(range(1,20)),
+      );
       $form['block_type'] = array(
         '#type' => 'radios',
         '#title' => t('Type'),
@@ -548,7 +568,7 @@
       $uids = implode(',', (array) $edit['uid_filter']);
       $tids = implode(',', (array) $edit['tid_filter']);
 
-      db_query("UPDATE {quotes_blocks} SET name = '%s', block_type = %d, nid_filter = '%s', rid_filter = '%s', uid_filter = '%s', tid_filter = '%s', cron_interval = %d, cron_step = %d WHERE bid = %d", $edit['name'], (($edit['block_type'] == 1) ? 1 : 0), $nids, $rids, $uids, $tids, ($edit['cron_interval'] ? $edit['cron_interval'] : 0), $edit['cron_step'], $delta);
+      db_query("UPDATE {quotes_blocks} SET name = '%s', block_type = %d, nid_filter = '%s', rid_filter = '%s', uid_filter = '%s', tid_filter = '%s', cron_interval = %d, cron_step = %d, count = %d WHERE bid = %d", $edit['name'], (($edit['block_type'] == 1) ? 1 : 0), $nids, $rids, $uids, $tids, ($edit['cron_interval'] ? $edit['cron_interval'] : 0), $edit['cron_step'], $edit['count'], $delta);
   }
 }
 
@@ -568,7 +588,8 @@
   $result = db_query("SELECT qb.* FROM {quotes_blocks} qb INNER JOIN {blocks} b ON b.module = 'quotes' WHERE b.status = 1 AND qb.cron_interval > 0 AND (qb.vid = 0 OR (qb.cron_last + (qb.cron_step * qb.cron_interval)) < %d)", time());
 
   for ($updated = FALSE; $block = db_fetch_array($result); $updated = TRUE) {
-    db_query('UPDATE {quotes_blocks} SET vid = %d, cron_last = %d WHERE bid = %d', quotes_get_quote($block, TRUE), time(), $block['bid']);
+    $quote = quotes_get_quote($block, TRUE);
+    db_query('UPDATE {quotes_blocks} SET vid = %d, cron_last = %d WHERE bid = %d', $quote[0], time(), $block['bid']);
   }
 
   if ($updated) {
@@ -791,23 +839,20 @@
  * @return
  *   The node ID for a quote matching the specified criteria.
  */
-function quotes_get_quote($filters = array(), $promoted_only = FALSE) {
+function quotes_get_quote($filters = array(), $promoted_only = FALSE, $how_many = 1) {
   $query = db_rewrite_sql('SELECT %s FROM {quotes} q INNER JOIN {node} n ON n.vid = q.vid ' . quotes_block_join_sql($filters) . "WHERE n.status = 1 AND n.type = 'quotes' AND " . ($promoted_only ? ' q.promote = 1 AND ' : '') . quotes_block_where_sql($filters));
 
   if ($filters['block_type'] == 1) {
-    return (int) db_result(db_query_range($query . ' ORDER BY n.created DESC', 'n.nid', 0, 1));
+    $res = db_query_range($query . ' ORDER BY n.created DESC', 'n.nid', 0, $how_many);
   }
   else {
-    // get the number of quotes in the database
-    $count = db_result(db_query($query, 'COUNT(*)'));
-
-    if (!$count) {
-      return 0;
-    }
-
-    // pick and retrieve a quote
-    return (int)db_result(db_query_range($query, 'n.nid', rand(0, $count - 1), 1));
+    $res = db_query_range($query . ' ORDER BY RAND()', 'DISTINCT(n.nid)', 0, $how_many);
+  }
+  $quotes = array();
+  while ($qid = db_fetch_array($res)) {
+  	$quotes[] = $qid['nid'];
   }
+  return $quotes;
 }
 
 /**
--- quotes.install.orig	2007-04-15 15:03:37.000000000 -0700
+++ quotes.install	2007-04-15 15:13:33.000000000 -0700
@@ -133,4 +133,31 @@
   return $items;
 }
 
-?>
\ No newline at end of file
+/**
+ * Adds a column so the user can specify how many quotes
+ * to show in a block
+ */
+function quotes_update_5() {
+  global $db_type;
+
+  $items = array();
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      $items[] = update_sql("ALTER TABLE {quotes_blocks} ADD COLUMN count INTEGER NOT NULL DEFAULT 1");
+      break;
+
+    case 'pgsql':
+      // this could all be a single query in postgres 8.1,
+      // but 7.4 makes us do it in 4 queries
+      $items[] = update_sql("ALTER TABLE {quotes_blocks} ADD COLUMN count INTEGER");
+      $items[] = update_sql("UPDATE {quotes_blocks} SET count=0 WHERE count IS NULL");
+      $items[] = update_sql("ALTER TABLE {quotes_blocks} ALTER COLUMN count SET NOT NULL");
+      $items[] = update_sql("ALTER TABLE {quotes_blocks} ALTER COLUMN count SET DEFAULT 1");
+      break;
+  }
+
+  return $items;
+}
+
+?>
