source: sipes/modules_contrib/views_data_export/views_data_export.install @ c43ea01

stableversion-3.0
Last change on this file since c43ea01 was e1332eb, checked in by lhernandez <lhernandez@…>, 8 años ago

se agrego el modulo para exportar los datos

  • Propiedad mode establecida a 100644
File size: 4.8 KB
Línea 
1<?php
2
3/**
4 * Implementation of hook_schema()
5 */
6function 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' => '32',
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' => '32',
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' => 'text',
54        'not null' => TRUE,
55        'serialize' => TRUE,
56      ),
57    ),
58    'primary key' => array('eid'),
59  );
60
61  $schema['views_data_export_object_cache'] = array(
62    'description' => 'A modified version of the views_object_cache that ignores session id.',
63    'fields' => array(
64      'eid' => array(
65        'type' => 'varchar',
66        'length' => '64',
67        'description' => 'The export ID this view equates too.',
68      ),
69      'updated' => array(
70        'type' => 'int',
71        'unsigned' => TRUE,
72        'not null' => TRUE,
73        'default' => 0,
74        'description' => 'The time this cache was created or updated.',
75      ),
76      'data' => array(
77        'type' => 'text',
78        'size' => 'big',
79        'description' => 'Serialized data being stored.',
80        'serialize' => TRUE,
81      ),
82    ),
83    'indexes' => array(
84      'eid' => array('eid'),
85      'updated' => array('updated'),
86    ),
87  );
88  return $schema;
89}
90
91
92/**
93 * Implementation of hook_install()
94 */
95function views_data_export_install() {
96  drupal_install_schema('views_data_export');
97}
98
99
100/**
101 * Implementation of hook_uninstall()
102 */
103function views_data_export_uninstall() {
104
105  //Clean up any tables we may have left around
106  views_data_export_garbage_collect(0, -1);
107
108  //Remove our base table
109  drupal_uninstall_schema('views_data_export');
110}
111
112/**
113 * Convert the data column in the object cache.
114 */
115function views_data_export_update_6200() {
116  $ret = array();
117 
118  $new_field = array(
119    'type' => 'text',
120    'size' => 'big',
121    'description' => 'Serialized data being stored.',
122    'serialize' => TRUE,
123  );
124
125  // Drop and re-add this field because there is a bug in
126  // db_change_field that causes this to fail when trying to cast the data.
127  db_drop_field($ret, 'views_data_export_object_cache', 'data');
128  db_add_field($ret, 'views_data_export_object_cache', 'data', $new_field);
129
130  return $ret;
131}
132
133/**
134 * Implements hook_requirements().
135 */
136function views_data_export_requirements($phase) {
137  global $db_type;
138  $requirements = array();
139
140  // Ensure translations don't break at install time
141  $t = get_t();
142
143  switch ($phase) {
144    case 'runtime':
145
146      switch ($db_type) {
147        case 'mysql':
148        case 'mysqli':
149          // Check the max allowed packet size.
150          $max_allowed_packet = db_result(db_query("SHOW VARIABLES WHERE variable_name = '%s'", array('max_allowed_packet')));
151          if (is_numeric($max_allowed_packet)) {
152            if ($max_allowed_packet < (16 * 1024 * 1024)) {
153              $requirements['views_data_export'] = array(
154                'title' => $t('MySQL - max allowed packet'),
155                'value' => format_size($max_allowed_packet),
156                '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'))),
157                'severity' => REQUIREMENT_WARNING,
158              );
159            }
160          }
161          break;
162      }
163      break;
164  }
165
166  return $requirements;
167}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.