summaryrefslogtreecommitdiff
path: root/includes/view
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-09-25 17:33:31 +0200
committermsquare <msquare@notrademark.de>2018-10-30 21:13:56 +0100
commit7f61dc95be4ac543986c7df2459532fd8f81368d (patch)
tree930497c659bbaa3e073313a261f3458348fd423d /includes/view
parent63d1292bf80d88be40eec7695c1a59f29e6609c5 (diff)
EventConfig: Merge event configuration from database to global config
Diffstat (limited to 'includes/view')
-rw-r--r--includes/view/EventConfig_view.php59
-rw-r--r--includes/view/User_view.php9
2 files changed, 36 insertions, 32 deletions
diff --git a/includes/view/EventConfig_view.php b/includes/view/EventConfig_view.php
index 4290ab0a..cd657c67 100644
--- a/includes/view/EventConfig_view.php
+++ b/includes/view/EventConfig_view.php
@@ -1,59 +1,62 @@
<?php
+use Carbon\Carbon;
+
/**
* Shows basic event infos and countdowns.
*
- * @param array $event_config The event configuration
* @return string
*/
-function EventConfig_countdown_page($event_config)
+function EventConfig_countdown_page()
{
- if (empty($event_config)) {
- return div('col-md-12 text-center', [
- heading(sprintf(__('Welcome to the %s!'), '<span class="icon-icon_angel"></span> ENGELSYSTEM'), 2)
- ]);
- }
-
+ $config = config();
+ $name = $config->get('name', '');
+ /** @var Carbon $buildup */
+ $buildup = $config->get('buildup_start');
+ /** @var Carbon $start */
+ $start = $config->get('event_start');
+ /** @var Carbon $end */
+ $end = $config->get('event_end');
+ /** @var Carbon $teardown */
+ $teardown = $config->get('teardown_end');
$elements = [];
- if (!is_null($event_config['event_name'])) {
- $elements[] = div('col-sm-12 text-center', [
- heading(sprintf(
- __('Welcome to the %s!'),
- $event_config['event_name'] . ' <span class="icon-icon_angel"></span> ENGELSYSTEM'
- ), 2)
- ]);
- }
+ $elements[] = div('col-sm-12 text-center', [
+ heading(sprintf(
+ __('Welcome to the %s!'),
+ $name . ' <span class="icon-icon_angel"></span> ENGELSYSTEM'
+ ), 2)
+ ]);
- if (!is_null($event_config['buildup_start_date']) && time() < $event_config['buildup_start_date']) {
+ if (!empty($buildup) && $buildup->greaterThan(new Carbon())) {
$elements[] = div('col-sm-3 text-center hidden-xs', [
heading(__('Buildup starts'), 4),
- '<span class="moment-countdown text-big" data-timestamp="' . $event_config['buildup_start_date'] . '">%c</span>',
- '<small>' . date(__('Y-m-d'), $event_config['buildup_start_date']) . '</small>'
+ '<span class="moment-countdown text-big" data-timestamp="' . $buildup->getTimestamp() . '">%c</span>',
+ '<small>' . $buildup->format(__('Y-m-d')) . '</small>'
]);
}
- if (!is_null($event_config['event_start_date']) && time() < $event_config['event_start_date']) {
+ if (!empty($start) && $start->greaterThan(new Carbon())) {
$elements[] = div('col-sm-3 text-center hidden-xs', [
heading(__('Event starts'), 4),
- '<span class="moment-countdown text-big" data-timestamp="' . $event_config['event_start_date'] . '">%c</span>',
- '<small>' . date(__('Y-m-d'), $event_config['event_start_date']) . '</small>'
+ '<span class="moment-countdown text-big" data-timestamp="' . $start->getTimestamp() . '">%c</span>',
+ '<small>' . $start->format(__('Y-m-d')) . '</small>'
]);
}
- if (!is_null($event_config['event_end_date']) && time() < $event_config['event_end_date']) {
+ if (!empty($end) && $end->greaterThan(new Carbon())) {
$elements[] = div('col-sm-3 text-center hidden-xs', [
heading(__('Event ends'), 4),
- '<span class="moment-countdown text-big" data-timestamp="' . $event_config['event_end_date'] . '">%c</span>',
- '<small>' . date(__('Y-m-d'), $event_config['event_end_date']) . '</small>'
+ '<span class="moment-countdown text-big" data-timestamp="' . $end->getTimestamp() . '">%c</span>',
+ '<small>' . $end->format(__('Y-m-d')) . '</small>'
]);
}
- if (!is_null($event_config['teardown_end_date']) && time() < $event_config['teardown_end_date']) {
+ if (!empty($teardown) && $teardown->greaterThan(new Carbon())) {
$elements[] = div('col-sm-3 text-center hidden-xs', [
heading(__('Teardown ends'), 4),
- '<span class="moment-countdown text-big" data-timestamp="' . $event_config['teardown_end_date'] . '">%c</span>',
- '<small>' . date(__('Y-m-d'), $event_config['teardown_end_date']) . '</small>'
+ '<span class="moment-countdown text-big" data-timestamp="' . $teardown->getTimestamp() . '">%c</span>',
+ '<small>' . $teardown->format(__('Y-m-d')) . '</small>'
]);
}
diff --git a/includes/view/User_view.php b/includes/view/User_view.php
index e092855a..ddf49885 100644
--- a/includes/view/User_view.php
+++ b/includes/view/User_view.php
@@ -1,5 +1,7 @@
<?php
+use Carbon\Carbon;
+
/**
* Renders user settings page
*
@@ -887,10 +889,9 @@ function render_user_arrived_hint()
global $user;
if ($user['Gekommen'] == 0) {
- $event_config = EventConfig();
- if (!empty($event_config)
- && !is_null($event_config['buildup_start_date'])
- && time() > $event_config['buildup_start_date']) {
+ /** @var Carbon $buildup */
+ $buildup = config('buildup_start');
+ if (!empty($buildup) && $buildup->lessThan(new Carbon())) {
return __('You are not marked as arrived. Please go to heaven\'s desk, get your angel badge and/or tell them that you arrived already.');
}
}