From 73175e2b64c85c7a8c528c76452cd82ffa99f925 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Mon, 28 Aug 2017 16:21:10 +0200 Subject: #337: Added routing --- templates/layout.html | 4 ++-- templates/maintenance.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'templates') diff --git a/templates/layout.html b/templates/layout.html index 787b4f22..1923124c 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -22,7 +22,7 @@ - ENGELSYSTEM + ENGELSYSTEM @@ -38,7 +38,7 @@ · Contact · Bugs / Features · Development Platform - · Credits + · Credits diff --git a/templates/maintenance.html b/templates/maintenance.html index 3f7dae8a..bd73bd74 100644 --- a/templates/maintenance.html +++ b/templates/maintenance.html @@ -21,7 +21,7 @@ - + ENGELSYSTEM -- cgit v1.2.3-70-g09d2 From a473a56f1dbf568dc66cd6fcffe6b638308c542e Mon Sep 17 00:00:00 2001 From: Bot Date: Wed, 30 Aug 2017 00:07:01 +0200 Subject: Formatting --- includes/model/Shifts_model.php | 3 +- includes/model/User_model.php | 2 +- includes/pages/admin_import.php | 2 +- includes/view/Rooms_view.php | 1 + includes/view/ShiftCalendarRenderer.php | 76 +++++++++++++++------------------ src/Database/Db.php | 9 ++-- templates/guest_credits.html | 7 ++- templates/layout.html | 4 +- 8 files changed, 50 insertions(+), 54 deletions(-) (limited to 'templates') diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index 88b28998..1589939d 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -45,7 +45,7 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter) AND NOT `Shifts`.`PSID` IS NULL) AS tmp_shifts ORDER BY `start`'; - + return DB::select( $sql, [ @@ -444,6 +444,7 @@ function Shift_update($shift) * * @param array $shift * @return bool|null + * @throws Exception */ function Shift_update_by_psid($shift) { diff --git a/includes/model/User_model.php b/includes/model/User_model.php index 4757ed3c..0ed602e0 100644 --- a/includes/model/User_model.php +++ b/includes/model/User_model.php @@ -241,7 +241,7 @@ function Users_by_angeltype($angeltype) `UserAngelTypes`.`id` AS `user_angeltype_id`, `UserAngelTypes`.`confirm_user_id`, `UserAngelTypes`.`supporter`, - (`UserDriverLicenses`.`user_id` IS NOT NULL) as `wants_to_drive`, + (`UserDriverLicenses`.`user_id` IS NOT NULL) AS `wants_to_drive`, `UserDriverLicenses`.* FROM `User` JOIN `UserAngelTypes` ON `User`.`UID`=`UserAngelTypes`.`user_id` diff --git a/includes/pages/admin_import.php b/includes/pages/admin_import.php index bda5ba93..bf8c498c 100644 --- a/includes/pages/admin_import.php +++ b/includes/pages/admin_import.php @@ -248,7 +248,7 @@ function admin_import() list($rooms_new, $rooms_deleted) = prepare_rooms($import_file); foreach ($rooms_new as $room) { $result = Room_create($room, true, true); - + $rooms_import[trim($room)] = $result; } foreach ($rooms_deleted as $room) { diff --git a/includes/view/Rooms_view.php b/includes/view/Rooms_view.php index 802b4c8e..76ce33a5 100644 --- a/includes/view/Rooms_view.php +++ b/includes/view/Rooms_view.php @@ -1,4 +1,5 @@ $room_id, + 'RID' => $room_id, 'Name' => $shift['room_name'] ]); - if (! isset($lanes[$room_id])) { + if (!isset($lanes[$room_id])) { // initialize room with one lane $lanes[$room_id] = [ new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot()) @@ -95,7 +91,7 @@ class ShiftCalendarRenderer $shift_added = false; foreach ($lanes[$room_id] as $lane) { /** @var ShiftCalendarLane $lane */ - if($lane->shiftFits($shift)) { + if ($lane->shiftFits($shift)) { $lane->addShift($shift); $shift_added = true; break; @@ -108,12 +104,11 @@ class ShiftCalendarRenderer $lanes[$room_id][] = $newLane; } } - + return $lanes; } /** - * * @return int */ public function getFirstBlockStartTime() @@ -122,7 +117,6 @@ class ShiftCalendarRenderer } /** - * * @return int */ public function getLastBlockEndTime() @@ -131,7 +125,6 @@ class ShiftCalendarRenderer } /** - * * @return float */ public function getBlocksPerSlot() @@ -153,9 +146,9 @@ class ShiftCalendarRenderer return ''; } return div('shift-calendar', [ - $this->renderTimeLane(), - $this->renderShiftLanes() - ]) . $this->renderLegend(); + $this->renderTimeLane(), + $this->renderShiftLanes() + ]) . $this->renderLegend(); } /** @@ -171,41 +164,45 @@ class ShiftCalendarRenderer $html .= $this->renderLane($lane); } } - + return $html; } /** * Renders a single lane * - * @param ShiftCalendarLane $lane - * The lane to render + * @param ShiftCalendarLane $lane The lane to render * @return string */ private function renderLane(ShiftCalendarLane $lane) { global $user; - + $shift_renderer = new ShiftCalendarShiftRenderer(); $html = ''; $rendered_until = $this->getFirstBlockStartTime(); - + foreach ($lane->getShifts() as $shift) { while ($rendered_until + ShiftCalendarRenderer::SECONDS_PER_ROW <= $shift['start']) { $html .= $this->renderTick($rendered_until); $rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW; } - - list ($shift_height, $shift_html) = $shift_renderer->render($shift, $this->needed_angeltypes[$shift['SID']], $this->shift_entries[$shift['SID']], $user); + + list ($shift_height, $shift_html) = $shift_renderer->render( + $shift, + $this->needed_angeltypes[$shift['SID']], + $this->shift_entries[$shift['SID']], + $user + ); $html .= $shift_html; $rendered_until += $shift_height * ShiftCalendarRenderer::SECONDS_PER_ROW; } - + while ($rendered_until < $this->getLastBlockEndTime()) { $html .= $this->renderTick($rendered_until); $rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW; } - + return div('lane', [ div('header', $lane->getHeader()), $html @@ -215,23 +212,21 @@ class ShiftCalendarRenderer /** * Renders a tick/block for given time * - * @param int $time - * unix timestamp - * @param boolean $label - * Should time labels be generated? + * @param int $time unix timestamp + * @param boolean $label Should time labels be generated? * @return string rendered tick html */ private function renderTick($time, $label = false) { if ($time % (24 * 60 * 60) == 23 * 60 * 60) { - if (! $label) { + if (!$label) { return div('tick day'); } return div('tick day', [ date('m-dH:i', $time) ]); } elseif ($time % (60 * 60) == 0) { - if (! $label) { + if (!$label) { return div('tick hour'); } return div('tick hour', [ @@ -253,7 +248,7 @@ class ShiftCalendarRenderer _('Time') ]) ]; - for ($block = 0; $block < $this->getBlocksPerSlot(); $block ++) { + for ($block = 0; $block < $this->getBlocksPerSlot(); $block++) { $thistime = $this->getFirstBlockStartTime() + ($block * ShiftCalendarRenderer::SECONDS_PER_ROW); $time_slot[] = $this->renderTick($thistime, true); } @@ -261,8 +256,7 @@ class ShiftCalendarRenderer } /** - * - * @param array[] $shifts + * @param array[] $shifts * @return int */ private function calcFirstBlockStartTime($shifts) @@ -277,8 +271,7 @@ class ShiftCalendarRenderer } /** - * - * @param array[] $shifts + * @param array[] $shifts * @return int */ private function calcLastBlockEndTime($shifts) @@ -293,7 +286,6 @@ class ShiftCalendarRenderer } /** - * * @return int */ private function calcBlocksPerSlot() diff --git a/src/Database/Db.php b/src/Database/Db.php index 777b16a2..7042998f 100644 --- a/src/Database/Db.php +++ b/src/Database/Db.php @@ -79,9 +79,10 @@ class Db return self::$stm->fetchAll(PDO::FETCH_ASSOC); } - + /** * Run a select query and return only the first result or null if no result is found. + * * @param string $query * @param array $bindings * @return array|null @@ -89,11 +90,11 @@ class Db public static function selectOne($query, array $bindings = []) { $result = self::select($query, $bindings); - - if(empty($result)) { + + if (empty($result)) { return null; } - + return array_shift($result); } diff --git a/templates/guest_credits.html b/templates/guest_credits.html index ba746d6a..db7fac57 100644 --- a/templates/guest_credits.html +++ b/templates/guest_credits.html @@ -20,11 +20,10 @@

Hosting

- Webspace, development platform and domain on engelsystem.de is currently provided by - would you buy this? (ichdasich) + Webspace, development platform and domain on engelsystem.de + is currently provided by would you buy this? (ichdasich) and adminstrated by mortzu, - derf - and ichdasich. + derf and ichdasich.

diff --git a/templates/layout.html b/templates/layout.html index 1923124c..4b9aa06e 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -22,7 +22,9 @@ - ENGELSYSTEM + + ENGELSYSTEM +
-- cgit v1.2.3-70-g09d2 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(-) (limited to 'templates') 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-70-g09d2