7.x dashboard.install dashboard_disable()

Implements hook_disable().

Stash a list of blocks enabled on the dashboard, so they can be re-enabled if the dashboard is re-enabled. Then disable those blocks, since the dashboard regions will no longer be defined.

File

modules/dashboard/dashboard.install, line 15
Install, update and uninstall functions for the dashboard module.

Code

function dashboard_disable() {
  // Stash a list of currently enabled blocks.
  $stashed_blocks = array();

  $result = db_select('block', 'b')
    ->fields('b', array('module', 'delta', 'region'))
    ->condition('b.region', dashboard_regions(), 'IN')
    ->execute();

  foreach ($result as $block) {
    $stashed_blocks[] = array(
      'module' => $block->module,
      'delta' => $block->delta,
      'region' => $block->region,
    );
  }
  variable_set('dashboard_stashed_blocks', $stashed_blocks);

  // Disable the dashboard blocks.
  db_update('block')
    ->fields(array(
      'status' => 0,
      'region' => BLOCK_REGION_NONE,
    ))
    ->condition('region', dashboard_regions(), 'IN')
    ->execute();
}