-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathunccd_event_map.install
203 lines (194 loc) · 6.46 KB
/
unccd_event_map.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
<?php
use Drupal\Core\Database\Database;
/**
* @file
* Install, update and uninstall functions for the unccd_event_map module.
*/
/**
* Implements hook_install().
*
* Creates a default entry on this module custom table.
*
* @ingroup unccd_event_map
*/
function unccd_event_map_install() {
$database = \Drupal::database();
// Add a default entry.
$fields = [
'title' => 'Celebration of the World Day to Combat Desertification',
'organisation' => 'Desert Research Center',
'email' => '[email protected]',
'url' => '',
'city' => 'Mataria',
'country' => 'Egypt',
'date' => '2018-06-17',
'description' => 'Desert Research Center plans to celebrate the World Day at the end of June after the feast of Aid El-Fitr. The details of the observance activities are being finalized.',
'latitude' => 30.1312,
'longitude' => 31.3103,
'approved' => 1,
];
$database
->insert('unccd_event_map')
->fields($fields)
->execute();
}
/**
* Implements hook_schema().
*
* Defines the database tables used by this module.
*
* @see hook_schema()
*
* @ingroup unccd_event_map
*/
function unccd_event_map_schema() {
$schema['unccd_event_map'] = [
'description' => 'Stores events for the event map',
'fields' => [
'id' => [
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique event ID.',
],
'title' => [
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Title of the event',
],
'organisation' => [
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Organisation running the event',
],
'organisation_url' => [
'type' => 'varchar',
'length' => 255,
'description' => 'URL of the event organizer(s)',
],
'url' => [
'type' => 'varchar',
'length' => 255,
'default' => '',
'description' => 'URL of the event on an external website',
],
'email' => [
'type' => 'varchar',
'length' => 255,
'default' => '',
'description' => 'Email of the contact person',
],
'city' => [
'type' => 'varchar',
'length' => 255,
'description' => 'City where the event takes place.',
],
'country' => [
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'description' => 'Country where the event takes place.',
],
'date' => [
'type' => 'datetime',
'mysql_type' => 'datetime',
'pgsql_type' => 'timestamp without time zone',
'sqlite_type' => 'varchar',
'sqlsrv_type' => 'smalldatetime',
'not null' => TRUE,
'description' => 'Date the event takes place on.',
],
'description' => [
'type' => 'text',
'not null' => TRUE,
'description' => 'Description of the event',
],
'latitude' => [
'type' => 'float',
'not_null' => TRUE,
'description' => 'The latitude of the location of the event (for map display)'
],
'longitude' => [
'type' => 'float',
'not_null' => TRUE,
'description' => 'The longitude of the location of the event (for map display)'
],
'approved' => [
'type' => 'int',
'size' => 'tiny',
'not_null' => TRUE,
'default' => 0,
'description' => 'Has the event been approved'
],
'image_id' => [
'type' => 'int',
'description' => 'The drupal file id for the uploaded image (needed to delete image when event is deleted)'
],
'image' => [
'type' => 'varchar',
'length' => 255,
'description' => 'Image for the event'
],
'attachment_type' => [
'type' => 'varchar',
'length' => 255,
'default' => 'Event Flyer',
'description' => 'The type of PDF attached (report, flyer, etc)'
],
'pdf_id' => [
'type' => 'int',
'description' => 'The drupal file id for the uploaded PDF (needed to delete PDF when event is deleted)'
],
'pdf' => [
'type' => 'varchar',
'length' => 255,
'description' => 'PDF for the event'
],
],
'primary key' => ['id'],
'indexes' => [
'title' => ['title'],
'country' => ['country'],
],
];
return $schema;
}
/**
* Adds the column for PDF upload and organisation url
*/
function unccd_event_map_update_8001(&$sandbox) {
$pdf_id_spec = [
'type' => 'int',
'description' => 'The drupal file id for the uploaded PDF (needed to delete PDF when event is deleted)'
];
$pdf_spec = [
'type' => 'varchar',
'length' => 255,
'description' => 'PDF for the event'
];
$organisation_url_spec = [
'type' => 'varchar',
'length' => 255,
'description' => 'URL of the event organizer(s)',
];
$schema = Database::getConnection()->schema();
$schema->addField('unccd_event_map', 'pdf_id', $pdf_id_spec);
$schema->addField('unccd_event_map', 'pdf', $pdf_spec);
$schema->addField('unccd_event_map', 'organisation_url', $organisation_url_spec);
}
/**
* Adds the column for attachment types
*/
function unccd_event_map_update_8002(&$sandbox) {
$attachment_type_spec = [
'type' => 'varchar',
'length' => 255,
'default' => 'Event Flyer',
'description' => 'The type of PDF attached (report, flyer, etc)'
];
$schema = Database::getConnection()->schema();
$schema->addField('unccd_event_map', 'attachment_type', $attachment_type_spec);
}