Projet

Général

Profil

Paste
Télécharger (3,8 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / makemeeting / makemeeting.install @ b75b6b8b

1
<?php
2

    
3
/**
4
 * @file
5
 * Makemeeting installation schemas
6
 */
7

    
8
/**
9
 * Implements hook_field_schema().
10
 */
11
function makemeeting_field_schema($field) {
12
  return array(
13
    'columns' => array(
14
      'closed' => array(
15
        'type' => 'int',
16
        'length' => 1,
17
        'not null' => FALSE,
18
        'default' => 0,
19
      ),
20
      'hidden' => array(
21
        'type' => 'int',
22
        'length' => 1,
23
        'not null' => FALSE,
24
        'default' => 0,
25
      ),
26
      'one_option' => array(
27
        'type' => 'int',
28
        'length' => 1,
29
        'not null' => FALSE,
30
        'default' => 0,
31
      ),
32
      'limit' => array(
33
        'type' => 'int',
34
        'not null' => FALSE,
35
        'default' => 0,
36
      ),
37
      'yesnomaybe' => array(
38
        'type' => 'int',
39
        'length' => 1,
40
        'not null' => FALSE,
41
        'default' => 0,
42
      ),
43
      'choices' => array(
44
        'type' => 'blob',
45
        'not null' => FALSE,
46
        'size' => 'big',
47
        'serialize' => TRUE,
48
      ),
49
    ),
50
  );
51
}
52

    
53
/**
54
 * Implements hook_schema().
55
 */
56
function makemeeting_schema() {
57
  $schema['makemeeting_answers'] = array(
58
    'description' => 'The choices by the visitors.',
59
    'fields' => array(
60
      'answer_id' => array(
61
        'type' => 'serial',
62
        'unsigned' => TRUE,
63
        'not null' => TRUE,
64
      ),
65
      'field_name' => array(
66
        'type' => 'varchar',
67
        'length' => 32,
68
        'not null' => TRUE,
69
        'description' => 'The name of the field this data is attached to',
70
      ),
71
      'entity_type' => array(
72
        'type' => 'varchar',
73
        'length' => 128,
74
        'not null' => TRUE,
75
        'default' => '',
76
        'description' => 'The entity type this data is attached to',
77
      ),
78
      'deleted' => array(
79
        'type' => 'int',
80
        'size' => 'tiny',
81
        'not null' => TRUE,
82
        'default' => 0,
83
        'description' => 'A boolean indicating whether this data item has been deleted'
84
      ),
85
      'entity_id' => array(
86
        'type' => 'int',
87
        'unsigned' => TRUE,
88
        'not null' => TRUE,
89
        'description' => 'The entity id this data is attached to',
90
      ),
91
      'language' => array(
92
        'type' => 'varchar',
93
        'length' => 32,
94
        'not null' => TRUE,
95
        'default' => '',
96
        'description' => 'The language for this data item.',
97
      ),
98
      'delta' => array(
99
        'type' => 'int',
100
        'unsigned' => TRUE,
101
        'not null' => TRUE,
102
        'description' => 'The sequence number for this data item, used for multi-value fields',
103
      ),
104
      'value' => array(
105
        'type' => 'text',
106
        'serialize' => TRUE,
107
      ),
108
      'uid' => array(
109
        'type' => 'int',
110
        'unsigned' => TRUE,
111
        'not null' => TRUE,
112
        'default' => 0,
113
      ),
114
      'name' => array(
115
        'type' => 'varchar',
116
        'length' => 255,
117
      ),
118
      'mail' => array(
119
        'type' => 'varchar',
120
        'length' => 255,
121
      ),
122
      'notification' => array(
123
        'type' => 'int',
124
        'not null' => TRUE,
125
        'length' => 1,
126
        'default' => 0,
127
      ),
128
    ),
129
    'primary key' => array('answer_id'),
130
  );
131
  return $schema;
132
}
133

    
134
/**
135
 * Add yesnomaybe column to field tables
136
 */
137
function makemeeting_update_7201() {
138
  $results = db_select('field_config', 'fc')
139
             ->fields('fc')
140
             ->condition('type', 'makemeeting')
141
             ->execute()
142
             ->fetchAll();
143
  foreach ($results as $field) {
144
    foreach (array('data', 'revision') as $type) {
145
      $table = "field_{$type}_{$field->field_name}";
146
      $column = "{$field->field_name}_yesnomaybe";
147
      // Data and revision tables need to be fixed
148
      if (!db_field_exists($table, $column)) {
149
        db_add_field($table, $column, array(
150
          'type' => 'int',
151
          'length' => 1,
152
          'not null' => FALSE,
153
          'default' => 0,
154
        ));
155
      }
156
    }
157
  }
158
}