function system_update_7053

Upgrade standard blocks and menus.

Related topics

Archivo

drupal-7.x/modules/system/system.install, line 2418
Install, update and uninstall functions for the system module.

Código

function system_update_7053() {
  if (db_table_exists('menu_custom')) {
    // Create the same menus as in menu_install().
    db_insert('menu_custom')->fields(array('menu_name' => 'user-menu', 'title' => 'User Menu', 'description' => "The <em>User</em> menu contains links related to the user's account, as well as the 'Log out' link."))->execute();

    db_insert('menu_custom')->fields(array('menu_name' => 'management', 'title' => 'Management', 'description' => "The <em>Management</em> menu contains links for administrative tasks."))->execute();
  }

  block_flush_caches();

  // Show the new menu blocks along the navigation block.
  $blocks = db_query("SELECT theme, status, region, weight, visibility, pages FROM {block} WHERE module = 'system' AND delta = 'navigation'");
  $deltas = db_or()->condition('delta', 'user-menu')->condition('delta', 'management');

  foreach ($blocks as $block) {
    db_update('block')->fields(array(
      'status' => $block->status,
      'region' => $block->region,
      'weight' => $block->weight,
      'visibility' => $block->visibility,
      'pages' => $block->pages,
    ))->condition('theme', $block->theme)->condition('module', 'system')->condition($deltas)->execute();
  }
}