diff options
author | msquare <msquare@notrademark.de> | 2016-09-27 17:59:28 +0200 |
---|---|---|
committer | msquare <msquare@notrademark.de> | 2016-09-27 17:59:28 +0200 |
commit | 5957e05bf13ec9659f52a3c613abac09cacab8c6 (patch) | |
tree | 4c926f5f2497c5955ad03594b0ee907652c1a51e /includes/controller/event_config_controller.php | |
parent | 031fc3057c46245cd62fc39f2d11ee3f0a393e06 (diff) |
finished rename settings to event config and added more date validation for event config
Diffstat (limited to 'includes/controller/event_config_controller.php')
-rw-r--r-- | includes/controller/event_config_controller.php | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/includes/controller/event_config_controller.php b/includes/controller/event_config_controller.php index 7e951214..f4564c18 100644 --- a/includes/controller/event_config_controller.php +++ b/includes/controller/event_config_controller.php @@ -17,16 +17,16 @@ function event_config_edit_controller() { $event_end_date = null; $teardown_end_date = null; - $settings_source = EventConfig(); - if ($settings_source === false) + $event_config = EventConfig(); + if ($event_config === false) engelsystem_error('Unable to load event config.'); - if ($settings_source != null) { - $event_name = $settings_source['event_name']; - $buildup_start_date = $settings_source['buildup_start_date']; - $event_start_date = $settings_source['event_start_date']; - $event_end_date = $settings_source['event_end_date']; - $teardown_end_date = $settings_source['teardown_end_date']; - $event_welcome_msg = $settings_source['event_welcome_msg']; + 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']; } if (isset($_REQUEST['submit'])) { @@ -58,6 +58,31 @@ function event_config_edit_controller() { $teardown_end_date = $result->getValue(); $ok &= $result->isOk(); + 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 ($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 ($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.")); + } + if ($ok) { $result = EventConfig_update($event_name, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date, $event_welcome_msg); @@ -66,7 +91,7 @@ function event_config_edit_controller() { engelsystem_log("Changed event config: $event_name, $event_welcome_msg, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date"); success(_("Settings saved.")); - redirect(page_link_to('admin_settings')); + redirect(page_link_to('admin_event_config')); } } |