From 952c7892f3ac7bfadf8419062e44ff1af66ecc57 Mon Sep 17 00:00:00 2001 From: Bot Date: Mon, 25 Dec 2017 23:12:52 +0100 Subject: Formatting & Docstrings --- includes/view/User_view.php | 110 ++++++++++++++++++++++++++++++-------------- 1 file changed, 75 insertions(+), 35 deletions(-) (limited to 'includes/view/User_view.php') diff --git a/includes/view/User_view.php b/includes/view/User_view.php index 5aec1962..c9530307 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -105,6 +105,7 @@ function User_registration_success_view($event_welcome_message) { $parsedown = new Parsedown(); $event_welcome_message = $parsedown->text($event_welcome_message); + return page_with_title(_('Registration successful'), [ msg(), div('row', [ @@ -171,7 +172,10 @@ function User_edit_vouchers_view($user) buttons([ button(user_link($user), glyph('chevron-left') . _('back')) ]), - info(sprintf(_('Angel should receive at least %d vouchers.'), User_get_eligable_voucher_count($user)), true), + 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']), @@ -269,10 +273,10 @@ function Users_table_header_link($column, $label, $order_by) */ function User_shift_state_render($user) { - if(!$user['Gekommen']) { + if (!$user['Gekommen']) { return ''; } - + $upcoming_shifts = ShiftEntries_upcoming_for_user($user); if (empty($upcoming_shifts)) { @@ -283,16 +287,25 @@ function User_shift_state_render($user) if ($nextShift['start'] > time()) { if ($nextShift['start'] - time() > 3600) { - return '' . _('Next shift %c') . ''; + return '' + . _('Next shift %c') + . ''; } - return '' . _('Next shift %c') . ''; + return '' + . _('Next shift %c') + . ''; } $halfway = ($nextShift['start'] + $nextShift['end']) / 2; if (time() < $halfway) { - return '' . _('Shift starts %c') . ''; + return '' + . _('Shift starts %c') + . ''; } - return '' . _('Shift ends %c') . ''; + + return '' + . _('Shift ends %c') + . ''; } /** @@ -344,14 +357,15 @@ function User_view_myshift($shift, $user_source, $its_me) 'shift_info' => $shift_info, 'comment' => '' ]; - - if($its_me) { + + if ($its_me) { $myshift['comment'] = $shift['Comment']; } if ($shift['freeloaded']) { if (in_array('user_shifts_admin', $privileges)) { - $myshift['comment'] .= '

' . _('Freeloaded') . ': ' . $shift['freeload_comment'] . '

'; + $myshift['comment'] .= '
' + . '

' . _('Freeloaded') . ': ' . $shift['freeload_comment'] . '

'; } else { $myshift['comment'] .= '

' . _('Freeloaded') . '

'; } @@ -432,7 +446,9 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel $myshifts_table = User_view_myshifts($shifts, $user_source, $its_me); return page_with_title( - ' ' . htmlspecialchars($user_source['Nick']) . ' ' . $user_name . '', + ' ' + . htmlspecialchars($user_source['Nick']) + . ' ' . $user_name . '', [ msg(), div('row space-top', [ @@ -451,10 +467,16 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel _('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('user_settings'), + glyph('list-alt') . _('Settings') + ) : '', $its_me ? button( page_link_to('ical', ['key' => $user_source['api_key']]), glyph('calendar') . _('iCal Export') @@ -487,7 +509,10 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel 'comment' => _('Comment'), 'actions' => _('Action') ], $myshifts_table) : '', - $its_me ? info(glyph('info-sign') . _('Your night shifts between 2 and 8 am count twice.'), true) : '', + $its_me ? info( + glyph('info-sign') . _('Your night shifts between 2 and 8 am count twice.'), + true + ) : '', $its_me && count($shifts) == 0 ? error(sprintf( _('Go to the shifts table to sign yourself up for some shifts.'), @@ -499,10 +524,16 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel } /** - * Render the state section of user view. + * Render the state section of user view + * + * @param bool $admin_user_privilege + * @param bool $freeloader + * @param array $user_source + * @return string */ -function User_view_state($admin_user_privilege, $freeloader, $user_source) { - if($admin_user_privilege) { +function User_view_state($admin_user_privilege, $freeloader, $user_source) +{ + if ($admin_user_privilege) { $state = User_view_state_admin($freeloader, $user_source); } else { $state = User_view_state_user($user_source); @@ -516,45 +547,54 @@ function User_view_state($admin_user_privilege, $freeloader, $user_source) { /** * Render the state section of user view for users. + * + * @param array $user_source + * @return array */ -function User_view_state_user($user_source) { +function User_view_state_user($user_source) +{ $state = [ User_shift_state_render($user_source) ]; - - if($user_source['Gekommen']) { + + if ($user_source['Gekommen']) { $state[] = '' . glyph('home') . _('Arrived') . ''; } else { $state[] = '' . _('Not arrived') . ''; } - + return $state; } /** * Render the state section of user view for admins. + * + * @param bool $freeloader + * @param array $user_source + * @return array */ -function User_view_state_admin($freeloader, $user_source) { +function User_view_state_admin($freeloader, $user_source) +{ $state = []; - - if($freeloader) { + + if ($freeloader) { $state[] = '' . glyph('exclamation-sign') . _('Freeloader') . ''; } - + $state[] = User_shift_state_render($user_source); - - if($user_source['Gekommen']) { + + if ($user_source['Gekommen']) { $state[] = '' . glyph('home') . sprintf(_('Arrived at %s'), date('Y-m-d', $user_source['arrival_date'])) . ''; - if($user_source['force_active']) { + if ($user_source['force_active']) { $state[] = '' . _('Active (forced)') . ''; - } elseif($user_source['Aktiv']) { + } elseif ($user_source['Aktiv']) { $state[] = '' . _('Active') . ''; } - if($user_source['Tshirt']) { + if ($user_source['Tshirt']) { $state[] = '' . _('T-Shirt') . ''; } } else { @@ -562,15 +602,15 @@ function User_view_state_admin($freeloader, $user_source) { . sprintf(_('Not arrived (Planned: %s)'), date('Y-m-d', $user_source['planned_arrival_date'])) . ''; } - - if($user_source['got_voucher'] > 0) { + + if ($user_source['got_voucher'] > 0) { $state[] = '' . glyph('cutlery') . sprintf( ngettext('Got %s voucher', 'Got %s vouchers', $user_source['got_voucher']), $user_source['got_voucher'] - ) - . ''; + ) + . ''; } else { $state[] = '' . _('Got no vouchers') . ''; } @@ -731,7 +771,7 @@ function render_user_arrived_hint() if ($user['Gekommen'] == 0) { $event_config = EventConfig(); - if(!is_null($event_config) + if (!is_null($event_config) && !is_null($event_config['buildup_start_date']) && time() > $event_config['buildup_start_date']) { 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.'); -- cgit v1.2.3-70-g09d2