Projet

Général

Profil

Paste
Télécharger (3,58 ko) Statistiques
| Branche: | Révision:

root / htmltest / sites / all / modules / diff / diff.install @ a5572547

1
<?php
2

    
3
/**
4
 * @file
5
 * Provides uninstallation functions.
6
 */
7

    
8
/**
9
 * Implements hook_uninstall().
10
 */
11
function diff_uninstall() {
12
  // Bulk delete entity based variables.
13
  $prefixes = array(
14
    'diff_enable_revisions_page_',
15
    'diff_show_',
16
    'diff_view_mode_',
17
    'diff_admin_path_',
18
    'diff_default_state_',
19
  );
20
  foreach ($prefixes as $prefix) {
21
    db_delete('variable')
22
      ->condition('name', db_like($prefix) . '%', 'LIKE')
23
      ->execute();
24
  }
25

    
26
  // Delete global variables.
27
  variable_del('diff_context_lines_trailing');
28
  variable_del('diff_context_lines_leading');
29
  variable_del('diff_theme');
30
  variable_del('diff_radio_behavior', '');
31

    
32
  foreach (field_info_fields() as $field) {
33
    variable_del("diff_{$field['module']}_field_{$field['type']}_default_options");
34
  }
35
}
36

    
37
/**
38
 * Updates the existing system variables to target the entity type and bundle.
39
 */
40
function diff_update_7300() {
41
  $node_types = array_keys(node_type_get_types());
42
  foreach ($node_types as $bundle) {
43
    $type_variables = array(
44
      'show_preview_changes',
45
      'enable_revisions_page',
46
      'show_diff_inline',
47
    );
48
    foreach ($type_variables as $prefix) {
49
      $setting = variable_get($prefix . '_' . $bundle, NULL);
50
      if (isset($setting)) {
51
        variable_del($prefix . '_' . $bundle);
52
        variable_set('diff_' . $prefix . '_node_' . $bundle, $setting);
53
      }
54
    }
55
  }
56
}
57

    
58
/**
59
 * Removed diff_update_7301().
60
 */
61

    
62
/**
63
 * Removed diff_update_7302().
64
 */
65

    
66
/**
67
 * Renames some internal settings names.
68
 */
69
function diff_update_7303() {
70
  // Get current values
71
  $radio = variable_get('diff_script_revisioning', 'simple');
72
  $leading = variable_get('diff_leading_context_lines', 2);
73
  $trailing = variable_get('diff_trailing_context_lines', 2);
74
  // Create new variable names
75
  variable_set('diff_radio_behavior', $radio);
76
  variable_set('diff_context_lines_leading', $leading);
77
  variable_set('diff_context_lines_trailing', $trailing);
78
  // Delete old variables
79
  variable_del('diff_script_revisioning');
80
  variable_del('diff_leading_context_lines');
81
  variable_del('diff_trailing_context_lines');
82
}
83

    
84
/**
85
 * Removes unused variable settings and merges inline diff block settings.
86
 */
87
function diff_update_7304() {
88
  // This is now always applied to text fields.
89
  variable_del('diff_normalise_text');
90

    
91
  // Merge the content type settings for the inline diff block into a single variable.
92
  // diff_update_7300() - show_diff_inline_TYPE to diff_show_diff_inline_node_TYPE
93
  $node_types = array_keys(node_type_get_types());
94
  $enabled_types = array();
95
  foreach ($node_types as $node_type) {
96
    if (variable_get('diff_show_diff_inline_node_' . $node_type, FALSE)) {
97
      $enabled_types[$node_type] = $node_type;
98
    }
99
    variable_del('diff_show_diff_inline_node_' . $node_type);
100
  }
101
  variable_set('diff_show_diff_inline_node_bundles', $enabled_types);
102

    
103
  // Warn users that these settings are altered.
104
  drupal_set_message(t('Diff <em>Inline differences</em> content type settings are now located within the <em>Inline differences</em> block settings.'));
105
}
106

    
107
/**
108
 * Updates to normalize the new view mode settings.
109
 */
110
function diff_update_7305() {
111
  // Rebuild the menus.
112
  variable_set('menu_rebuild_needed', TRUE);
113

    
114
  // Removed the enforced entity view mode.
115
  db_delete('variable')
116
      ->condition('name', db_like('diff_view_mode_standard_node_') . '%', 'LIKE')
117
      ->execute();
118

    
119
  // Removes the configurable view mode for the inline diff block, as this
120
  // is fairly meaningless and confusing to users.
121
  db_delete('variable')
122
      ->condition('name', db_like('diff_view_mode_inline_') . '%', 'LIKE')
123
      ->execute();
124
}