From 0a20883aa862779b48fd2a297456c2db04cffb95 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Thu, 31 Aug 2017 12:25:06 +0200 Subject: Reimplementation of 2840bb619 (signup requires arrival), closes #330 --- config/config.default.php | 27 +++++++++++++++------------ includes/helper/message_helper.php | 11 ++++++----- includes/model/Shifts_model.php | 4 ++++ includes/pages/user_shifts.php | 6 ++++++ includes/view/Rooms_view.php | 8 ++++++++ public/index.php | 3 ++- templates/user_shifts.html | 17 +++++++++++------ 7 files changed, 52 insertions(+), 24 deletions(-) diff --git a/config/config.default.php b/config/config.default.php index a0303b15..419b02d1 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -4,7 +4,7 @@ return [ // MySQL-Connection Settings - 'database' => [ + 'database' => [ 'host' => 'localhost', 'user' => 'root', 'pw' => '', @@ -12,28 +12,28 @@ return [ ], // For accessing stats - 'api_key' => '', + 'api_key' => '', // Enable maintenance mode (show a static page) - 'maintenance' => false, + 'maintenance' => false, // Set to development to enable debugging messages - 'environment' => 'production', + 'environment' => 'production', // URL to the angel faq and job description - 'faq_url' => 'https://events.ccc.de/congress/2013/wiki/Static:Volunteers', + 'faq_url' => 'https://events.ccc.de/congress/2013/wiki/Static:Volunteers', // Contact email address, linked on every page - 'contact_email' => 'mailto:ticket@c3heaven.de', + 'contact_email' => 'mailto:ticket@c3heaven.de', // From address of all emails - 'no_reply_email' => 'noreply@engelsystem.de', + 'no_reply_email' => 'noreply@engelsystem.de', // Default theme, 1=style1.css - 'theme' => 1, + 'theme' => 1, // Available themes - 'available_themes' => [ + 'available_themes' => [ '4' => 'Engelsystem 33c3 (2016)', '3' => 'Engelsystem 32c3 (2015)', '2' => 'Engelsystem cccamp15', @@ -42,10 +42,13 @@ return [ ], // Number of News shown on one site - 'display_news' => 6, + 'display_news' => 6, + + // Only arrived angels can sign up for shifts + 'signup_requires_arrival' => false, // Anzahl Stunden bis zum Austragen eigener Schichten - 'last_unsubscribe' => 3, + 'last_unsubscribe' => 3, // Setzt den zu verwendenden Crypto-Algorithmus (entsprechend der Dokumentation von crypt()). // Falls ein Benutzerpasswort in einem anderen Format gespeichert ist, @@ -55,7 +58,7 @@ return [ // Blowfish '$2y$13' // SHA-256 '$5$rounds=5000' // SHA-512 '$6$rounds=5000' - 'crypt_alg' => '$6$rounds=5000', + 'crypt_alg' => '$6$rounds=5000', 'min_password_length' => 8, diff --git a/includes/helper/message_helper.php b/includes/helper/message_helper.php index 7a42a7b7..4fa0efe3 100644 --- a/includes/helper/message_helper.php +++ b/includes/helper/message_helper.php @@ -57,16 +57,17 @@ function success($msg, $immediately = false) * @param string $class * @param string $msg * @param bool $immediately - * @return string|null + * @return string */ function alert($class, $msg, $immediately = false) { $session = session(); + if (empty($msg)) { + return ''; + } + if ($immediately) { - if ($msg == '') { - return ''; - } return '
' . $msg . '
'; } @@ -74,5 +75,5 @@ function alert($class, $msg, $immediately = false) $message .= alert($class, $msg, true); $session->set('msg', $message); - return null; + return ''; } diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index 1589939d..03f8341f 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -245,6 +245,10 @@ function Shift_signup_allowed_angel( ) { $free_entries = Shift_free_entries($needed_angeltype, $shift_entries); + if (config('signup_requires_arrival') && !$user['Gekommen']) { + return new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, $free_entries); + } + if ($user_shifts == null) { $user_shifts = Shifts_by_user($user); } diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php index 30abbde6..2bd7688f 100644 --- a/includes/pages/user_shifts.php +++ b/includes/pages/user_shifts.php @@ -206,6 +206,11 @@ function view_user_shifts() $end_day = date('Y-m-d', $shiftsFilter->getEndTime()); $end_time = date('H:i', $shiftsFilter->getEndTime()); + $assignNotice = ''; + if (config('signup_requires_arrival') && !$user['Gekommen']) { + $assignNotice = info(render_user_arrived_hint(), true); + } + return page([ div('col-md-12', [ msg(), @@ -229,6 +234,7 @@ function view_user_shifts() . ' ' . _('Description of the jobs.') . '', + 'assign_notice' => $assignNotice, 'shifts_table' => msg() . $shiftCalendarRenderer->render(), 'ical_text' => '

' . _('iCal export') . '

' . sprintf( _('Export of shown shifts. iCal format or JSON format available (please keep secret, otherwise reset the api key).'), diff --git a/includes/view/Rooms_view.php b/includes/view/Rooms_view.php index 3c0440a4..adb58a9a 100644 --- a/includes/view/Rooms_view.php +++ b/includes/view/Rooms_view.php @@ -11,8 +11,16 @@ use Engelsystem\ShiftsFilterRenderer; */ function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer) { + global $user; + + $assignNotice = ''; + if (config('signup_requires_arrival') && !$user['Gekommen']) { + $assignNotice = info(render_user_arrived_hint(), true); + } + return page_with_title(glyph('map-marker') . $room['Name'], [ $shiftsFilterRenderer->render($room), + $assignNotice, $shiftCalendarRenderer->render() ]); } diff --git a/public/index.php b/public/index.php index a83ab5e8..b44e1491 100644 --- a/public/index.php +++ b/public/index.php @@ -19,7 +19,7 @@ $free_pages = [ 'stats', 'users', 'user_driver_licenses', - 'user_password_recovery' + 'user_password_recovery', ]; // Gewünschte Seite/Funktion @@ -218,6 +218,7 @@ $parameters = [ if ($page == 'user_meetings') { $parameters['meetings'] = 1; } + echo view(__DIR__ . '/../templates/layout.html', [ 'theme' => isset($user) ? $user['color'] : config('theme'), 'title' => $title, diff --git a/templates/user_shifts.html b/templates/user_shifts.html index 2b176ef9..c3fb7718 100644 --- a/templates/user_shifts.html +++ b/templates/user_shifts.html @@ -4,12 +4,14 @@ var days = document.getElementById(id + '_day').getElementsByTagName( 'option'); for (var i = 0; i < days.length; i++) { - if (days[i].value == moment().format('YYYY-MM-DD')) + if (days[i].value === moment().format('YYYY-MM-DD')) { days[i].selected = true; + } } } -

+ +
@@ -17,7 +19,7 @@
%start_select%
-
-
%task_notice%
- +
%assign_notice%
+
+
+

%task_notice%

+
-- cgit v1.2.3-54-g00ecf