You are here

function block_block in Drupal 5

Same name and namespace in other branches
  1. 4 modules/block.module \block_block()
  2. 6 modules/block/block.module \block_block()

Implementation of hook_block().

Generates the administrator-defined blocks for display.

File

modules/block/block.module, line 110
Controls the boxes that are displayed around the main content.

Code

function block_block($op = 'list', $delta = 0, $edit = array()) {
  switch ($op) {
    case 'list':
      $blocks = array();
      $result = db_query('SELECT bid, info FROM {boxes} ORDER BY info');
      while ($block = db_fetch_object($result)) {
        $blocks[$block->bid]['info'] = $block->info;
      }
      return $blocks;
    case 'configure':
      $box = block_box_get($delta);
      if (filter_access($box['format'])) {
        return block_box_form($box);
      }
      break;
    case 'save':
      block_box_save($edit, $delta);
      break;
    case 'view':
      $block = db_fetch_object(db_query('SELECT body, format FROM {boxes} WHERE bid = %d', $delta));
      $data['content'] = check_markup($block->body, $block->format, FALSE);
      return $data;
  }
}