xmlsitemap_menu.install 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. // $Id: xmlsitemap_menu.install,v 1.3 2010/01/18 07:46:28 davereid Exp $
  3. /**
  4. * @file
  5. * Install and uninstall schema and functions for the xmlsitemap_menu module.
  6. */
  7. /**
  8. * Implements hook_uninstall().
  9. */
  10. function xmlsitemap_menu_uninstall() {
  11. // Remove variables.
  12. drupal_load('module', 'xmlsitemap_menu');
  13. $variables = array_keys(xmlsitemap_menu_variables());
  14. foreach ($variables as $variable) {
  15. variable_del($variable);
  16. }
  17. }
  18. // @todo Remove these update functions before alpha.
  19. function xmlsitemap_menu_update_1() {
  20. $value = xmlsitemap_menu_var('menus');
  21. variable_set('xmlsitemap_menu_menus', array_filter($value));
  22. }
  23. function xmlsitemap_menu_update_2() {
  24. $field = array(
  25. 'description' => 'The {menu_links}.menu_name of this menu link.',
  26. 'type' => 'varchar',
  27. 'length' => 32,
  28. 'default' => NULL,
  29. );
  30. db_add_field('xmlsitemap', 'menu_name', $field);
  31. db_add_index('xmlsitemap', 'menu_name', array('menu_name'));
  32. db_query("UPDATE {xmlsitemap} SET menu_name = (SELECT menu_name FROM {menu_links} WHERE mlid = {xmlsitemap}.id) WHERE type = 'menu'");
  33. }
  34. function xmlsitemap_menu_update_3() {
  35. $menus = variable_get('xmlsitemap_menu_menus', array());
  36. foreach ($menus as $menu) {
  37. variable_set('xmlsitemap_menu_status_' . $menu, TRUE);
  38. }
  39. variable_del('xmlsitemap_menu_menus');
  40. }
  41. function xmlsitemap_menu_update_4() {
  42. }
  43. function xmlsitemap_menu_update_5() {
  44. }
  45. // Skip to 6 since I was stupid and had xmlsitemap_menu_update_5() in xmlsitemap_node.install
  46. function xmlsitemap_menu_update_6() {
  47. db_update('system')
  48. ->fields(array('weight' => 0))
  49. ->condition('type', 'module')
  50. ->condition('name', 'xmlsitemap_menu')
  51. ->execute();
  52. }
  53. function xmlsitemap_menu_update_7() {
  54. $menus = array_keys(menu_get_menus());
  55. foreach ($menus as $menu) {
  56. if (variable_get('xmlsitemap_menu_priority_' . $menu, 'default') === 'default') {
  57. variable_set('xmlsitemap_menu_priority_' . $menu, 0.5);
  58. }
  59. }
  60. }