Index: modules/block.module
===================================================================
RCS file: /var/www/cvs/drupal/drupal/modules/block.module,v
retrieving revision 1.1.1.1
diff -u -F^f -r1.1.1.1 block.module
--- modules/block.module	3 Apr 2005 05:24:35 -0000	1.1.1.1
+++ modules/block.module	3 Apr 2005 20:01:50 -0000
@@ -215,11 +215,11 @@ function block_admin_display() {
       if ($block['region'] == 0) {
         $left[] = $row;
       }
-      else {
+      if ($block['region'] == 1) {
         $right[] = $row;
       }
     }
-    else {
+    else if ($block['region'] <= 1) {
       $disabled[] = $row;
     }
   }
@@ -420,27 +420,37 @@ function block_user($type, $edit, &$user
   }
 }
 
-/**
- * Return blocks available for current $user at $region.
- *
- * @param $region main|left|right
+ /**
+ * Return blocks available for current $user at $region. You may use this
+ * function for anything that needs a node type or a URL matcher.
+  *
+ * @param $region
+ *   This is a string which describes in a human readable form which region
+ *   you need. Drupal core uses 'left', 'right' and 'all', where 'all' means
+ *   both left and right.
+  *
+ * @param $regions
+ *   This is an optional array and contains map(s) from the string $region to
+ *   the numerical region index(es) in the blocks table. See default value
+ *   for examples.
  *
- * @return array of block objects, indexed with <i>module</i>_<i>delta</i>
- *
- * @see <a href="http://drupal.org/node/1042" target="_top">[feature]
- *   Generic template design difficult w/o block region "look-ahead"</a>
- * @todo add a proper primary key (bid) to the blocks table so we don't have
- *   to mess around with this <i>module</i>_<i>delta</i> construct. currently,
- *   "blocks" has no primary key defined (bad)!
- */
-function block_list($region) {
+ * @return
+ *   an array of block objects, indexed with <i>module</i>_<i>delta</i>.
+ *   If you are displaying your blocks in one or two sidebars, you may check
+ *   whether this array is empty to see how many columns are going to be
+ *   displayed.
+  *
+  * @todo add a proper primary key (bid) to the blocks table so we don't have
+  *   to mess around with this <i>module</i>_<i>delta</i> construct. currently,
+  *   "blocks" has no primary key defined (bad)!
+  */
+function block_list($region, $regions = array('left' => 0, 'right' => 1, 'all' => '0, 1')) {
   global $user;
   static $blocks = array();
 
   if (!isset($blocks[$region])) {
     $blocks[$region] = array();
-    $result = db_query('SELECT * FROM {blocks} WHERE status = 1 '. ($region != 'all' ? 'AND region = %d ' : '') .'ORDER BY weight, module', $region == 'left' ? 0 : 1);
-
+    $result = db_query("SELECT * FROM {blocks} WHERE status = 1 AND region IN ('%s') ORDER BY weight, module", $regions[$region]);
     while ($result && ($block = db_fetch_array($result))) {
       // Use the user's block visibility setting, if necessary
       if ($block['custom'] != 0) {
