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 --- includes/view/AngelTypes_view.php | 71 +++++++++++++++++++-------- includes/view/Questions_view.php | 12 ++++- includes/view/ShiftCalendarShiftRenderer.php | 14 +++--- includes/view/ShiftTypes_view.php | 34 ++++++++++--- includes/view/Shifts_view.php | 9 ++-- includes/view/UserAngelTypes_view.php | 73 ++++++++++++++++++++++------ includes/view/User_view.php | 46 ++++++++++++------ 7 files changed, 188 insertions(+), 71 deletions(-) (limited to 'includes/view') diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php index f74b0eb1..32f58d4b 100644 --- a/includes/view/AngelTypes_view.php +++ b/includes/view/AngelTypes_view.php @@ -50,7 +50,10 @@ function AngelType_delete_view($angeltype) buttons([ button(page_link_to('angeltypes'), _('cancel'), 'cancel'), button( - page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'] . '&confirmed', + page_link_to( + 'angeltypes', + ['action' => 'delete', 'angeltype_id' => $angeltype['id'], 'confirmed' => 1] + ), _('delete'), 'ok' ) @@ -67,7 +70,6 @@ function AngelType_delete_view($angeltype) */ function AngelType_edit_view($angeltype, $supporter_mode) { - $contact_info = AngelType_contact_info($angeltype); return page_with_title(sprintf(_('Edit %s'), $angeltype['name']), [ buttons([ button(page_link_to('angeltypes'), _('Angeltypes'), 'back') @@ -127,7 +129,7 @@ function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, if ($user_angeltype == null) { $buttons[] = button( - page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], + page_link_to('user_angeltypes', ['action' => 'add', 'angeltype_id' => $angeltype['id']]), _('join'), 'add' ); @@ -142,20 +144,22 @@ function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $angeltype['name'] )); } - $buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'], - _('leave'), 'cancel'); + $buttons[] = button( + page_link_to('user_angeltypes', ['action' => 'delete', 'user_angeltype_id' => $user_angeltype['id']]), + _('leave'), 'cancel' + ); } if ($admin_angeltypes || $supporter) { $buttons[] = button( - page_link_to('angeltypes') . '&action=edit&angeltype_id=' . $angeltype['id'], + page_link_to('angeltypes', ['action' => 'edit', 'angeltype_id' => $angeltype['id']]), _('edit'), 'edit' ); } if ($admin_angeltypes) { $buttons[] = button( - page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'], + page_link_to('angeltypes', ['action' => 'delete', 'angeltype_id' => $angeltype['id']]), _('delete'), 'delete' ); @@ -194,12 +198,18 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a if ($angeltype['restricted'] && $member['confirm_user_id'] == null) { $member['actions'] = table_buttons([ button( - page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $member['user_angeltype_id'], + page_link_to( + 'user_angeltypes', + ['action' => 'confirm', 'user_angeltype_id' => $member['user_angeltype_id']] + ), _('confirm'), 'btn-xs' ), button( - page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'], + page_link_to( + 'user_angeltypes', + ['action' => 'delete', 'user_angeltype_id' => $member['user_angeltype_id']] + ), _('deny'), 'btn-xs' ) @@ -209,7 +219,11 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a if ($admin_angeltypes) { $member['actions'] = table_buttons([ button( - page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&supporter=0', + page_link_to('user_angeltypes', [ + 'action' => 'update', + 'user_angeltype_id' => $member['user_angeltype_id'], + 'supporter' => 0 + ]), _('Remove supporter rights'), 'btn-xs' ) @@ -222,11 +236,18 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a if ($admin_user_angeltypes) { $member['actions'] = table_buttons([ $admin_angeltypes - ? button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&supporter=1', + ? button(page_link_to('user_angeltypes', [ + 'action' => 'update', + 'user_angeltype_id' => $member['user_angeltype_id'], + 'supporter' => 1 + ]), _('Add supporter rights'), 'btn-xs') : '', button( - page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'], + page_link_to('user_angeltypes', [ + 'action' => 'delete', + 'user_angeltype_id' => $member['user_angeltype_id'] + ]), _('remove'), 'btn-xs' ) @@ -340,7 +361,14 @@ function AngelType_view( $page[] = '

' . _('Members') . '

'; if ($admin_user_angeltypes) { $page[] = buttons([ - button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _('Add'), 'add') + button( + page_link_to( + 'user_angeltypes', + ['action' => 'add', 'angeltype_id' => $angeltype['id']] + ), + _('Add'), + 'add' + ) ]); } $page[] = table($table_headers, $members_confirmed); @@ -349,12 +377,12 @@ function AngelType_view( $page[] = '

' . _('Unconfirmed') . '

'; $page[] = buttons([ button( - page_link_to('user_angeltypes') . '&action=confirm_all&angeltype_id=' . $angeltype['id'], + page_link_to('user_angeltypes', ['action' => 'confirm_all', 'angeltype_id' => $angeltype['id']]), _('confirm all'), 'ok' ), button( - page_link_to('user_angeltypes') . '&action=delete_all&angeltype_id=' . $angeltype['id'], + page_link_to('user_angeltypes', ['action' => 'delete_all', 'angeltype_id' => $angeltype['id']]), _('deny all'), 'cancel' ) @@ -377,8 +405,10 @@ function AngelTypes_list_view($angeltypes, $admin_angeltypes) return page_with_title(angeltypes_title(), [ msg(), buttons([ - $admin_angeltypes ? button(page_link_to('angeltypes') . '&action=edit', _('New angeltype'), 'add') : '', - button(page_link_to('angeltypes') . '&action=about', _('Teams/Job description')) + $admin_angeltypes + ? button(page_link_to('angeltypes', ['action' => 'edit']), _('New angeltype'), 'add') + : '', + button(page_link_to('angeltypes', ['action' => 'about']), _('Teams/Job description')) ]), table([ 'name' => _('Name'), @@ -406,13 +436,16 @@ function AngelTypes_about_view_angeltype($angeltype) $buttons = []; if ($angeltype['user_angeltype_id'] != null) { $buttons[] = button( - page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $angeltype['user_angeltype_id'], + page_link_to( + 'user_angeltypes', + ['action' => 'delete', 'user_angeltype_id' => $angeltype['user_angeltype_id']] + ), _('leave'), 'cancel' ); } else { $buttons[] = button( - page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], + page_link_to('user_angeltypes', ['action' => 'add', 'angeltype_id' => $angeltype['id']]), _('join'), 'add' ); diff --git a/includes/view/Questions_view.php b/includes/view/Questions_view.php index dee7585c..a44a099d 100644 --- a/includes/view/Questions_view.php +++ b/includes/view/Questions_view.php @@ -9,14 +9,22 @@ function Questions_view($open_questions, $answered_questions, $ask_action) { foreach ($open_questions as &$question) { - $question['actions'] = '' . _('delete') . ''; + $question['actions'] = '' + . _('delete') + . ''; $question['Question'] = str_replace("\n", '
', $question['Question']); } foreach ($answered_questions as &$question) { $question['Question'] = str_replace("\n", '
', $question['Question']); $question['Answer'] = str_replace("\n", '
', $question['Answer']); - $question['actions'] = '' . _('delete') . ''; + $question['actions'] = '' + . _('delete') + . ''; } return page_with_title(questions_title(), [ diff --git a/includes/view/ShiftCalendarShiftRenderer.php b/includes/view/ShiftCalendarShiftRenderer.php index 8560d47d..f0488e83 100644 --- a/includes/view/ShiftCalendarShiftRenderer.php +++ b/includes/view/ShiftCalendarShiftRenderer.php @@ -125,7 +125,7 @@ class ShiftCalendarShiftRenderer if (in_array('user_shifts_admin', $privileges)) { $html .= '
  • ' . button( - page_link_to('user_shifts') . '&shift_id=' . $shift['SID'], + page_link_to('user_shifts', ['shift_id' => $shift['SID']]), _('Add more angels'), 'btn-xs' ) . '
  • '; @@ -169,11 +169,13 @@ class ShiftCalendarShiftRenderer case ShiftSignupState::ADMIN: case ShiftSignupState::FREE: // When admin or free display a link + button for sign up - $entry_list[] = '' + $entry_list[] = '' . $inner_text . ' ' . button( - page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'], + page_link_to('user_shifts', ['shift_id' => $shift['SID'], 'type_id' => $angeltype['id']]), _('Sign up'), 'btn-xs btn-primary' ); break; @@ -191,7 +193,7 @@ class ShiftCalendarShiftRenderer // Add link to join the angeltype first $entry_list[] = $inner_text . '
    ' . button( - page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], + page_link_to('user_angeltypes', ['action' => 'add', 'angeltype_id' => $angeltype['id']]), sprintf(_('Become %s'), $angeltype['name']), 'btn-xs' ); @@ -232,8 +234,8 @@ class ShiftCalendarShiftRenderer $header_buttons = ''; if (in_array('admin_shifts', $privileges)) { $header_buttons = '
    ' . table_buttons([ - button(page_link_to('user_shifts') . '&edit_shift=' . $shift['SID'], glyph('edit'), 'btn-xs'), - button(page_link_to('user_shifts') . '&delete_shift=' . $shift['SID'], glyph('trash'), 'btn-xs') + button(page_link_to('user_shifts', ['edit_shift' => $shift['SID']]), glyph('edit'), 'btn-xs'), + button(page_link_to('user_shifts', ['delete_shift' => $shift['SID']]), glyph('trash'), 'btn-xs') ]) . '
    '; } $shift_heading = date('H:i', $shift['start']) . ' ‐ ' diff --git a/includes/view/ShiftTypes_view.php b/includes/view/ShiftTypes_view.php index e0750617..74e0d7c0 100644 --- a/includes/view/ShiftTypes_view.php +++ b/includes/view/ShiftTypes_view.php @@ -24,7 +24,10 @@ function ShiftType_delete_view($shifttype) buttons([ button(page_link_to('shifttypes'), _('cancel'), 'cancel'), button( - page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'] . '&confirmed', + page_link_to( + 'shifttypes', + ['action' => 'delete', 'shifttype_id' => $shifttype['id'], 'confirmed' => 1] + ), _('delete'), 'ok btn-danger' ) @@ -81,12 +84,16 @@ function ShiftType_view($shifttype, $angeltype) buttons([ button(page_link_to('shifttypes'), shifttypes_title(), 'back'), $angeltype ? button( - page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], + page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]), $angeltype['name'] ) : '', - button(page_link_to('shifttypes') . '&action=edit&shifttype_id=' . $shifttype['id'], _('edit'), 'edit'), button( - page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'], + page_link_to('shifttypes', ['action' => 'edit', 'shifttype_id' => $shifttype['id']]), + _('edit'), + 'edit' + ), + button( + page_link_to('shifttypes', ['action' => 'delete', 'shifttype_id' => $shifttype['id']]), _('delete'), 'delete' ) @@ -103,11 +110,22 @@ function ShiftType_view($shifttype, $angeltype) function ShiftTypes_list_view($shifttypes) { foreach ($shifttypes as &$shifttype) { - $shifttype['name'] = '' . $shifttype['name'] . ''; + $shifttype['name'] = '' + . $shifttype['name'] + . ''; $shifttype['actions'] = table_buttons([ - button(page_link_to('shifttypes') . '&action=edit&shifttype_id=' . $shifttype['id'], _('edit'), 'btn-xs'), button( - page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'], + page_link_to( + 'shifttypes', + ['action' => 'edit', 'shifttype_id' => $shifttype['id']] + ), + _('edit'), + 'btn-xs' + ), + button( + page_link_to('shifttypes', ['action' => 'delete', 'shifttype_id' => $shifttype['id']]), _('delete'), 'btn-xs' ) @@ -117,7 +135,7 @@ function ShiftTypes_list_view($shifttypes) return page_with_title(shifttypes_title(), [ msg(), buttons([ - button(page_link_to('shifttypes') . '&action=edit', _('New shifttype'), 'add') + button(page_link_to('shifttypes', ['action' => 'edit']), _('New shifttype'), 'add') ]), table([ 'name' => _('Name'), diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php index 094af7ad..bc905f39 100644 --- a/includes/view/Shifts_view.php +++ b/includes/view/Shifts_view.php @@ -1,4 +1,5 @@ isSignupAllowed()) { return button( - page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'], + page_link_to('user_shifts', ['shift_id' => $shift['SID'], 'type_id' => $angeltype['id']]), _('Sign up') ); } elseif ($user_angeltype == null) { return button( - page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], + page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]), sprintf(_('Become %s'), $angeltype['name']) ); @@ -207,12 +208,12 @@ function Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angelty $entry .= '
    '; if ($user_shift_admin) { $entry .= button_glyph( - page_link_to('user_myshifts') . '&edit=' . $shift_entry['id'] . '&id=' . $shift_entry['UID'], + page_link_to('user_myshifts', ['edit' => $shift_entry['id'], 'id' => $shift_entry['UID']]), 'pencil', 'btn-xs' ); } - $entry .= button_glyph(page_link_to('user_shifts') . '&entry_id=' . $shift_entry['id'], 'trash', 'btn-xs'); + $entry .= button_glyph(page_link_to('user_shifts', ['entry_id' => $shift_entry['id']]), 'trash', 'btn-xs'); $entry .= '
    '; } return $entry; diff --git a/includes/view/UserAngelTypes_view.php b/includes/view/UserAngelTypes_view.php index 15d99961..98f6c3e9 100644 --- a/includes/view/UserAngelTypes_view.php +++ b/includes/view/UserAngelTypes_view.php @@ -19,12 +19,18 @@ function UserAngelType_update_view($user_angeltype, $user, $angeltype, $supporte User_Nick_render($user) ), true), buttons([ - button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'), button( - page_link_to('user_angeltypes') - . '&action=update&user_angeltype_id=' . $user_angeltype['id'] - . '&supporter=' . ($supporter ? '1' : '0') - . '&confirmed', + page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]), + _('cancel'), + 'cancel' + ), + button( + page_link_to('user_angeltypes', [ + 'action' => 'update', + 'user_angeltype_id' => $user_angeltype['id'], + 'supporter' => ($supporter ? '1' : '0'), + 'confirmed' => 1, + ]), _('yes'), 'ok' ) @@ -42,9 +48,19 @@ function UserAngelTypes_delete_all_view($angeltype) msg(), info(sprintf(_('Do you really want to deny all users for %s?'), $angeltype['name']), true), buttons([ - button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'), button( - page_link_to('user_angeltypes') . '&action=delete_all&angeltype_id=' . $angeltype['id'] . '&confirmed', + page_link_to( + 'angeltypes', + ['action' => 'view', 'angeltype_id' => $angeltype['id']] + ), + _('cancel'), + 'cancel' + ), + button( + page_link_to( + 'user_angeltypes', + ['action' => 'delete_all', 'angeltype_id' => $angeltype['id'], 'confirmed' => 1] + ), _('yes'), 'ok' ) @@ -62,9 +78,11 @@ function UserAngelTypes_confirm_all_view($angeltype) msg(), info(sprintf(_('Do you really want to confirm all users for %s?'), $angeltype['name']), true), buttons([ - button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'), + button(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]), _('cancel'), + 'cancel'), button( - page_link_to('user_angeltypes') . '&action=confirm_all&angeltype_id=' . $angeltype['id'] . '&confirmed', + page_link_to('user_angeltypes', + ['action' => 'confirm_all', 'angeltype_id' => $angeltype['id'], 'confirmed' => 1]), _('yes'), 'ok' ) @@ -84,9 +102,16 @@ function UserAngelType_confirm_view($user_angeltype, $user, $angeltype) msg(), info(sprintf(_('Do you really want to confirm %s for %s?'), User_Nick_render($user), $angeltype['name']), true), buttons([ - button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'), button( - page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed', + page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]), + _('cancel'), + 'cancel' + ), + button( + page_link_to( + 'user_angeltypes', + ['action' => 'confirm', 'user_angeltype_id' => $user_angeltype['id'], 'confirmed' => 1] + ), _('yes'), 'ok' ) @@ -106,9 +131,14 @@ function UserAngelType_delete_view($user_angeltype, $user, $angeltype) msg(), info(sprintf(_('Do you really want to delete %s from %s?'), User_Nick_render($user), $angeltype['name']), true), buttons([ - button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'), button( - page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed', + page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]), + _('cancel'), + 'cancel' + ), + button( + page_link_to('user_angeltypes', + ['action' => 'delete', 'user_angeltype_id' => $user_angeltype['id'], 'confirmed' => 1]), _('yes'), 'ok' ) @@ -132,7 +162,11 @@ function UserAngelType_add_view($angeltype, $users_source, $user_id) return page_with_title(_('Add user to angeltype'), [ msg(), buttons([ - button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('back'), 'back') + button( + page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]), + _('back'), + 'back' + ) ]), form([ form_info(_('Angeltype'), $angeltype['name']), @@ -153,9 +187,16 @@ function UserAngelType_join_view($user, $angeltype) msg(), info(sprintf(_('Do you really want to add %s to %s?'), User_Nick_render($user), $angeltype['name']), true), buttons([ - button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'), button( - page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'] . '&user_id=' . $user['UID'] . '&confirmed', + page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]), + _('cancel'), + 'cancel' + ), + button( + page_link_to( + 'user_angeltypes', + ['action' => 'add', 'angeltype_id' => $angeltype['id'], 'user_id' => $user['UID'], 'confirmed' => 1] + ), _('save'), 'ok' ) diff --git a/includes/view/User_view.php b/includes/view/User_view.php index 932614a7..c1e6f49e 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -127,7 +127,7 @@ function User_registration_success_view($event_welcome_message) '

    ' . _('What can I do?') . '

    ', '

    ' . _('Please read about the jobs you can do to help us.') . '

    ', buttons([ - button(page_link_to('angeltypes') . '&action=about', _('Teams/Job description') . ' »') + button(page_link_to('angeltypes', ['action' => 'about']), _('Teams/Job description') . ' »') ]) ]) ]) @@ -172,10 +172,13 @@ function User_edit_vouchers_view($user) button(user_link($user), glyph('chevron-left') . _('back')) ]), info(sprintf(_('Angel should receive at least %d vouchers.'), User_get_eligable_voucher_count($user)), true), - form([ - form_spinner('vouchers', _('Number of vouchers given out'), $user['got_voucher']), - form_submit('submit', _('Save')) - ], page_link_to('users') . '&action=edit_vouchers&user_id=' . $user['UID']) + form( + [ + form_spinner('vouchers', _('Number of vouchers given out'), $user['got_voucher']), + form_submit('submit', _('Save')) + ], + page_link_to('users', ['action' => 'edit_vouchers', 'user_id' => $user['UID']]) + ) ]); } @@ -208,7 +211,7 @@ function Users_view( $user['Tshirt'] = glyph_bool($user['Tshirt']); $user['lastLogIn'] = date(_('m/d/Y h:i a'), $user['lastLogIn']); $user['actions'] = table_buttons([ - button_glyph(page_link_to('admin_user') . '&id=' . $user['UID'], 'edit', 'btn-xs') + button_glyph(page_link_to('admin_user', ['id' => $user['UID']]), 'edit', 'btn-xs') ]); } $users[] = [ @@ -253,7 +256,11 @@ function Users_view( */ function Users_table_header_link($column, $label, $order_by) { - return '' . $label . ($order_by == $column ? ' ' : '') . ''; + return '' + . $label . ($order_by == $column ? ' ' : '') + . ''; } /** @@ -347,7 +354,7 @@ function User_view_myshift($shift, $user_source, $its_me) ]; if ($its_me || in_array('user_shifts_admin', $privileges)) { $myshift['actions'][] = button( - page_link_to('user_myshifts') . '&edit=' . $shift['id'] . '&id=' . $user_source['UID'], + page_link_to('user_myshifts', ['edit' => $shift['id'], 'id' => $user_source['UID']]), glyph('edit') . _('edit'), 'btn-xs' ); @@ -356,8 +363,15 @@ function User_view_myshift($shift, $user_source, $its_me) ($shift['start'] > time() + config('last_unsubscribe') * 3600) || in_array('user_shifts_admin', $privileges) ) { + $parameters = [ + 'cancel' => $shift['id'], + 'id' => $user_source['UID'], + ]; + if ($its_me) { + $parameters['id'] = ''; + } $myshift['actions'][] = button( - page_link_to('user_myshifts') . ((!$its_me) ? '&id=' . $user_source['UID'] : '') . '&cancel=' . $shift['id'], + page_link_to('user_myshifts', $parameters), glyph('trash') . _('sign off'), 'btn-xs' ); @@ -427,7 +441,7 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel div('col-md-12', [ buttons([ $admin_user_privilege ? button( - page_link_to('admin_user') . '&id=' . $user_source['UID'], + page_link_to('admin_user', ['id' => $user_source['UID']]), glyph('edit') . _('edit') ) : '', $admin_user_privilege ? button( @@ -435,24 +449,24 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel glyph('road') . _('driving license') ) : '', ($admin_user_privilege && !$user_source['Gekommen']) ? button( - page_link_to('admin_arrive') . '&arrived=' . $user_source['UID'], + page_link_to('admin_arrive', ['arrived' => $user_source['UID']]), _('arrived') ) : '', $admin_user_privilege ? button( - page_link_to('users') . '&action=edit_vouchers&user_id=' . $user_source['UID'], + page_link_to('users', ['action' => 'edit_vouchers', 'user_id' => $user_source['UID']]), glyph('cutlery') . _('Edit vouchers') ) : '', $its_me ? button(page_link_to('user_settings'), glyph('list-alt') . _('Settings')) : '', $its_me ? button( - page_link_to('ical') . '&key=' . $user_source['api_key'], + page_link_to('ical', ['key' => $user_source['api_key']]), glyph('calendar') . _('iCal Export') ) : '', $its_me ? button( - page_link_to('shifts_json_export') . '&key=' . $user_source['api_key'], + page_link_to('shifts_json_export', ['key' => $user_source['api_key']]), glyph('export') . _('JSON Export') ) : '', $its_me ? button( - page_link_to('user_myshifts') . '&reset', + page_link_to('user_myshifts', ['reset' => 1]), glyph('repeat') . _('Reset API key') ) : '' ]) @@ -607,7 +621,7 @@ function User_groups_render($user_groups) function User_Nick_render($user_source) { return ' ' . htmlspecialchars($user_source['Nick']) . ''; } -- 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 'includes/view') 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 96f1d9fd541d0c5ef78151f8c69a89c41684b67a Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Wed, 30 Aug 2017 14:59:27 +0200 Subject: Bugfixes --- includes/controller/shift_entries_controller.php | 6 +++--- includes/controller/shifts_controller.php | 11 ++++++----- includes/pages/admin_arrive.php | 4 ++-- includes/pages/admin_import.php | 20 ++++++++++++-------- includes/pages/admin_user.php | 4 ++-- includes/pages/user_myshifts.php | 4 ++-- includes/sys_page.php | 6 +++++- includes/view/Rooms_view.php | 2 +- includes/view/ShiftCalendarShiftRenderer.php | 14 +++++++++----- includes/view/ShiftsFilterRenderer.php | 11 ++++++++--- 10 files changed, 50 insertions(+), 32 deletions(-) (limited to 'includes/view') diff --git a/includes/controller/shift_entries_controller.php b/includes/controller/shift_entries_controller.php index 148b19fb..150db2e9 100644 --- a/includes/controller/shift_entries_controller.php +++ b/includes/controller/shift_entries_controller.php @@ -13,7 +13,7 @@ function shift_entry_add_controller() $request = request(); $shift_id = 0; - if ($request->has('shift_id') && preg_match('/^\d*$/', $request->input('shift_id'))) { + if ($request->has('shift_id') && preg_match('/^\d+$/', $request->input('shift_id'))) { $shift_id = $request->input('shift_id'); } else { redirect(page_link_to('user_shifts')); @@ -33,7 +33,7 @@ function shift_entry_add_controller() $shift['Name'] = $room_array[$shift['RID']]; $type_id = 0; - if ($request->has('type_id') && preg_match('/^\d*$/', $request->input('type_id'))) { + if ($request->has('type_id') && preg_match('/^\d+$/', $request->input('type_id'))) { $type_id = $request->input('type_id'); } else { redirect(page_link_to('user_shifts')); @@ -64,7 +64,7 @@ function shift_entry_add_controller() if ( $request->has('user_id') - && preg_match('/^\d*$/', $request->input('user_id')) + && preg_match('/^\d+$/', $request->input('user_id')) && ( in_array('user_shifts_admin', $privileges) || in_array('shiftentry_edit_angeltype_supporter', $privileges) diff --git a/includes/controller/shifts_controller.php b/includes/controller/shifts_controller.php index c359850f..70011821 100644 --- a/includes/controller/shifts_controller.php +++ b/includes/controller/shifts_controller.php @@ -8,10 +8,13 @@ use Engelsystem\ShiftSignupState; */ function shift_link($shift) { - $link = page_link_to('shifts', ['action' => 'view']); + $parameters = ['action' => 'view']; if (isset($shift['SID'])) { - $link .= '&shift_id=' . $shift['SID']; + $parameters['shift_id'] = $shift['SID']; } + + $link = page_link_to('shifts', $parameters); + return $link; } @@ -201,7 +204,7 @@ function shift_delete_controller() } // Schicht komplett löschen (nur für admins/user mit user_shifts_admin privileg) - if (!$request->has('delete_shift') || !preg_match('/^\d*$/', $request->input('delete_shift'))) { + if (!$request->has('delete_shift') || !preg_match('/^\d+$/', $request->input('delete_shift'))) { redirect(page_link_to('user_shifts')); } $shift_id = $request->input('delete_shift'); @@ -316,8 +319,6 @@ function shifts_controller() /** * Redirects the user to his next shift. - * - * @return false */ function shift_next_controller() { diff --git a/includes/pages/admin_arrive.php b/includes/pages/admin_arrive.php index 2f312b1f..48e2c91f 100644 --- a/includes/pages/admin_arrive.php +++ b/includes/pages/admin_arrive.php @@ -23,7 +23,7 @@ function admin_arrive() $search = strip_request_item('search'); } - if ($request->has('reset') && preg_match('/^\d*$/', $request->input('reset'))) { + if ($request->has('reset') && preg_match('/^\d+$/', $request->input('reset'))) { $user_id = $request->input('reset'); $user_source = User($user_id); if ($user_source != null) { @@ -39,7 +39,7 @@ function admin_arrive() } else { $msg = error(_('Angel not found.'), true); } - } elseif ($request->has('arrived') && preg_match('/^\d*$/', $request->input('arrived'))) { + } elseif ($request->has('arrived') && preg_match('/^\d+$/', $request->input('arrived'))) { $user_id = $request->input('arrived'); $user_source = User($user_id); if ($user_source != null) { diff --git a/includes/pages/admin_import.php b/includes/pages/admin_import.php index bf8c498c..e97f95e1 100644 --- a/includes/pages/admin_import.php +++ b/includes/pages/admin_import.php @@ -98,10 +98,12 @@ function admin_import() if ($valid) { redirect( - page_link_to('admin_import') - . '&step=check&shifttype_id=' . $shifttype_id - . '&add_minutes_end=' . $add_minutes_end - . '&add_minutes_start=' . $add_minutes_start + page_link_to('admin_import', [ + 'step' => 'check', + 'shifttype_id' => $shifttype_id, + 'add_minutes_end' => $add_minutes_end, + 'add_minutes_start' => $add_minutes_start, + ]) ); } else { $html .= div('well well-sm text-center', [ @@ -207,10 +209,12 @@ function admin_import() ], shifts_printable($events_deleted, $shifttypes)), form_submit('submit', _('Import')) ], - page_link_to('admin_import') - . '&step=import&shifttype_id=' . $shifttype_id - . '&add_minutes_end=' . $add_minutes_end - . '&add_minutes_start=' . $add_minutes_start + page_link_to('admin_import', [ + 'step' => 'import', + 'shifttype_id' => $shifttype_id, + 'add_minutes_end' => $add_minutes_end, + 'add_minutes_start' => $add_minutes_start, + ]) ); break; diff --git a/includes/pages/admin_user.php b/includes/pages/admin_user.php index 9b3b0f44..0620155b 100644 --- a/includes/pages/admin_user.php +++ b/includes/pages/admin_user.php @@ -179,11 +179,11 @@ function admin_user() switch ($request->input('action')) { case 'save_groups': if ($user_id != $user['UID']) { - $my_highest_group = DB::select( + $my_highest_group = DB::selectOne( 'SELECT * FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id`', [$user['UID']] ); - $his_highest_group = DB::select( + $his_highest_group = DB::selectOne( 'SELECT * FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id`', [$user_id] ); diff --git a/includes/pages/user_myshifts.php b/includes/pages/user_myshifts.php index 60a26922..836bd566 100644 --- a/includes/pages/user_myshifts.php +++ b/includes/pages/user_myshifts.php @@ -46,7 +46,7 @@ function user_myshifts() ), button(page_link_to('user_myshifts', ['reset' => 'ack']), _('Continue'), 'btn-danger') ]); - } elseif ($request->has('edit') && preg_match('/^\d*$/', $request->input('edit'))) { + } elseif ($request->has('edit') && preg_match('/^\d+$/', $request->input('edit'))) { $user_id = $request->input('edit'); $shift = DB::selectOne(' SELECT @@ -124,7 +124,7 @@ function user_myshifts() } else { redirect(page_link_to('user_myshifts')); } - } elseif ($request->has('cancel') && preg_match('/^\d*$/', $request->input('cancel'))) { + } elseif ($request->has('cancel') && preg_match('/^\d+$/', $request->input('cancel'))) { $user_id = $request->input('cancel'); $shift = DB::selectOne(' SELECT * diff --git a/includes/sys_page.php b/includes/sys_page.php index df57d08a..33ec18b9 100644 --- a/includes/sys_page.php +++ b/includes/sys_page.php @@ -170,7 +170,11 @@ function strip_request_item($name, $default_value = null) function test_request_int($name) { $input = request()->input($name); - return preg_match('/^\d*$/', $input); + if (is_null($input)) { + return false; + } + + return preg_match('/^\d+$/', $input); } /** diff --git a/includes/view/Rooms_view.php b/includes/view/Rooms_view.php index 76ce33a5..3c0440a4 100644 --- a/includes/view/Rooms_view.php +++ b/includes/view/Rooms_view.php @@ -12,7 +12,7 @@ use Engelsystem\ShiftsFilterRenderer; function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer) { return page_with_title(glyph('map-marker') . $room['Name'], [ - $shiftsFilterRenderer->render(room_link($room)), + $shiftsFilterRenderer->render($room), $shiftCalendarRenderer->render() ]); } diff --git a/includes/view/ShiftCalendarShiftRenderer.php b/includes/view/ShiftCalendarShiftRenderer.php index f0488e83..0e5fc8c3 100644 --- a/includes/view/ShiftCalendarShiftRenderer.php +++ b/includes/view/ShiftCalendarShiftRenderer.php @@ -124,11 +124,15 @@ class ShiftCalendarShiftRenderer } if (in_array('user_shifts_admin', $privileges)) { - $html .= '
  • ' . button( - page_link_to('user_shifts', ['shift_id' => $shift['SID']]), - _('Add more angels'), - 'btn-xs' - ) . '
  • '; + $html .= '
  • ' . _('Add more angels') . ':'; + foreach ($needed_angeltypes as $angeltype) { + $html .= ' ' . button( + page_link_to('user_shifts', ['shift_id' => $shift['SID'], 'type_id' => $angeltype['id']]), + $angeltype['name'], + 'btn-xs' + ); + } + $html .= '
  • '; } if ($html != '') { return [ diff --git a/includes/view/ShiftsFilterRenderer.php b/includes/view/ShiftsFilterRenderer.php index 43a23ef6..c3e0ccf1 100644 --- a/includes/view/ShiftsFilterRenderer.php +++ b/includes/view/ShiftsFilterRenderer.php @@ -39,17 +39,22 @@ class ShiftsFilterRenderer /** * Renders the filter. * - * @param string $link_base + * @param array $room * @return string Generated HTML */ - public function render($link_base) + public function render($room) { $toolbar = []; if ($this->daySelectionEnabled && !empty($this->days)) { $selected_day = date('Y-m-d', $this->shiftsFilter->getStartTime()); $day_dropdown_items = []; foreach ($this->days as $day) { - $day_dropdown_items[] = toolbar_item_link($link_base . '&shifts_filter_day=' . $day, '', $day); + $link = page_link_to('rooms', [ + 'action' => 'view', + 'room_id' => $room['RID'], + 'shifts_filter_day' => $day, + ]); + $day_dropdown_items[] = toolbar_item_link($link, '', $day); } $toolbar[] = toolbar_dropdown('', $selected_day, $day_dropdown_items, 'active'); } -- 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 'includes/view') 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