-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrooms_availability_constraints.install
83 lines (79 loc) · 1.99 KB
/
rooms_availability_constraints.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
<?php
/**
* @file
* Install for Rooms Availability module - sets up the main Rooms Availability
* table.
*/
/**
* Implements hook_field_schema().
*/
function rooms_availability_constraints_field_schema($field) {
if ($field['type'] == 'rooms_availability_constraints_range') {
return array(
'columns' => array(
'start_date' => array(
'type' => 'varchar',
'length' => 10,
'not null' => TRUE,
),
'end_date' => array(
'type' => 'varchar',
'length' => 10,
'not null' => TRUE,
),
'always' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 1,
),
'constraint_type' => array(
'type' => 'varchar',
'length' => 20,
'not null' => TRUE,
),
'start_day' => array(
'type' => 'int',
'not null' => FALSE,
),
'minimum_stay' => array(
'type' => 'int',
'not null' => FALSE,
),
'maximum_stay' => array(
'type' => 'int',
'not null' => FALSE,
),
),
'indexes' => array(
'range' => array(
'start_date',
'end_date',
'minimum_stay',
'maximum_stay'),
'range_day' => array(
'start_date',
'end_date',
'minimum_stay',
'maximum_stay',
'start_day'),
),
);
}
}
/**
* Implements hook_install().
*/
function rooms_availability_constraints_install() {
field_info_cache_clear();
rooms_availability_constraints_add_availability_range_field('rooms_unit_type', 'rooms_unit_type');
}
/**
* Implements hook_uninstall().
*/
function rooms_availability_constraints_uninstall() {
foreach (rooms_unit_get_types() as $type) {
variable_del('rooms_availability_constraints_unit_' . $type->type);
variable_del('rooms_availability_constraints_type_' . $type->type);
}
field_delete_field('rooms_constraints_range');
}