forked from vejlebib/ding_place2book
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ding_place2book.install
123 lines (115 loc) · 3.33 KB
/
ding_place2book.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
<?php
/**
* @file
* Installation file for ding_place2book module.
*/
/**
* Implements hook_schema().
*/
function ding_place2book_schema() {
return array(
'ding_place2book' => array(
'description' => 'Table to hold information about Place2Book tickets.',
'fields' => array(
'nid' => array(
'description' => 'The foreign key to {node}.nid',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'place2book_id' => array(
'description' => 'An ID-reference to the corresponding event on the ticket booking service',
'type' => 'int',
'unsigned' => FALSE,
'not null' => TRUE,
'default' => 0,
),
'capacity' => array(
'description' => 'The maximum capacity on the Place2Book event. 0 is interpreted as unlimited capacity on the event (default)',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'maintain_copy' => array(
'description' => 'Event is created and updated on Place2Book',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1,
),
'kultunaut_export' => array(
'description' => 'Place2Book forwards the event to kultunaut',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'passive' => array(
'description' => 'Event on Place2Book is flagged as passive',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('nid'),
),
);
}
/**
* Implements hook_enable().
*/
function ding_place2book_enable() {
// Create a field on the Event nodetype as a placeholder
// for the order-button/info-area.
// Check if our field is not already created.
if (!field_info_field('field_place2book_tickets')) {
$field = array(
'field_name' => 'field_place2book_tickets',
'type' => 'text',
);
field_create_field($field);
// Create the instance on the bundle.
$instance = array(
'field_name' => 'field_place2book_tickets',
'entity_type' => 'node',
'label' => 'Place2book Tickets',
'bundle' => 'ding_event',
'required' => TRUE,
'default_value' => array(array('value' => '')),
'description' => 'Placeholder for Place2book ticket information and/or order link',
'display' => array(
'default' => array(
'label' => 'hidden',
'settings' => array(),
'weight' => 10,
),
),
);
field_create_instance($instance);
}
}
/**
* Implements hook_disable().
*/
function ding_place2book_disable() {
field_delete_field('field_place2book_tickets');
field_purge_batch(10);
}
/**
* Implements hook_install().
*/
function ding_place2book_install() {
// @todo - Is this viable?
// Update module weight to make it heavier than CCK field groups.
db_query("UPDATE {system} SET weight = 10 WHERE name = 'ding_place2book';");
}
/**
* Implements hook_uninstall().
*/
function ding_place2book_uninstall() {
variable_del('ding_place2book');
variable_del('ding_place2book_libraries');
variable_del('ding_place2book_event_nodes');
}