-
Notifications
You must be signed in to change notification settings - Fork 1
/
repeating_dates.install
70 lines (66 loc) · 1.76 KB
/
repeating_dates.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
<?php
/**
* @file
* Install, update and uninstall functions.
*/
/**
* Implements hook_field_schema().
*/
function repeating_dates_field_schema($field) {
$db_columns = array();
$db_columns['dtstart'] = array(
'type' => 'int',
'size' => 'big',
'not null' => FALSE,
'description' => 'The start date of the range',
);
$db_columns['dtend'] = array(
'type' => 'int',
'size' => 'big',
'not null' => FALSE,
'description' => 'The end date of the range',
);
$db_columns['rrule'] = array(
'type' => 'text',
'not null' => FALSE,
'description' => 'The ical rules for recurrences',
);
return array('columns' => $db_columns);
}
/**
* Update dtstart and dtend table field schema for bigger values.
*/
function repeating_dates_update_1000() {
$config_names = config_get_names_with_prefix('field.instance');
$rd_field_names = array();
foreach ($config_names as $name) {
$config = config($name);
if ($config->get('widget.module') == 'repeating_dates') {
$rd_field_names[] = $config->get('field_name');
}
}
$start_spec = array(
'type' => 'int',
'size' => 'big',
'not null' => FALSE,
'description' => 'The start date of the range',
);
$end_spec = array(
'type' => 'int',
'size' => 'big',
'not null' => FALSE,
'description' => 'The end date of the range',
);
foreach ($rd_field_names as $field_name) {
$table_names = array(
"field_data_$field_name",
"field_revision_$field_name",
);
foreach ($table_names as $table_name) {
$start_col = $field_name . '_dtstart';
db_change_field($table_name, $start_col, $start_col, $start_spec);
$end_col = $field_name . '_dtend';
db_change_field($table_name, $end_col, $end_col, $end_spec);
}
}
}