You are here

function multiblock_get_block in MultiBlock 7

Same name and namespace in other branches
  1. 5 multiblock.module \multiblock_get_block()
  2. 6 multiblock.module \multiblock_get_block()

Fetch a given block from the multiblock database table.

Parameters

$delta: Optional. Retreive a single block based on this delta. If none specified, all multiblock instances are returned.

$reset: Optional. Boolean value to reset the internal cache of this function.

5 calls to multiblock_get_block()
multiblock_add_form_submit in ./multiblock.module
Add block instance to database from "Add Block Instance" form.
multiblock_block_info in ./multiblock.module
Implements hook_block_info().
multiblock_call_block in ./multiblock.module
Dispatch a hook_block call to its respective module. Paramater $delta is the new multiblock delta that we're using and $op is the op we are dispatching.
multiblock_delete_form in ./multiblock.module
multiblock_general in ./multiblock.module
Page callback for the "Manage Block Instances page".

File

./multiblock.module, line 80
Enhances the block API, as provided by D7 Core.

Code

function multiblock_get_block($delta = NULL, $reset = FALSE) {
  static $blocks;
  if (!isset($blocks) || $reset) {
    $blocks = array();
    $result = db_query("SELECT * FROM {multiblock}");
    $modules = array();
    foreach ($result as $row) {

      // If we've not checked this module is enabled yet do so.
      if (!isset($modules[$row->module])) {
        $modules[$row->module] = module_exists($row->module);
      }

      // Only add this block if the module is enabled.
      if ($modules[$row->module]) {
        $blocks[$row->delta] = $row;
      }
    }
  }
  return is_numeric($delta) ? isset($blocks[$delta]) ? $blocks[$delta] : FALSE : $blocks;
}