function blocks_setup(&$PAGE, $pinned = BLOCKS_PINNED_FALSE)
{
    switch ($pinned) {
        case BLOCKS_PINNED_TRUE:
            $pageblocks = blocks_get_pinned($PAGE);
            break;
        case BLOCKS_PINNED_BOTH:
            $pageblocks = blocks_get_by_page_pinned($PAGE);
            break;
        case BLOCKS_PINNED_FALSE:
        default:
            $pageblocks = blocks_get_by_page($PAGE);
            break;
    }
    blocks_execute_url_action($PAGE, $pageblocks, $pinned == BLOCKS_PINNED_TRUE);
    return $pageblocks;
}
function blocks_setup(&$page, $pinned = BLOCKS_PINNED_FALSE)
{
    $page->blocks->load_blocks();
    blocks_execute_url_action($page, $page->blocks);
    return $page->blocks;
}