You are here

function quicktabs_get_blocks in Quick Tabs 6.3

Same name and namespace in other branches
  1. 5 quicktabs.module \quicktabs_get_blocks()
  2. 6 quicktabs.module \quicktabs_get_blocks()
  3. 6.2 includes/admin.inc \quicktabs_get_blocks()
  4. 7.3 quicktabs.admin.inc \quicktabs_get_blocks()
  5. 7.2 includes/admin.inc \quicktabs_get_blocks()

Helper function to get all blocks.

1 call to quicktabs_get_blocks()
_quicktabs_form in includes/admin.inc

File

includes/admin.inc, line 695

Code

function quicktabs_get_blocks() {
  static $blocksarray;
  if (empty($blocksarray)) {
    global $theme_key;
    init_theme();
    $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $theme_key);
    $old_blocks = array();
    while ($old_block = db_fetch_array($result)) {
      $old_blocks[$old_block['module']][$old_block['delta']] = $old_block;
    }
    $blocks = array();
    foreach (module_list() as $module) {
      $module_blocks = module_invoke($module, 'block', 'list');
      if ($module_blocks) {
        foreach ($module_blocks as $delta => $block) {
          if (empty($old_blocks[$module][$delta])) {

            // If it's a new block, add identifiers.
            $block['module'] = $module;
            $block['delta'] = $delta;
            $block['theme'] = $theme_key;
            $blocks[] = $block;
          }
          else {
            $old_blocks[$module][$delta]['info'] = $block['info'];

            // Add this block to the list of blocks we return.
            $blocks[] = $old_blocks[$module][$delta];
          }
        }
      }
    }
    $blocksarray = array();
    foreach ($blocks as $i => $block) {
      if ($block['module'] != 'quicktabs') {
        $key = $block['module'] . '_delta_' . $block['delta'];
        $blocksarray[$key] = $block['info'];
      }
    }
  }
  return $blocksarray;
}