Projet

Général

Profil

Paste
Télécharger (4,2 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / diff / diff.install @ 661d64c9

1
<?php
2

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

    
8
/**
9
 * Implements hook_install().
10
 */
11
function diff_install() {
12
  user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('diff view changes'));
13
  user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('diff view changes'));
14
}
15

    
16
/**
17
 * Implements hook_uninstall().
18
 */
19
function diff_uninstall() {
20
  // Bulk delete entity based variables.
21
  $prefixes = array(
22
    'diff_enable_revisions_page_',
23
    'diff_show_',
24
    'diff_view_mode_',
25
    'diff_admin_path_',
26
    'diff_default_state_',
27
    'diff_additional_options_',
28
  );
29
  foreach ($prefixes as $prefix) {
30
    db_delete('variable')
31
      ->condition('name', db_like($prefix) . '%', 'LIKE')
32
      ->execute();
33
  }
34

    
35
  // Delete global variables.
36
  variable_del('diff_context_lines_trailing');
37
  variable_del('diff_context_lines_leading');
38
  variable_del('diff_theme');
39
  variable_del('diff_radio_behavior', '');
40

    
41
  foreach (field_info_fields() as $field) {
42
    variable_del("diff_{$field['module']}_field_{$field['type']}_default_options");
43
  }
44
}
45

    
46
/**
47
 * Updates the existing system variables to target the entity type and bundle.
48
 */
49
function diff_update_7300() {
50
  $node_types = array_keys(node_type_get_types());
51
  foreach ($node_types as $bundle) {
52
    $type_variables = array(
53
      'show_preview_changes',
54
      'enable_revisions_page',
55
      'show_diff_inline',
56
    );
57
    foreach ($type_variables as $prefix) {
58
      $setting = variable_get($prefix . '_' . $bundle, NULL);
59
      if (isset($setting)) {
60
        variable_del($prefix . '_' . $bundle);
61
        variable_set('diff_' . $prefix . '_node_' . $bundle, $setting);
62
      }
63
    }
64
  }
65
}
66

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

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

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

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

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

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

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

    
127
/**
128
 * Sets the optional additional node properties to render so that the title
129
 * still shows by default when doing node comparisons.
130
 */
131
function diff_update_7306() {
132
  variable_set('diff_additional_options_node', array('title' => 'title'));
133
}
134

    
135
/**
136
 * Grants access to the Diff "View Changes" button permission to all users.
137
 */
138
function diff_update_7307() {
139
  user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('diff view changes'));
140
  user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('diff view changes'));
141
}