function menu_block_update_5200 in Menu Block 7.2
Same name and namespace in other branches
- 5.2 menu_block.install \menu_block_update_5200()
- 6.2 menu_block.install \menu_block_update_5200()
- 7.3 menu_block.install \menu_block_update_5200()
Converts menu block-tracking data to new format.
File
- ./
menu_block.install, line 69 - Provides install, upgrade and un-install functions for menu_block.
Code
function menu_block_update_5200() {
$block_ids = array();
foreach (variable_get('menu_block_enabled_blocks', array()) as $delta => $enabled) {
if ($enabled) {
$block_ids[] = $delta;
// Build new $menu_block_ids.
// Convert $menu_block_DELTA_mid to $menu_block_DELTA_menu_name.
$mid = variable_get("menu_block_{$delta}_mid", 1);
variable_set("menu_block_{$delta}_menu_name", $mid);
// If we weren't upgraded to 5.x-2.x before the Drupal 6 upgrade, the
// mid-to-menu_name conversion is not possible.
variable_set("menu_block_{$delta}_title", $mid == 2 ? 'primary-links' : 'navigation');
variable_del("menu_block_{$delta}_mid");
}
else {
// Delete un-enabled menu block.
variable_del("menu_block_{$delta}_mid");
variable_del("menu_block_{$delta}_level");
variable_del("menu_block_{$delta}_depth");
variable_del("menu_block_{$delta}_expanded");
db_delete('block')
->condition('module', 'menu_block')
->condition('delta', $delta)
->execute();
db_delete('block_role')
->condition('module', 'menu_block')
->condition('delta', $delta)
->execute();
}
}
// Finish conversion of $menu_block_enabled_blocks to $menu_block_ids.
sort($block_ids);
variable_set('menu_block_ids', $block_ids);
variable_del('menu_block_enabled_blocks');
cache_clear_all();
return t('A 5.x-1.x version of Menu block has been detected and an attempt was made to upgrade it. Unfortunately, you should have upgraded to Menu block 5.x-2.x before your upgrade to Drupal 7. You may need to re-configure all your menu blocks.');
}