diff.install 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * @file
  4. * Provides uninstallation functions.
  5. */
  6. /**
  7. * Implements hook_uninstall().
  8. */
  9. function diff_uninstall() {
  10. // Bulk delete entity based variables.
  11. $prefixes = array(
  12. 'diff_enable_revisions_page_',
  13. 'diff_show_',
  14. 'diff_view_mode_',
  15. 'diff_admin_path_',
  16. 'diff_default_state_',
  17. );
  18. foreach ($prefixes as $prefix) {
  19. db_delete('variable')
  20. ->condition('name', db_like($prefix) . '%', 'LIKE')
  21. ->execute();
  22. }
  23. // Delete global variables.
  24. variable_del('diff_context_lines_trailing');
  25. variable_del('diff_context_lines_leading');
  26. variable_del('diff_theme');
  27. variable_del('diff_radio_behavior', '');
  28. foreach (field_info_fields() as $field) {
  29. variable_del("diff_{$field['module']}_field_{$field['type']}_default_options");
  30. }
  31. }
  32. /**
  33. * Updates the existing system variables to target the entity type and bundle.
  34. */
  35. function diff_update_7300() {
  36. $node_types = array_keys(node_type_get_types());
  37. foreach ($node_types as $bundle) {
  38. $type_variables = array(
  39. 'show_preview_changes',
  40. 'enable_revisions_page',
  41. 'show_diff_inline',
  42. );
  43. foreach ($type_variables as $prefix) {
  44. $setting = variable_get($prefix . '_' . $bundle, NULL);
  45. if (isset($setting)) {
  46. variable_del($prefix . '_' . $bundle);
  47. variable_set('diff_' . $prefix . '_node_' . $bundle, $setting);
  48. }
  49. }
  50. }
  51. }
  52. /**
  53. * Removed diff_update_7301().
  54. */
  55. /**
  56. * Removed diff_update_7302().
  57. */
  58. /**
  59. * Renames some internal settings names.
  60. */
  61. function diff_update_7303() {
  62. // Get current values
  63. $radio = variable_get('diff_script_revisioning', 'simple');
  64. $leading = variable_get('diff_leading_context_lines', 2);
  65. $trailing = variable_get('diff_trailing_context_lines', 2);
  66. // Create new variable names
  67. variable_set('diff_radio_behavior', $radio);
  68. variable_set('diff_context_lines_leading', $leading);
  69. variable_set('diff_context_lines_trailing', $trailing);
  70. // Delete old variables
  71. variable_del('diff_script_revisioning');
  72. variable_del('diff_leading_context_lines');
  73. variable_del('diff_trailing_context_lines');
  74. }
  75. /**
  76. * Removes unused variable settings and merges inline diff block settings.
  77. */
  78. function diff_update_7304() {
  79. // This is now always applied to text fields.
  80. variable_del('diff_normalise_text');
  81. // Merge the content type settings for the inline diff block into a single variable.
  82. // diff_update_7300() - show_diff_inline_TYPE to diff_show_diff_inline_node_TYPE
  83. $node_types = array_keys(node_type_get_types());
  84. $enabled_types = array();
  85. foreach ($node_types as $node_type) {
  86. if (variable_get('diff_show_diff_inline_node_' . $node_type, FALSE)) {
  87. $enabled_types[$node_type] = $node_type;
  88. }
  89. variable_del('diff_show_diff_inline_node_' . $node_type);
  90. }
  91. variable_set('diff_show_diff_inline_node_bundles', $enabled_types);
  92. // Warn users that these settings are altered.
  93. drupal_set_message(t('Diff <em>Inline differences</em> content type settings are now located within the <em>Inline differences</em> block settings.'));
  94. }
  95. /**
  96. * Updates to normalize the new view mode settings.
  97. */
  98. function diff_update_7305() {
  99. // Rebuild the menus.
  100. variable_set('menu_rebuild_needed', TRUE);
  101. // Removed the enforced entity view mode.
  102. db_delete('variable')
  103. ->condition('name', db_like('diff_view_mode_standard_node_') . '%', 'LIKE')
  104. ->execute();
  105. // Removes the configurable view mode for the inline diff block, as this
  106. // is fairly meaningless and confusing to users.
  107. db_delete('variable')
  108. ->condition('name', db_like('diff_view_mode_inline_') . '%', 'LIKE')
  109. ->execute();
  110. }