This repository has been archived by the owner on Mar 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conferenceBookings.php
executable file
·473 lines (405 loc) · 18.8 KB
/
conferenceBookings.php
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
<?php
# Class to create a conference bookings system
class conferenceBookings extends frontControllerApplication
{
# Function to assign defaults additional to the general application defaults
public function defaults ()
{
# Specify available arguments as defaults or as NULL (to represent a required argument)
$defaults = array (
'applicationName' => 'Conference bookings',
'div' => strtolower (__CLASS__),
'database' => 'conferencebookings',
'table' => 'conference',
'databaseStrictWhere' => true,
'administrators' => true,
'useEditing' => true,
'useSettings' => true,
'internalAuth' => true,
'authentication' => true, // All pages require login
'settingsTableExplodeTextarea' => array ('sessions', 'projects'),
'useCamUniLookup' => false,
);
# Return the defaults
return $defaults;
}
# Function assign additional actions
public function actions ()
{
# Specify additional actions
$actions = array (
'home' => array (
'description' => false,
'url' => '',
'tab' => 'Home',
'icon' => 'house',
),
'conference' => array (
'description' => 'Register for the conference',
'url' => 'conference/',
'tab' => 'Conference registration',
'form' => true,
),
'presentations' => array (
'description' => 'Apply to give a presentation',
'url' => 'presentations/',
'tab' => 'Presentation application',
'form' => true,
),
'posters' => array (
'description' => 'Apply to present a poster',
'url' => 'posters/',
'tab' => 'Poster application',
'form' => true,
),
'fieldweek' => array (
'description' => 'Register for the fieldweek',
'url' => 'fieldweek/',
'tab' => 'Fieldweek registration',
'form' => true,
),
'vendor' => array (
'description' => 'Register as a vendor',
'url' => 'vendor/',
'tab' => 'Vendor registration',
'form' => true,
),
'edit' => array (
'description' => false,
'url' => '%1/edit.html',
'usetab' => 'home',
'authentication' => true,
),
);
# Return the actions
return $actions;
}
# Database structure definition
public function databaseStructure ()
{
return "
CREATE TABLE `administrators` (
`username` varchar(255 NOT NULL PRIMARY KEY COMMENT 'Username',
`active` enum('','Yes','No' NOT NULL DEFAULT 'Yes' COMMENT 'Currently active?'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='System administrators';
CREATE TABLE `settings` (
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'Automatic key (ignored)',
`feedbackRecipient` VARCHAR(255) NOT NULL COMMENT 'Recipient e-mail',
`conferenceIntroduction` TEXT COMMENT 'Conference page introduction',
`presentationsIntroduction` TEXT COMMENT 'Presentations page introduction',
`postersIntroduction` TEXT COMMENT 'Posters page introduction',
`fieldweekIntroduction` TEXT COMMENT 'Fieldweek page introduction',
`vendorIntroduction` TEXT COMMENT 'Vendor page introduction',
`sessions` TEXT NOT NULL COMMENT 'Sessions',
`projects` TEXT NOT NULL COMMENT 'Projects',
`conferenceConfirmationMailIntroduction` TEXT NULL COMMENT 'Introduction text for conference e-mail'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Settings';
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'Automatic key',
`email` varchar(191 NOT NULL COMMENT 'Your e-mail address' UNIQUE KEY,
`password` varchar(255 NOT NULL COMMENT 'Password',
`validationToken` varchar(255 DEFAULT NULL COMMENT 'Token for validation or password reset',
`lastLoggedInAt` datetime DEFAULT NULL COMMENT 'Last logged in time',
`validatedAt` datetime DEFAULT NULL COMMENT 'Time when validated',
`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Timestamp'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Users';
CREATE TABLE `conference` (
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'Automatic key',
`title` enum('Dr','Mr','Ms','Miss','Mrs','Mx','Prof','Sir' NOT NULL COMMENT 'Title',
`forename` varchar(255 NOT NULL COMMENT 'Forename',
`surname` varchar(255 NOT NULL COMMENT 'Surname',
`address` text NOT NULL COMMENT 'Address, including postal code',
`country` varchar(255 NOT NULL COMMENT 'Country',
`email` varchar(255 NOT NULL COMMENT 'E-mail',
`participantType` enum('Presenter','Participant (non-student)','Student participant','Vendor representative' NOT NULL COMMENT 'Registering as',
`membership` enum('Member','None' NOT NULL COMMENT 'Professional membership',
`userId` INT(11) NOT NULL UNIQUE KEY COMMENT 'User ID',
`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Automatic timestamp'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Conference applications';
CREATE TABLE `fieldweek` (
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'Automatic key',
`title` enum('Dr','Mr','Ms','Miss','Mrs','Mx','Prof','Sir' NOT NULL COMMENT 'Title',
`forename` varchar(255 NOT NULL COMMENT 'Forename',
`surname` varchar(255 NOT NULL COMMENT 'Surname',
`address` text NOT NULL COMMENT 'Address, including postal code',
`country` varchar(255 NOT NULL COMMENT 'Country',
`email` varchar(255 NOT NULL COMMENT 'E-mail',
`position` enum('Academic','Student','Research','Other' NOT NULL COMMENT 'Position',
`membership` enum('Member','None' NOT NULL COMMENT 'Professional membership',
`project1` varchar(255 NOT NULL COMMENT 'Project - 1st choice',
`project2` varchar(255 NOT NULL COMMENT '2nd choice',
`project3` varchar(255 NOT NULL COMMENT '3rd choice',
`project4` varchar(255 DEFAULT NULL COMMENT '4th choice',
`project5` varchar(255 DEFAULT NULL COMMENT '5th choice',
`statement` text NOT NULL COMMENT 'Applicant statement',
`dietaryRequirements` enum('No particular requirements','Vegetarian','Vegan','Gluten-free','Other:' NOT NULL COMMENT 'Dietary requirements',
`dietaryDetails` varchar(255 DEFAULT NULL COMMENT 'Other (dietary request)',
`medical` text COMMENT 'Physical/medical concerns',
`userId` INT(11) NOT NULL UNIQUE KEY COMMENT 'User ID',
`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Automatic timestamp'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Conference applications';
CREATE TABLE `presentations` (
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'Automatic key',
`type` enum('Oral','Poster' NOT NULL COMMENT 'Type of presentation',
`session` varchar(255 NOT NULL COMMENT 'Session',
`title` varchar(255 NOT NULL COMMENT 'Title',
`name` varchar(255 NOT NULL COMMENT 'Presenter''s name',
`email` VARCHAR(255) NOT NULL COMMENT 'Presenter\'s e-mail',
`authors` text NOT NULL COMMENT 'Author(s), one per line',
`abstract` text NOT NULL COMMENT 'Abstract',
`status` ENUM('Submitted','In review','Accepted','Rejected') NOT NULL DEFAULT 'Submitted' COMMENT 'Status',
`review` TEXT NULL COMMENT 'Reviewer comments',
`userId` INT(11) NOT NULL COMMENT 'User ID',
`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Automatic timestamp',
UNIQUE `typeUserId` (`type`, `userId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Presentation (oral/poster) applications';
CREATE TABLE `vendor` (
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'Automatic key',
`company` varchar(255 NOT NULL COMMENT 'Company name',
`title` enum('Dr','Mr','Ms','Miss','Mrs','Mx','Prof','Sir' NOT NULL COMMENT 'Title',
`forename` varchar(255 NOT NULL COMMENT 'Forename',
`surname` varchar(255 NOT NULL COMMENT 'Surname',
`address` text NOT NULL COMMENT 'Address, including postal code',
`country` varchar(255 NOT NULL COMMENT 'Country',
`email` varchar(255 NOT NULL COMMENT 'E-mail',
`website` varchar(255 NOT NULL COMMENT 'Company website',
`description` text NOT NULL COMMENT 'Vendor description',
`userId` INT(11) NOT NULL UNIQUE KEY COMMENT 'User ID',
`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Automatic timestamp'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Conference applications';
";
}
# Additional initialisation
public function main ()
{
# Set internal fields
$this->internalFields = array ('id', 'status', 'review', 'userId', 'createdAt');
}
# Welcome screen
public function home ()
{
# Start the HTML
$html = "\n<p><strong>Welcome to the conference booking system.</strong></p>";
# Create a list of forms
$list = array ();
foreach ($this->actions as $actionId => $action) {
if (isSet ($action['form']) && $action['form']) {
$list[$actionId] = "<a href=\"{$this->baseUrl}/{$actionId}/\">" . htmlspecialchars ($action['description']) . '</a>';
}
}
$html .= "\n<p>Please select the relevant form:</p>";
$html .= application::htmlUl ($list, 0, 'boxylist');
# Show the HTML
echo $html;
}
# Conference registration
public function conference ()
{
# Delegate to the form
echo $html = $this->createForm (__FUNCTION__);
}
# Presentation application
public function presentations ()
{
# Delegate to the form
echo $html = $this->createForm (__FUNCTION__);
}
# Poster application
public function posters ()
{
# Delegate to the form
echo $html = $this->createForm (__FUNCTION__, 'presentations');
}
# Fieldweek registration
public function fieldweek ()
{
# Delegate to the form
echo $html = $this->createForm (__FUNCTION__);
}
# Vendor registration
public function vendor ()
{
# Delegate to the form
echo $html = $this->createForm (__FUNCTION__);
}
# Form
private function createForm ($action, $forceTable = false)
{
# Start the HTML
$html = '';
# Determine the table to use
$table = $action;
if ($forceTable) {
$table = $forceTable;
}
# Determine any prefix to the e-mail
$confirmationEmailIntroductoryText = false;
if ($action == 'conference') {
if ($this->settings['conferenceConfirmationMailIntroduction']) {
$confirmationEmailIntroductoryText = $this->settings['conferenceConfirmationMailIntroduction'];
}
}
# Show the user's submission if they have already made one
if ($submission = $this->getDisplayableSubmissionOfUser ($this->user, $table, $action, $headings /* returned by reference */)) {
# Show the submission
$html = "\n<p>You have submitted the following details:</p>";
$html .= application::htmlTableKeyed ($submission, $headings, true, 'lines', false, true, $addRowKeyClasses = true);
$html .= "\n<p class=\"comment\">Please contact us via the <a href=\"{$this->baseUrl}/feedback.html\">feedback page</a> if any of these details are incorrect.</p>";
# Return the HTML
return $html;
}
# Get the dataBinding attributes for each table
$dataBindingAttributesByAction = $this->formDataBindingAttributes ();
# Create a new form
$form = new form (array (
'div' => 'ultimateform horizontalonly',
'displayRestrictions' => false,
'nullText' => '',
'formCompleteText' => $this->tick . ' Thank you for your submission. We will be in touch in due course.',
'autofocus' => true,
'databaseConnection' => $this->databaseConnection,
'unsavedDataProtection' => true,
'picker' => true,
'cols' => 60,
'ip' => false,
'user' => $this->userVisibleIdentifier,
'confirmationEmailIntroductoryText' => $confirmationEmailIntroductoryText,
));
if ($this->settings["{$action}Introduction"]) {
$introductionHtml = application::formatTextBlock (application::makeClickableLinks ($this->settings["{$action}Introduction"]));
$introductionHtml = "\n<div class=\"graybox\">" . $introductionHtml . "\n</div>";
$form->heading ('', $introductionHtml);
}
$form->dataBinding (array (
'database' => $this->settings['database'],
'table' => $table,
'intelligence' => true,
'exclude' => $this->internalFields,
'attributes' => $dataBindingAttributesByAction[$action],
));
# For the projects, enforce uniqueness
if ($table == 'fieldweek') {
$form->validation ('different', array ('project1', 'project2', 'project3', 'project4', 'project5'));
}
# Set output to e-mail, confirmation e-mail, and screen
$form->setOutputEmail ($this->settings['feedbackRecipient'], $this->settings['administratorEmail'], "{$this->settings['applicationName']}: {$this->actions[$action]['description']}");
$form->setOutputConfirmationEmail ('email', $this->settings['administratorEmail'], "{$this->settings['applicationName']}: {$this->actions[$action]['description']}", $includeAbuseNotice = false);
$form->setOutputScreen ();
# Process the form
if ($result = $form->process ($html)) {
# Inject the user ID
$result['userId'] = $this->user;
# Insert into the database
if (!$this->databaseConnection->insert ($this->settings['database'], $table, $result)) {
echo "\n<p class=\"warning\">There was a problem inserting the data.</p>";
application::dumpData ($this->databaseConnection->error ());
}
}
# Return the HTML
return $html;
}
# Function to get the submission of a user for display to the user
private function getDisplayableSubmissionOfUser ($userId, $table, $action, &$headings = array ())
{
# Set constraints
$constraints = array ('userId' => $this->user);
# For the hybrid presentations/poster table, set additional constraint
if ($table == 'presentations') {
$typeConstraints = array (
'presentations' => 'Oral',
'posters' => 'Poster',
);
$constraints['type'] = $typeConstraints[$action];
}
# Get the data
$data = $this->databaseConnection->selectOne ($this->settings['database'], $table, $constraints);
# Exclude internal fields
$visiblePrivateFields = array ('status'); // Allow status
$internalFields = array_diff ($this->internalFields, $visiblePrivateFields);
foreach ($internalFields as $field) {
unset ($data[$field]);
}
# Obtain headings
$headings = $this->databaseConnection->getHeadings ($this->settings['database'], $table);
# Return the data
return $data;
}
# Helper function to define the dataBinding attributes
private function formDataBindingAttributes ()
{
# Get the countries
$countries = form::getCountries ();
# Define the properties, by table
$dataBindingAttributes = array (
'conference' => array (
'email' => array ('default' => $this->userVisibleIdentifier, 'editable' => false, ),
'country' => array ('type' => 'select', 'values' => $countries, ),
'participantType' => array ('type' => 'radiobuttons', ),
'membership' => array ('type' => 'radiobuttons', ),
),
'presentations' => array (
'type' => array ('type' => 'radiobuttons', 'default' => 'Oral', 'editable' => false, ),
'session' => array ('type' => 'radiobuttons', 'values' => $this->settings['sessions'], ),
'email' => array ('default' => $this->userVisibleIdentifier, 'editable' => false, ),
'abstract' => array ('description' => 'If you would like to request some special audio or visual aids for this presentation, use this filed to inform us.'),
),
'posters' => array (
'type' => array ('type' => 'radiobuttons', 'default' => 'Poster', 'editable' => false, ),
'session' => array ('type' => 'radiobuttons', 'values' => $this->settings['sessions'], ),
'email' => array ('default' => $this->userVisibleIdentifier, 'editable' => false, ),
),
'fieldweek' => array (
'country' => array ('type' => 'select', 'values' => $countries, ),
'email' => array ('default' => $this->userVisibleIdentifier, 'editable' => false, ),
'position' => array ('type' => 'radiobuttons', ),
'membership' => array ('type' => 'radiobuttons', ),
'project1' => array ('type' => 'select', 'values' => $this->settings['projects'], 'heading' => array (3 => 'Project choice'), ),
'project2' => array ('type' => 'select', 'values' => $this->settings['projects'], ),
'project3' => array ('type' => 'select', 'values' => $this->settings['projects'], ),
'project4' => array ('type' => 'select', 'values' => $this->settings['projects'], ),
'statement' => array ('heading' => array ('p' => 'Due to limitation of space, only 40 applications will be accepted. To be considered all applications must be accompanied by a brief statement describing how the applicant will use this experience in their future studies. This statement must be no more than 500 words in length. Of the 40 spaces available, 10 full scholarships will be awarded to successful applicants from developing countries. No other financial assistance will be provided.', )),
'project5' => array ('type' => 'select', 'values' => $this->settings['projects'], ),
'dietaryRequirements' => array ('type' => 'radiobuttons', 'heading' => array (3 => 'Personal requirements'), ),
'medical' => array ('description' => 'Please use this field to let us know of any physical or medical conditions we should be aware of to improve your participation.', ),
),
'vendor' => array (
'country' => array ('type' => 'select', 'values' => $countries, ),
'email' => array ('default' => $this->userVisibleIdentifier, 'editable' => false, ),
'website' => array ('placeholder' => 'https://...', 'description' => false, ),
'description' => array ('heading' => array ('p' => 'In the field below please describe what it is you wish to display, why you think it is appropriate for this conference, and what, if any, special requirements you need to present your materials effectively.'), ),
),
);
# Return the properties
return $dataBindingAttributes;
}
# Admin editing section, substantially delegated to the sinenomine editing component
public function editing ($attributes = array (), $deny = false, $sinenomineExtraSettings = array ())
{
# Define sinenomine settings
$sinenomineExtraSettings = array (
'int1ToCheckbox' => true,
'simpleJoin' => true,
'datePicker' => true,
'richtextEditorToolbarSet' => 'BasicLonger',
'richtextWidth' => 600,
'richtextHeight' => 200,
);
# Define table attributes
$attributesByTable = $this->formDataBindingAttributes ($table);
$attributes = array ();
foreach ($attributesByTable as $table => $attributesForTable) {
foreach ($attributesForTable as $field => $fieldAttributes) {
$attributes[] = array ($this->settings['database'], $table, $field, $fieldAttributes);
}
}
# Define tables to deny editing for
$deny[$this->settings['database']] = array (
'administrators',
'settings',
'users',
);
# Hand off to the default editor, which will echo the HTML
parent::editing ($attributes, $deny, $sinenomineExtraSettings);
}
}
?>