Projet

Général

Profil

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

root / drupal7 / sites / all / modules / views_data_export / views_data_export.install @ 74f6bef0

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
        'type' => 'text',
79
        '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
146
147
148
/**
149
 * Implements hook_requirements().
150
 */
151
function views_data_export_requirements($phase) {
152
  $requirements = array();
153
154
  // Ensure translations don't break at install time
155
  $t = get_t();
156
157
  switch ($phase) {
158
    case 'runtime':
159
160
      $requirements['views_data_export_temp'] = array(
161
        'title' => t('Views Data Export temporary directory'),
162
        'severity' => REQUIREMENT_OK,
163
        'value' => t('Exists'),
164
      );
165
166
      $path = variable_get('views_data_export_directory', 'temporary://views_plugin_display');
167
      if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
168
        $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)));
169
        $requirements['views_data_export_temp']['severity'] = REQUIREMENT_ERROR;
170
        $requirements['views_data_export_temp']['value'] = t('Unable to create');
171
      }
172
173
      $db_type = Database::getConnection()->databaseType();
174
      switch ($db_type) {
175
        case 'mysql':
176
          // Check the max allowed packet size.
177
          $max_allowed_packet = db_query('SHOW VARIABLES WHERE variable_name = :name', array(':name' => 'max_allowed_packet'))->fetchField(1);
178
          if (is_numeric($max_allowed_packet)) {
179
            if ($max_allowed_packet < (16 * 1024 * 1024)) {
180
              $requirements['views_data_export'] = array(
181
                'title' => $t('MySQL - max allowed packet'),
182
                'value' => format_size($max_allowed_packet),
183
                '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'))),
184
                'severity' => REQUIREMENT_WARNING,
185
              );
186
            }
187
          }
188
          break;
189
      }
190
      break;
191
  }
192
193
  return $requirements;
194
}