block_list($region, $regions = array('left' => 0, 'right' => 1, 'all' => '0, 1'))
drupal/modules/block.module, line 449
$region
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 AND region IN (%s) ORDER BY weight, module", $regions[$region]);
while ($block = db_fetch_array($result)) {
// Use the user's block visibility setting, if necessary
if ($block['custom'] != 0) {
if ($user->uid && isset($user->block[$block['module']][$block['delta']])) {
$enabled = $user->block[$block['module']][$block['delta']];
}
else {
$enabled = ($block['custom'] == 1);
}
}
else {
$enabled = TRUE;
}
// Match path if necessary
if ($block['pages']) {
$path = drupal_get_path_alias($_GET['q']);
$regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($block['pages'], '/')) .')$/';
$page_match = !($block['visibility'] xor preg_match($regexp, $path));
}
else {
$page_match = TRUE;
}
// Match node type if necessary
$type_match = FALSE;
if ($block['types'] != '') {
if (arg(0) == 'node' && is_numeric(arg(1))) {
$node = node_load(array('nid' => arg(1)));
$types = explode(',', $block['types']);
//Match on any one selected type
foreach ($types as $type) {
if ($node->type == $type) {
$type_match = TRUE;
break;
}
}
}
}
else {
$type_match = TRUE;
}
if ($enabled && $page_match && $type_match) {
// Check the current throttle status and see if block should be displayed
// based on server load.
if (!($block['throttle'] && (module_invoke('throttle', 'status') > 0))) {
$array = module_invoke($block['module'], 'block', 'view', $block['delta']);
if (is_array($array)) {
$block = array_merge($block, $array);
}
}
if (isset($block['content']) && $block['content']) {
$blocks[$region]["$block[module]_$block[delta]"] = (object) $block;
}
}
}
}
return $blocks[$region];
}