-
Notifications
You must be signed in to change notification settings - Fork 0
/
funi_video.install
226 lines (214 loc) · 6.96 KB
/
funi_video.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<?php
// $Id$
/**
* Implementation of hook_install().
*/
function funi_video_install() {
// Create table
$created = drupal_install_schema('funi_video');
if ($created) {
drupal_set_message(t('Funi Video module installed successfully. You must set <a href="/admin/user/permissions#module-funi_video">permissions</a> and <a href="/admin/build/funi_video">configure</a> the module. '));
}
else {
drupal_set_message(t('Table installation for the Funi Video module was unsuccessful. The tables may need to be installed by hand. See funi_video.install file for a list of the installation queries.'), 'error');
}
return;
}
/**
* Implementation of hook_uninstall().
*/
function funi_video_uninstall() {
// Remove variables
db_query('DELETE FROM {variable} WHERE name LIKE "funi_video_%"');
// Remove table
$deleted = drupal_uninstall_schema('funi_video');
if ($deleted) {
drupal_set_message(t('Funi Video module has been uninstalled successfully.'));
}
else {
drupal_set_message(t('Table removal for the Funi Video module was unsuccessful. The tables may need to be uninstalled by hand. See funi_video.install file for a list of the uninstall queries.'), 'error');
}
return;
}
/**
* Implementation of hook_schema() - borrowed from the views installer.
*
* Generate the current version of the database schema from
* the sequence of schema update functions. Uses a similar
* method to install.inc's drupal_get_schema_versions() to
* establish the update sequence.
*
* To change the schema, add a new funi_video_schema_N()
* function to match the associated funi_video_update_N()
*
* @param $caller_function
* The name of the function that called us.
* Used internally, if requesting a specific schema version.
*/
function funi_video_schema() {
$schema['funivideo_videos'] = array(
'description' => t('Stores video activity information.'),
'fields' => array(
'nid' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Show node ID.',
),
'show_name' => array(
'description' => 'The show name.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'node_type' => array(
'description' => 'Node type',
'type' => 'varchar',
'length' => 80,
'not null' => TRUE,
),
'quality' => array(
'description' => t('Video quality'),
'type' => 'varchar',
'not null' => FALSE,
'length' => 255,
),
'fs_sunrise' => array(
'description' => 'Free streaming sunrise.', 'type' => 'int', 'length' => 11, 'not null' => FALSE,
),
'fs_sunset' => array(
'description' => 'Free streaming sunset.', 'type' => 'int', 'length' => 11, 'not null' => FALSE,
),
'sub_sunrise' => array(
'description' => 'Subscription sunrise.', 'type' => 'int', 'length' => 11, 'not null' => FALSE,
),
'sub_sunset' => array(
'description' => 'Subscription sunset.', 'type' => 'int', 'length' => 11, 'not null' => FALSE,
),
'active_state' => array(
'description' => 'Active state',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
),
'exclusive_active' => array(
'description' => 'If active and exclusive (subscription)',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
),
'hulu_active' => array(
'description' => 'If Hulu sunrise is active and id exists',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
),
'next_sunrise' => array(
'description' => 'free streaming sunrise OR subscription sunrise WHICHEVER is next ) - this is for recent sorting in Views',
'type' => 'int', 'length' => 11, 'not null' => TRUE,
),
'last_check' => array(
'description' => 'time of the last check on this videos active status',
'type' => 'int', 'length' => 11, 'not null' => TRUE,
),
'next_check' => array(
'description' => 'time that this video should be checked next (based on whichever sunrise/sunset is coming up next)',
'type' => 'int', 'length' => 11, 'not null' => TRUE,
),
),
'indexes' => array(
'show_name' => array('show_name'),
'type' => array('node_type'),
'active_state' => array('active_state'),
'next_sunrise' => array('next_sunrise'),
'next_check' => array('next_check'),
),
'foreign keys' => array(
'node_video' => array(
'table' => 'node_revision',
'columns' => array('nid' => 'nid'),
),
),
'primary key' => array('nid'),
);
$schema['funivideo_shows'] = array(
'description' => t('Stores show activity information.'),
'fields' => array(
'nid' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Show node ID.',
),
'needs_update' => array(
'description' => 'Needs update',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
),
'has_videos' => array(
'description' => 'Has videos',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
),
'most_recent_video' => array(
'description' => 'Most recent video', 'type' => 'int', 'length' => 11, 'not null' => TRUE,
),
'has_episodes' => array(
'description' => 'Has episodes',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
),
'most_recent_episode' => array(
'description' => 'Most recent episode', 'type' => 'int', 'length' => 11, 'not null' => TRUE,
),
'has_subscription' => array(
'description' => 'Has subscription',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
),
'subscription_exclusive' => array(
'description' => 'Subscription exclusive',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
),
'has_hd' => array(
'description' => 'Has hd',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
),
'video_types' => array(
'description' => t('Video types'),
'type' => 'varchar',
'not null' => FALSE,
'length' => 255,
),
),
'indexes' => array(
'needs_update' => array('needs_update'),
'has' => array('has_videos','has_episodes','has_subscription', 'has_hd'),
'most_recent' => array('most_recent_video','most_recent_episode'),
'sub_exclusive' => array('subscription_exclusive'),
),
'foreign keys' => array(
'node_show' => array(
'table' => 'og',
'columns' => array('nid' => 'nid'),
),
),
'primary key' => array('nid'),
);
return $schema;
}