You are here

function menu_block_update_6200 in Menu Block 6.2

Same name and namespace in other branches
  1. 7.3 menu_block.install \menu_block_update_6200()
  2. 7.2 menu_block.install \menu_block_update_6200()

Converts the mids to menu names using the D5-stored menu_title variable.

File

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

Code

function menu_block_update_6200() {
  $menus = menu_get_menus();
  foreach (variable_get('menu_block_ids', array()) as $delta) {

    // Drupal 6 uses the menu title to create the new menu_name.
    $menu_name = preg_replace('/[^a-zA-Z0-9]/', '-', strtolower(variable_get("menu_block_{$delta}_title", '')));

    // If we can't find the new menu_name, default to the navigation menu.
    if (empty($menus[$menu_name])) {
      $menu_name = 'navigation';
    }
    variable_set("menu_block_{$delta}_menu_name", $menu_name);
    variable_del("menu_block_{$delta}_title");
  }
  return array(
    0 => array(
      'success' => TRUE,
      'query' => t('The 5.x-2.x version of Menu block has been upgraded. To use menu blocks in Drupal 6, find the "Add menu block" tab (or button) on the <a href="@url">administer blocks page</a>.', array(
        '@url' => url('admin/build/block'),
      )),
    ),
  );
}