admin_menu.install 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. /**
  3. * @file
  4. * Install, update, and uninstall functions for the admin menu module.
  5. */
  6. /**
  7. * Implements hook_schema().
  8. */
  9. function admin_menu_schema() {
  10. $schema['cache_admin_menu'] = drupal_get_schema_unprocessed('system', 'cache');
  11. $schema['cache_admin_menu']['description'] = 'Cache table for Administration menu to store client-side caching hashes.';
  12. return $schema;
  13. }
  14. /**
  15. * Implements hook_install().
  16. */
  17. function admin_menu_install() {
  18. // Increase the module weight, so admin_menu catches any alterations made by
  19. // other modules in hook_menu_alter().
  20. db_update('system')
  21. ->fields(array('weight' => 100))
  22. ->condition('type', 'module')
  23. ->condition('name', 'admin_menu')
  24. ->execute();
  25. }
  26. /**
  27. * Implements hook_uninstall().
  28. */
  29. function admin_menu_uninstall() {
  30. // Delete variables.
  31. variable_del('admin_menu_components');
  32. variable_del('admin_menu_margin_top');
  33. variable_del('admin_menu_position_fixed');
  34. variable_del('admin_menu_tweak_modules');
  35. variable_del('admin_menu_tweak_tabs');
  36. variable_del('admin_menu_show_all');
  37. variable_del('admin_menu_display');
  38. variable_del('admin_menu_cache_server');
  39. variable_del('admin_menu_cache_client');
  40. // Unused variables still should be deleted.
  41. variable_del('admin_menu_devel_modules');
  42. variable_del('admin_menu_devel_modules_enabled');
  43. variable_del('admin_menu_devel_modules_skip');
  44. }
  45. /**
  46. * Ensure that admin_menu is rebuilt after upgrading to D6.
  47. */
  48. function admin_menu_update_6000() {
  49. // Drop the {admin_menu} table in admin_menu_update_6000() on sites that used
  50. // one of the later patches in #132524.
  51. if (db_table_exists('admin_menu')) {
  52. db_drop_table('admin_menu');
  53. }
  54. }
  55. /**
  56. * Wipe and rebuild so we can switch the icon path to <front>.
  57. */
  58. function admin_menu_update_6001() {
  59. db_delete('menu_links')->condition('module', 'admin_menu')->execute();
  60. menu_cache_clear('admin_menu');
  61. }
  62. /**
  63. * Add {cache_admin_menu} table.
  64. */
  65. function admin_menu_update_7300() {
  66. if (!db_table_exists('cache_admin_menu')) {
  67. $schema = drupal_get_schema_unprocessed('system', 'cache');
  68. db_create_table('cache_admin_menu', $schema);
  69. }
  70. }
  71. /**
  72. * Increase the module weight.
  73. *
  74. * @see admin_menu_install()
  75. */
  76. function admin_menu_update_7302() {
  77. db_update('system')
  78. ->fields(array('weight' => 100))
  79. ->condition('type', 'module')
  80. ->condition('name', 'admin_menu')
  81. ->execute();
  82. }
  83. /**
  84. * Remove local tasks from {menu_links} table.
  85. */
  86. function admin_menu_update_7303() {
  87. db_delete('menu_router')
  88. ->condition('path', 'admin/%', 'LIKE')
  89. ->condition('type', MENU_IS_LOCAL_TASK, '&')
  90. ->execute();
  91. }
  92. /**
  93. * Remove obsolete 'admin_menu' menu and all orphan links in it.
  94. */
  95. function admin_menu_update_7304() {
  96. // Remove the custom menu used by 6.x-1.x.
  97. if (db_table_exists('menu_custom')) {
  98. db_delete('menu_custom')->condition('menu_name', 'admin_menu')->execute();
  99. }
  100. // 6.x-1.x cloned the entire link structure below the path 'admin' into a
  101. // separate 'menu_name' "admin_menu" with 'module' "admin_menu". 6.x-3.x and
  102. // early alpha versions of 7.x-3.x still did something similar. All of these
  103. // records are obsolete. Removal of the 'module' records (without different
  104. // menu_name) is particularly important, since they would otherwise appear
  105. // as duplicate links.
  106. db_delete('menu_links')
  107. ->condition(db_or()
  108. ->condition('module', 'admin_menu')
  109. ->condition('menu_name', 'admin_menu')
  110. )
  111. ->execute();
  112. }