Projet

Général

Profil

Paste
Télécharger (6,86 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views_data_export / views_data_export.install @ 0ccfec7f

1 85ad3d82 Assos Assos
<?php
2
3
/**
4
 * Implementation of hook_schema()
5
 */
6
function views_data_export_schema() {
7
  $schema = array();
8
9
  $schema['views_data_export'] = array(
10
    'description' => t('Keep track of currently executing exports.'),
11
    'fields' => array(
12
      'eid' => array(
13
        'description' => 'Unique id for each on-going export.',
14
        'type' => 'serial',
15
        'unsigned' => TRUE,
16
        'not null' => TRUE,
17
      ),
18
      'view_name' => array(
19
        'type' => 'varchar',
20
        'length' => '128',
21
        'default' => '',
22
        'not null' => TRUE,
23
        'description' => 'The unique name of the view. This is the primary field views are loaded from, and is used so that views may be internal and not necessarily in the database. May only be alphanumeric characters plus underscores.',
24
      ),
25
      'view_display_id' => array(
26
        'type' => 'varchar',
27
        'length' => '64',
28
        'default' => '',
29
        'not null' => TRUE,
30
        'description' => 'The unique name of the view. This is the primary field views are loaded from, and is used so that views may be internal and not necessarily in the database. May only be alphanumeric characters plus underscores.',
31
      ),
32
      'time_stamp' => array(
33
        'type' => 'int',
34
        'unsigned' => TRUE,
35
        'not null' => TRUE,
36
        'default' => 0,
37
        'description' => 'The time this export started',
38
      ),
39
      'fid' => array(
40
        'description' => 'Files ID.',
41
        'type' => 'int',
42
        'unsigned' => TRUE,
43
        'not null' => TRUE
44
      ),
45
      'batch_state' => array(
46
        'type' => 'varchar',
47
        'length' => '32',
48
        'default' => 'init',
49
        'not null' => TRUE,
50
        'description' => 'The current state of the batch.',
51
      ),
52
      'sandbox' => array(
53
        'type' => 'blob',
54
        'not null' => FALSE,
55
        'size' => 'big',
56
        'serialize' => TRUE,
57
      ),
58
    ),
59
    'primary key' => array('eid'),
60
  );
61
62
  $schema['views_data_export_object_cache'] = array(
63
    'description' => 'A modified version of the views_object_cache that ignores session id.',
64
    'fields' => array(
65
      'eid' => array(
66
        'type' => 'varchar',
67
        'length' => '64',
68
        'description' => 'The export ID this view equates too.',
69
      ),
70
      'updated' => array(
71
        'type' => 'int',
72
        'unsigned' => TRUE,
73
        'not null' => TRUE,
74
        'default' => 0,
75
        'description' => 'The time this cache was created or updated.',
76
      ),
77
      'data' => array(
78 f0456308 Assos Assos
        'type' => 'blob',
79 85ad3d82 Assos Assos
        'size' => 'big',
80
        'description' => 'Serialized data being stored.',
81
        'serialize' => TRUE,
82
      ),
83
    ),
84
    'indexes' => array(
85
      'eid' => array('eid'),
86
      'updated' => array('updated'),
87
    ),
88
  );
89
  return $schema;
90
}
91
92
/**
93
 * Implementation of hook_uninstall()
94
 */
95
function views_data_export_uninstall() {
96
  // Clean up any tables we may have left around.
97
  module_load_include('module', 'views_data_export');
98
  views_data_export_garbage_collect(0, -1);
99
}
100
101
/**
102
 * Convert the data column in the object cache.
103
 */
104
function views_data_export_update_7100() {
105
  $new_field = array(
106
    'type' => 'text',
107
    'size' => 'big',
108
    'description' => 'Serialized data being stored.',
109
    'serialize' => TRUE,
110
  );
111
112
  // Drop and re-add this field because there is a bug in
113
  // db_change_field that causes this to fail when trying to cast the data.
114
  db_drop_field('views_data_export_object_cache', 'data');
115
  db_add_field('views_data_export_object_cache', 'data', $new_field);
116
}
117
118
/**
119
 * Increase the length of the view_name field to match views_schema_7301().
120
 */
121
function views_data_export_update_7300() {
122
  $fields = array();
123
124
  $fields['view_name'] = array(
125
    'type' => 'varchar',
126
    'length' => '128',
127
    'default' => '',
128
    'not null' => TRUE,
129
    'description' => 'The unique name of the view. This is the primary field views are loaded from, and is used so that views may be internal and not necessarily in the database. May only be alphanumeric characters plus underscores.',
130
  );
131
132
  $fields['view_display_id'] = array(
133
    'type' => 'varchar',
134
    'length' => '64',
135
    'default' => '',
136
    'not null' => TRUE,
137
    'description' => 'An identifier for this display; usually generated from the display_plugin, so should be something like page or page_1 or block_2, etc.',
138
  );
139
140
  // Apply the updates to the DB.
141
  foreach ($fields as $field_name => $spec) {
142
    db_change_field('views_data_export', $field_name, $field_name, $spec);
143
  }
144
}
145 f0456308 Assos Assos
/**
146
 * Change the object cache table to support postgres installations
147
 */
148
function views_data_export_update_7301(){
149
  $spec = array(
150
        'type' => 'blob',
151
        'size' => 'big',
152
        'description' => 'Serialized data being stored.',
153
        'serialize' => TRUE,
154
      );
155
  db_change_field('views_data_export_object_cache', 'data', 'data', $spec);
156
}
157 85ad3d82 Assos Assos
158
159
/**
160
 * Implements hook_requirements().
161
 */
162
function views_data_export_requirements($phase) {
163
  $requirements = array();
164
165
  // Ensure translations don't break at install time
166
  $t = get_t();
167
168
  switch ($phase) {
169
    case 'runtime':
170
171
      $requirements['views_data_export_temp'] = array(
172
        'title' => t('Views Data Export temporary directory'),
173
        'severity' => REQUIREMENT_OK,
174
        'value' => t('Exists'),
175
      );
176
177
      $path = variable_get('views_data_export_directory', 'temporary://views_plugin_display');
178
      if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
179
        $requirements['views_data_export_temp']['description'] = t('The Views Data Export temporary directory, %path could not be created due to a misconfigured directory. Please ensure that the temporary directory is correctly configured and that the webserver has permission to create directories.', array('%path' => file_uri_target($path)));
180
        $requirements['views_data_export_temp']['severity'] = REQUIREMENT_ERROR;
181
        $requirements['views_data_export_temp']['value'] = t('Unable to create');
182
      }
183
184
      $db_type = Database::getConnection()->databaseType();
185
      switch ($db_type) {
186
        case 'mysql':
187
          // Check the max allowed packet size.
188
          $max_allowed_packet = db_query('SHOW VARIABLES WHERE variable_name = :name', array(':name' => 'max_allowed_packet'))->fetchField(1);
189
          if (is_numeric($max_allowed_packet)) {
190
            if ($max_allowed_packet < (16 * 1024 * 1024)) {
191
              $requirements['views_data_export'] = array(
192
                'title' => $t('MySQL - max allowed packet'),
193
                'value' => format_size($max_allowed_packet),
194
                'description' => $t("Your MySQL 'max_allowed_packet' setting may be too low for Views data export to function correctly, Drupal's requirements recommend setting it to at least 16M. See: !link", array('!link' => l('http://drupal.org/requirements', 'http://drupal.org/requirements'))),
195
                'severity' => REQUIREMENT_WARNING,
196
              );
197
            }
198
          }
199
          break;
200
      }
201
      break;
202
  }
203
204
  return $requirements;
205
}