2016-07-14 10:19:38 +02:00
|
|
|
<?php
|
2016-09-27 17:24:18 +02:00
|
|
|
|
2016-09-27 17:49:13 +02:00
|
|
|
function event_config_title() {
|
|
|
|
return _("Event config");
|
2016-07-14 10:19:38 +02:00
|
|
|
}
|
2016-09-27 17:24:18 +02:00
|
|
|
|
2016-09-27 17:49:13 +02:00
|
|
|
function event_config_edit_controller() {
|
|
|
|
global $privileges;
|
|
|
|
|
2016-09-29 09:43:08 +02:00
|
|
|
if (! in_array('admin_event_config', $privileges)) {
|
2016-09-27 17:49:13 +02:00
|
|
|
redirect('?');
|
2016-09-29 09:43:08 +02:00
|
|
|
}
|
2016-09-27 17:49:13 +02:00
|
|
|
|
2016-09-27 17:24:18 +02:00
|
|
|
$event_name = null;
|
|
|
|
$event_welcome_msg = null;
|
|
|
|
$buildup_start_date = null;
|
|
|
|
$event_start_date = null;
|
|
|
|
$event_end_date = null;
|
|
|
|
$teardown_end_date = null;
|
|
|
|
|
2016-09-27 17:59:28 +02:00
|
|
|
$event_config = EventConfig();
|
2016-09-29 09:43:08 +02:00
|
|
|
if ($event_config === false) {
|
2016-09-27 17:49:13 +02:00
|
|
|
engelsystem_error('Unable to load event config.');
|
2016-09-29 09:43:08 +02:00
|
|
|
}
|
2016-09-27 17:59:28 +02:00
|
|
|
if ($event_config != null) {
|
|
|
|
$event_name = $event_config['event_name'];
|
|
|
|
$buildup_start_date = $event_config['buildup_start_date'];
|
|
|
|
$event_start_date = $event_config['event_start_date'];
|
|
|
|
$event_end_date = $event_config['event_end_date'];
|
|
|
|
$teardown_end_date = $event_config['teardown_end_date'];
|
|
|
|
$event_welcome_msg = $event_config['event_welcome_msg'];
|
2016-07-14 10:19:38 +02:00
|
|
|
}
|
2016-09-27 17:24:18 +02:00
|
|
|
|
2016-07-14 10:19:38 +02:00
|
|
|
if (isset($_REQUEST['submit'])) {
|
|
|
|
$ok = true;
|
2016-09-27 17:24:18 +02:00
|
|
|
|
2016-09-29 09:43:08 +02:00
|
|
|
if (isset($_REQUEST['event_name'])) {
|
2016-09-27 17:24:18 +02:00
|
|
|
$event_name = strip_request_item('event_name');
|
2016-09-29 09:43:08 +02:00
|
|
|
}
|
|
|
|
if ($event_name == '') {
|
2016-09-27 17:24:18 +02:00
|
|
|
$event_name = null;
|
2016-09-29 09:43:08 +02:00
|
|
|
}
|
2016-09-27 17:24:18 +02:00
|
|
|
|
2016-09-29 09:43:08 +02:00
|
|
|
if (isset($_REQUEST['event_welcome_msg'])) {
|
2016-09-27 17:24:18 +02:00
|
|
|
$event_welcome_msg = strip_request_item_nl('event_welcome_msg');
|
2016-09-29 09:43:08 +02:00
|
|
|
}
|
|
|
|
if ($event_welcome_msg == '') {
|
2016-09-27 17:24:18 +02:00
|
|
|
$event_welcome_msg = null;
|
2016-09-29 09:43:08 +02:00
|
|
|
}
|
2016-09-27 17:24:18 +02:00
|
|
|
|
|
|
|
$result = check_request_date('buildup_start_date', _("Please enter buildup start date."), true);
|
|
|
|
$buildup_start_date = $result->getValue();
|
|
|
|
$ok &= $result->isOk();
|
|
|
|
|
|
|
|
$result = check_request_date('event_start_date', _("Please enter event start date."), true);
|
|
|
|
$event_start_date = $result->getValue();
|
|
|
|
$ok &= $result->isOk();
|
|
|
|
|
|
|
|
$result = check_request_date('event_end_date', _("Please enter event end date."), true);
|
|
|
|
$event_end_date = $result->getValue();
|
|
|
|
$ok &= $result->isOk();
|
|
|
|
|
|
|
|
$result = check_request_date('teardown_end_date', _("Please enter teardown end date."), true);
|
|
|
|
$teardown_end_date = $result->getValue();
|
|
|
|
$ok &= $result->isOk();
|
|
|
|
|
2016-09-27 17:59:28 +02:00
|
|
|
if ($buildup_start_date != null && $event_start_date != null && $buildup_start_date > $event_start_date) {
|
|
|
|
$ok = false;
|
|
|
|
error(_("The buildup start date has to be before the event start date."));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($event_start_date != null && $event_end_date != null && $event_start_date > $event_end_date) {
|
|
|
|
$ok = false;
|
|
|
|
error(_("The event start date has to be before the event end date."));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($event_end_date != null && $teardown_end_date != null && $event_end_date > $teardown_end_date) {
|
|
|
|
$ok = false;
|
|
|
|
error(_("The event end date has to be before the teardown end date."));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($buildup_start_date != null && $teardown_end_date != null && $buildup_start_date > $teardown_end_date) {
|
|
|
|
$ok = false;
|
|
|
|
error(_("The buildup start date has to be before the teardown end date."));
|
|
|
|
}
|
|
|
|
|
2016-09-27 17:24:18 +02:00
|
|
|
if ($ok) {
|
2016-09-27 17:49:13 +02:00
|
|
|
$result = EventConfig_update($event_name, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date, $event_welcome_msg);
|
2016-09-27 17:24:18 +02:00
|
|
|
|
2016-09-29 09:43:08 +02:00
|
|
|
if ($result === false) {
|
2016-09-27 17:49:13 +02:00
|
|
|
engelsystem_error("Unable to update event config.");
|
2016-09-29 09:43:08 +02:00
|
|
|
}
|
2016-09-27 17:24:18 +02:00
|
|
|
|
2016-09-27 18:42:10 +02:00
|
|
|
engelsystem_log("Changed event config: $event_name, $event_welcome_msg, " . date("Y-m-d", $buildup_start_date) . ", " . date("Y-m-d", $event_start_date) . ", " . date("Y-m-d", $event_end_date) . ", " . date("Y-m-d", $teardown_end_date));
|
2016-09-27 17:24:18 +02:00
|
|
|
success(_("Settings saved."));
|
2016-09-27 17:59:28 +02:00
|
|
|
redirect(page_link_to('admin_event_config'));
|
2016-07-14 10:19:38 +02:00
|
|
|
}
|
2016-09-27 17:24:18 +02:00
|
|
|
}
|
2016-07-14 10:19:38 +02:00
|
|
|
|
2016-09-27 17:49:13 +02:00
|
|
|
return [
|
|
|
|
event_config_title(),
|
|
|
|
EventConfig_edit_view($event_name, $event_welcome_msg, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date)
|
|
|
|
];
|
2016-07-14 10:19:38 +02:00
|
|
|
}
|
2016-09-27 17:49:13 +02:00
|
|
|
|
|
|
|
?>
|