You are here

function menu_block_update_5100 in Menu Block 6.2

Same name and namespace in other branches
  1. 5.2 menu_block.install \menu_block_update_5100()
  2. 5 menu_block.install \menu_block_update_5100()
  3. 7.3 menu_block.install \menu_block_update_5100()
  4. 7.2 menu_block.install \menu_block_update_5100()

Convert pre-1.0 configurations to the new block naming convention.

File

./menu_block.install, line 47
Provides install, upgrade and un-install functions for menu_block.

Code

function menu_block_update_5100() {
  $delta = 0;
  $enabled_blocks = array();

  // Find the old enabled blocks.
  foreach (variable_get('menu_block_enabled_blocks', array()) as $old_delta => $enabled) {
    list($mid, $level) = explode('-', $old_delta);
    if ($enabled) {
      $enabled_blocks[++$delta] = TRUE;
      variable_set("menu_block_{$delta}_mid", $mid);
      variable_set("menu_block_{$delta}_level", $level);
      variable_set("menu_block_{$delta}_depth", variable_get("menu_block_depth_{$mid}_{$level}", 0));
      variable_set("menu_block_{$delta}_expanded", variable_get("menu_block_expanded_{$mid}_{$level}", 0));
    }

    // Remove any of the old-style variables.
    variable_del("menu_block_depth_{$mid}_{$level}");
    variable_del("menu_block_expanded_{$mid}_{$level}");
  }
  variable_set('menu_block_enabled_blocks', $enabled_blocks);
  return array(
    0 => array(
      'success' => TRUE,
      'query' => t('A pre-release version of Menu block has been detected. All menu blocks from the pre-release version have been given a new delta and are no longer placed in any block regions; their block placement should be re-configured immediately.'),
    ),
  );
}