Project

General

Profile

Download (4.08 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/**
3
 * @file
4
 * Install, update and uninstall functions for the cdm_api module.
5
 */
6

    
7
/**
8
 * Implements hook_schema().
9
 * The drupal_(un)install_schema functions are called automatically in D7.
10
 */
11
function cdm_api_schema() {
12
  $schema['cache_cdm_ws'] = array(
13
    'fields' => array(
14
      'cid' => array(
15
        'description' => 'Primary Key: Unique cache ID.',
16
        'type' => 'varchar',
17
        'length' => '333',
18
        'not null' => TRUE,
19
        'default' => '',
20
      ),
21
      'data' => array(
22
        'description' => 'The data to cache.',
23
        'type' => 'blob',
24
        'size' => 'big',
25
        'not null' => FALSE,
26
      ),
27
      'expire' => array(
28
        'description' => 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.',
29
        'type' => 'int',
30
        'not null' => TRUE,
31
        'default' => 0,
32
        'disp-width' => '11',
33
      ),
34
      'created' => array(
35
        'description' => 'Unix timestamp indicating when the cache entry was created.',
36
        'type' => 'int',
37
        'not null' => TRUE,
38
        'default' => 0,
39
        'disp-width' => '11',
40
      ),
41
      'serialized' => array(
42
        'description' => 'A flag to indicate whether content is serialized by Drupal (1) or not (0).',
43
        'type' => 'int',
44
        'size' => 'small',
45
        'not null' => FALSE,
46
      ),
47
    ),
48
    'primary key' => array('cid'),
49
    'indexes' => array(
50
      'expire' => array('expire'),
51
    ),
52
    // Important, since the 'cid' field is too big to create a key on in INNODB.
53
    // InnoDB allows a max. key length of 767 bytes, MyISAM 1000 bytes, which is
54
    // for utf8 (333*3)+1, so 333 characters max. instead of 255 chars.
55
    'mysql_engine' => 'MyISAM',
56
  );
57

    
58
  // @Comment WA: please describe the fields.
59
  $schema['node_cdm'] = array(
60
    'fields' => array(
61
      'nid' => array(
62
        'type' => 'int',
63
        'not null' => TRUE,
64
        'disp-width' => '11',
65
      ),
66
      'wsuri' => array(
67
        'type' => 'varchar',
68
        'length' => '255',
69
        'not null' => FALSE,
70
      ),
71
      'hash' => array(
72
        'type' => 'char',
73
        'length' => '32',
74
        'not null' => TRUE,
75
      ),
76
      'cdmtype' => array(
77
        'type' => 'varchar',
78
        'length' => '255',
79
        'not null' => FALSE,
80
      ),
81
      'uuid' => array(
82
        'type' => 'varchar',
83
        'length' => '255',
84
        'not null' => TRUE,
85
        'default' => '',
86
      ),
87
    ),
88
    'primary key' => array('hash'),
89
  );
90

    
91
  return $schema;
92
}
93

    
94
/**
95
 * Update D5 cache table to match Drupal 7 cache table columns.
96
 */
97
function cdm_api_update_7000() {
98
  $schema = cdm_api_schema();
99

    
100
  // No need to use db_change_field() here.
101
  // We simply drop and recreate the cache tables to start clean.
102
  db_drop_table('cache_cdm_ws');
103
  db_create_table('cache_cdm_ws', $schema['cache_cdm_ws']);
104
}
105

    
106
/*
107
Comment @WA: fix is obsolete in Drupal 7.
108
function _get_sql_fix_watchdog() {
109
  return "ALTER TABLE {watchdog} CHANGE referer referer TEXT NOT NULL ;";
110
}
111
*/
112

    
113
/**
114
 * Implements hook_requirements().
115
 *
116
 * This hook, like all others dealing with installation and updates, must
117
 * reside in the .install file, or it will not properly abort the installation
118
 * of the module if a critical requirement is missing.
119
 */
120
function cdm_api_requirements() {
121
  // t() Is not yet available in installation phase, so we use get_t instead.
122
  $t = get_t();
123
  $requirements['cdm_api'] = array(
124
    'title' => $t('CDM API'),
125
  );
126

    
127
  if (function_exists('curl_init')) {
128
    // Description below title is not yet in use.
129
    $requirements['cdm_api']['description'] = '';
130
    $requirements['cdm_api']['value'] = $t('
131
      CURL php extension is available and will be used by the CDM API.
132
      HTTP requests thus will be up to 20x faster.'
133
    );
134
  }
135
  else {
136
    $requirements['cdm_api']['value'] = $t('CURL php extension is missing. If
137
      CURL lib is installed HTTP requests will be up to 20x faster.');
138
  }
139

    
140
  // FIXME: once _get_content_fsockopen is implemented change severity to
141
  // REQUIREMENT_WARNING.
142
  $requirements['cdm_api']['severity'] = (function_exists('curl_init') ? REQUIREMENT_OK : REQUIREMENT_INFO);
143

    
144
  return $requirements;
145
}
(3-3/9)