From d71e7bbfad2f07f82df0c515608996d250fd4182 Mon Sep 17 00:00:00 2001 From: Bot Date: Mon, 2 Jan 2017 15:43:36 +0100 Subject: Formatting --- includes/view/AngelTypes_view.php | 336 +++++++++------ includes/view/EventConfig_view.php | 180 ++++---- includes/view/Questions_view.php | 42 +- includes/view/Rooms_view.php | 8 +- includes/view/ShiftCalendarLane.php | 62 +-- includes/view/ShiftCalendarRenderer.php | 381 ++++++++-------- includes/view/ShiftCalendarShiftRenderer.php | 327 +++++++------- includes/view/ShiftEntry_view.php | 44 +- includes/view/ShiftTypes_view.php | 103 +++-- includes/view/ShiftsFilterRenderer.php | 108 ++--- includes/view/Shifts_view.php | 170 +++++--- includes/view/UserAngelTypes_view.php | 139 +++--- includes/view/UserDriverLicenses_view.php | 64 +-- includes/view/UserHintsRenderer.php | 100 ++--- includes/view/User_view.php | 623 ++++++++++++++++----------- 15 files changed, 1522 insertions(+), 1165 deletions(-) (limited to 'includes/view') diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php index bade3664..0458a5db 100644 --- a/includes/view/AngelTypes_view.php +++ b/includes/view/AngelTypes_view.php @@ -42,12 +42,16 @@ function AngelType_render_membership($user_angeltype) function AngelType_delete_view($angeltype) { return page_with_title(sprintf(_("Delete angeltype %s"), $angeltype['name']), [ - info(sprintf(_("Do you want to delete angeltype %s?"), $angeltype['name']), true), - buttons([ - button(page_link_to('angeltypes'), _("cancel"), 'cancel'), - button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'] . '&confirmed', _("delete"), 'ok') - ]) - ]); + info(sprintf(_("Do you want to delete angeltype %s?"), $angeltype['name']), true), + buttons([ + button(page_link_to('angeltypes'), _("cancel"), 'cancel'), + button( + page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'] . '&confirmed', + _("delete"), + 'ok' + ) + ]) + ]); } /** @@ -55,31 +59,46 @@ function AngelType_delete_view($angeltype) * * @param Angeltype $angeltype * The angeltype to edit - * @param boolean $supporter_mode + * @param boolean $supporter_mode * Is the user a supporter of this 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') - ]), - msg(), - form([ - $supporter_mode ? form_info(_("Name"), $angeltype['name']) : form_text('name', _("Name"), $angeltype['name']), - $supporter_mode ? form_info(_("Restricted"), $angeltype['restricted'] ? _("Yes") : _("No")) : form_checkbox('restricted', _("Restricted"), $angeltype['restricted']), - $supporter_mode ? form_info(_("No Self Sign Up"), $angeltype['no_self_signup'] ? _("Yes") : _("No")) : form_checkbox('no_self_signup', _("No Self Sign Up"), $angeltype['no_self_signup']), - $supporter_mode ? form_info(_("Requires driver license"), $angeltype['requires_driver_license'] ? _("Yes") : _("No")) : form_checkbox('requires_driver_license', _("Requires driver license"), $angeltype['requires_driver_license']), - //form_text('contact_name', _("Name"), $angeltype['contact_name']), - //form_text('contact_dect', _("DECT"), $angeltype['contact_dect']), - //form_text('contact_email', _("E-Mail"), $angeltype['contact_email']), - form_info("", _("Restricted angel types can only be used by an angel if enabled by a supporter (double opt-in).")), - form_textarea('description', _("Description"), $angeltype['description']), - form_info("", _("Please use markdown for the description.")), - form_submit('submit', _("Save")) - ]) - ]); + buttons([ + button(page_link_to('angeltypes'), _("Angeltypes"), 'back') + ]), + msg(), + form([ + $supporter_mode + ? form_info(_("Name"), $angeltype['name']) + : form_text('name', _("Name"), $angeltype['name']), + $supporter_mode + ? form_info(_("Restricted"), $angeltype['restricted'] ? _("Yes") : _("No")) + : form_checkbox('restricted', _("Restricted"), $angeltype['restricted']), + $supporter_mode + ? form_info(_("No Self Sign Up"), $angeltype['no_self_signup'] ? _("Yes") : _("No")) + : form_checkbox('no_self_signup', _("No Self Sign Up"), $angeltype['no_self_signup']), + $supporter_mode + ? form_info(_("Requires driver license"), $angeltype['requires_driver_license'] ? _("Yes") : _("No")) + : form_checkbox( + 'requires_driver_license', + _("Requires driver license"), + $angeltype['requires_driver_license'] + ), + //form_text('contact_name', _("Name"), $angeltype['contact_name']), + //form_text('contact_dect', _("DECT"), $angeltype['contact_dect']), + //form_text('contact_email', _("E-Mail"), $angeltype['contact_email']), + form_info( + "", + _("Restricted angel types can only be used by an angel if enabled by a supporter (double opt-in).") + ), + form_textarea('description', _("Description"), $angeltype['description']), + form_info("", _("Please use markdown for the description.")), + form_submit('submit', _("Save")) + ]) + ]); } /** @@ -88,33 +107,49 @@ function AngelType_edit_view($angeltype, $supporter_mode) function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user) { $buttons = [ - button(page_link_to('angeltypes'), _("Angeltypes"), 'back') - ]; - + button(page_link_to('angeltypes'), _("Angeltypes"), 'back') + ]; + if ($angeltype['requires_driver_license']) { $buttons[] = button(user_driver_license_edit_link($user), glyph("road") . _("my driving license")); } - + if ($user_angeltype == null) { - $buttons[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), 'add'); + $buttons[] = button( + page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], + _("join"), + 'add' + ); } else { if ($angeltype['requires_driver_license'] && $user_driver_license == null) { error(_("This angeltype requires a driver license. Please enter your driver license information!")); } - + if ($angeltype['restricted'] && $user_angeltype['confirm_user_id'] == null) { - error(sprintf(_("You are unconfirmed for this angeltype. Please go to the introduction for %s to get confirmed."), $angeltype['name'])); + error(sprintf( + _("You are unconfirmed for this angeltype. Please go to the introduction for %s to get confirmed."), + $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'], _("edit"), 'edit'); + $buttons[] = button( + 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'], _("delete"), 'delete'); + $buttons[] = button( + page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'], + _("delete"), + 'delete' + ); } - + return buttons($buttons); } @@ -130,7 +165,7 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a $members_unconfirmed = []; foreach ($members as $member) { $member['Nick'] = User_Nick_render($member); - + if ($angeltype['requires_driver_license']) { $member['wants_to_drive'] = glyph_bool($member['user_id']); $member['has_car'] = glyph_bool($member['has_car']); @@ -140,18 +175,30 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a $member['has_license_12_5t_truck'] = glyph_bool($member['has_license_12_5t_truck']); $member['has_license_forklift'] = glyph_bool($member['has_license_forklift']); } - + 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'], _("confirm"), 'btn-xs'), - button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'], _("deny"), 'btn-xs') - ]); + button( + 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'], + _("deny"), + 'btn-xs' + ) + ]); $members_unconfirmed[] = $member; } elseif ($member['supporter']) { if ($admin_angeltypes) { $member['actions'] = table_buttons([ - button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&supporter=0', _("Remove supporter rights"), 'btn-xs') - ]); + button( + page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&supporter=0', + _("Remove supporter rights"), + 'btn-xs' + ) + ]); } else { $member['actions'] = ''; } @@ -159,19 +206,26 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a } else { 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', _("Add supporter rights"), 'btn-xs') : '', - button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'], _("remove"), 'btn-xs') - ]); + $admin_angeltypes + ? 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'], + _("remove"), + 'btn-xs' + ) + ]); } $members_confirmed[] = $member; } } - + return [ - $supporters, - $members_confirmed, - $members_unconfirmed - ]; + $supporters, + $members_confirmed, + $members_unconfirmed + ]; } /** @@ -181,82 +235,103 @@ function AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes) { if ($angeltype['requires_driver_license'] && ($supporter || $admin_angeltypes)) { return [ - 'Nick' => _("Nick"), - 'DECT' => _("DECT"), - 'wants_to_drive' => _("Driver"), - 'has_car' => _("Has car"), - 'has_license_car' => _("Car"), - 'has_license_3_5t_transporter' => _("3,5t Transporter"), - 'has_license_7_5t_truck' => _("7,5t Truck"), - 'has_license_12_5t_truck' => _("12,5t Truck"), - 'has_license_forklift' => _("Forklift"), - 'actions' => '' - ]; + 'Nick' => _("Nick"), + 'DECT' => _("DECT"), + 'wants_to_drive' => _("Driver"), + 'has_car' => _("Has car"), + 'has_license_car' => _("Car"), + 'has_license_3_5t_transporter' => _("3,5t Transporter"), + 'has_license_7_5t_truck' => _("7,5t Truck"), + 'has_license_12_5t_truck' => _("12,5t Truck"), + 'has_license_forklift' => _("Forklift"), + 'actions' => '' + ]; } return [ - 'Nick' => _("Nick"), - 'DECT' => _("DECT"), - 'actions' => '' - ]; + 'Nick' => _("Nick"), + 'DECT' => _("DECT"), + 'actions' => '' + ]; } /** * Render an angeltype page containing the member lists. */ -function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angeltypes, $admin_angeltypes, $supporter, $user_driver_license, $user) -{ +function AngelType_view( + $angeltype, + $members, + $user_angeltype, + $admin_user_angeltypes, + $admin_angeltypes, + $supporter, + $user_driver_license, + $user +) { $page = [ - AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user), - msg() - ]; - + AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user), + msg() + ]; + $page[] = '

' . _("Description") . '

'; $parsedown = new Parsedown(); if ($angeltype['description'] != "") { $page[] = '
' . $parsedown->parse($angeltype['description']) . '
'; } - - list($supporters, $members_confirmed, $members_unconfirmed) = AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $admin_angeltypes); + + list($supporters, $members_confirmed, $members_unconfirmed) = AngelType_view_members( + $angeltype, + $members, + $admin_user_angeltypes, + $admin_angeltypes + ); $table_headers = AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes); - + if (count($supporters) > 0) { $page[] = '

' . _("supporters") . '

'; $page[] = table($table_headers, $supporters); } - + if (count($members_confirmed) > 0) { $members_confirmed[] = [ - 'Nick' => _('Sum'), - 'DECT' => count($members_confirmed), - 'actions' => '' - ]; + 'Nick' => _('Sum'), + 'DECT' => count($members_confirmed), + 'actions' => '' + ]; } - + if (count($members_unconfirmed) > 0) { $members_unconfirmed[] = [ - 'Nick' => _('Sum'), - 'DECT' => count($members_unconfirmed), - 'actions' => '' - ]; + 'Nick' => _('Sum'), + 'DECT' => count($members_unconfirmed), + 'actions' => '' + ]; } - + $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); - + if ($admin_user_angeltypes && $angeltype['restricted'] && count($members_unconfirmed) > 0) { $page[] = '

' . _("Unconfirmed") . '

'; $page[] = buttons([ - button(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'], _("deny all"), 'cancel') - ]); + button( + 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'], + _("deny all"), + 'cancel' + ) + ]); $page[] = table($table_headers, $members_unconfirmed); } - + return page_with_title(sprintf(_("Team %s"), $angeltype['name']), $page); } @@ -268,19 +343,19 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel 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")) - ]), - table([ - 'name' => _("Name"), - 'restricted' => glyph('lock') . _("Restricted"), - 'no_self_signup' => glyph('share') . _("Self Sign Up Allowed"), - 'membership' => _("Membership"), - 'actions' => "" - ], $angeltypes) - ]); + msg(), + buttons([ + $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"), + 'restricted' => glyph('lock') . _("Restricted"), + 'no_self_signup' => glyph('share') . _("Self Sign Up Allowed"), + 'membership' => _("Membership"), + 'actions' => "" + ], $angeltypes) + ]); } /** @@ -289,27 +364,38 @@ function AngelTypes_list_view($angeltypes, $admin_angeltypes) function AngelTypes_about_view_angeltype($angeltype) { $parsedown = new Parsedown(); - + $html = '

' . $angeltype['name'] . '

'; - + if (isset($angeltype['user_angeltype_id'])) { $buttons = []; if ($angeltype['user_angeltype_id'] != null) { - $buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $angeltype['user_angeltype_id'], _("leave"), 'cancel'); + $buttons[] = button( + 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'], _("join"), 'add'); + $buttons[] = button( + page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], + _("join"), + 'add' + ); } $html .= buttons($buttons); } - + if ($angeltype['restricted']) { - $html .= info(_("This angeltype is restricted by double-opt-in by a team supporter. Please show up at the according introduction meetings."), true); + $html .= info( + _("This angeltype is restricted by double-opt-in by a team supporter. Please show up at the according introduction meetings."), + true + ); } if ($angeltype['description'] != "") { $html .= '
' . $parsedown->parse($angeltype['description']) . '
'; } $html .= '
'; - + return $html; } @@ -319,20 +405,20 @@ function AngelTypes_about_view_angeltype($angeltype) function AngelTypes_about_view($angeltypes, $user_logged_in) { global $faq_url; - + $content = [ - buttons([ - ! $user_logged_in ? button(page_link_to('register'), register_title()) : '', - ! $user_logged_in ? button(page_link_to('login'), login_title()) : '', - $user_logged_in ? button(page_link_to('angeltypes'), angeltypes_title(), 'back') : '', - button($faq_url, _("FAQ"), "btn-primary") - ]), - '

' . _("Here is the list of teams and their tasks. If you have questions, read the FAQ.") . '

', - '
' - ]; + buttons([ + !$user_logged_in ? button(page_link_to('register'), register_title()) : '', + !$user_logged_in ? button(page_link_to('login'), login_title()) : '', + $user_logged_in ? button(page_link_to('angeltypes'), angeltypes_title(), 'back') : '', + button($faq_url, _("FAQ"), "btn-primary") + ]), + '

' . _("Here is the list of teams and their tasks. If you have questions, read the FAQ.") . '

', + '
' + ]; foreach ($angeltypes as $angeltype) { $content[] = AngelTypes_about_view_angeltype($angeltype); } - + return page_with_title(_("Teams/Job description"), $content); } diff --git a/includes/view/EventConfig_view.php b/includes/view/EventConfig_view.php index 87002399..9f24f9c9 100644 --- a/includes/view/EventConfig_view.php +++ b/includes/view/EventConfig_view.php @@ -2,56 +2,60 @@ /** * Shows basic event infos and countdowns. + * * @param EventConfig $event_config The event configuration */ function EventConfig_countdown_page($event_config) { if ($event_config == null) { return div('col-md-12 text-center', [ - heading(sprintf(_("Welcome to the %s!"), ' ENGELSYSTEM'), 2) - ]); + heading(sprintf(_("Welcome to the %s!"), ' ENGELSYSTEM'), 2) + ]); } - + $elements = []; - + if ($event_config['event_name'] != null) { $elements[] = div('col-sm-12 text-center', [ - heading(sprintf(_("Welcome to the %s!"), $event_config['event_name'] . ' ENGELSYSTEM'), 2) - ]); + heading(sprintf( + _("Welcome to the %s!"), + $event_config['event_name'] . ' ENGELSYSTEM' + ), 2) + ]); } - + if ($event_config['buildup_start_date'] != null && time() < $event_config['buildup_start_date']) { $elements[] = div('col-sm-3 text-center hidden-xs', [ - heading(_("Buildup starts"), 4), - '%c', - '' . date(_("Y-m-d"), $event_config['buildup_start_date']) . '' - ]); + heading(_("Buildup starts"), 4), + '%c', + '' . date(_("Y-m-d"), $event_config['buildup_start_date']) . '' + ]); } - + if ($event_config['event_start_date'] != null && time() < $event_config['event_start_date']) { $elements[] = div('col-sm-3 text-center hidden-xs', [ - heading(_("Event starts"), 4), - '%c', - '' . date(_("Y-m-d"), $event_config['event_start_date']) . '' - ]); + heading(_("Event starts"), 4), + '%c', + '' . date(_("Y-m-d"), $event_config['event_start_date']) . '' + ]); } - + if ($event_config['event_end_date'] != null && time() < $event_config['event_end_date']) { $elements[] = div('col-sm-3 text-center hidden-xs', [ - heading(_("Event ends"), 4), - '%c', - '' . date(_("Y-m-d"), $event_config['event_end_date']) . '' - ]); + heading(_("Event ends"), 4), + '%c', + '' . date(_("Y-m-d"), $event_config['event_end_date']) . '' + ]); } - + if ($event_config['teardown_end_date'] != null && time() < $event_config['teardown_end_date']) { $elements[] = div('col-sm-3 text-center hidden-xs', [ - heading(_("Teardown ends"), 4), - '%c', - '' . date(_("Y-m-d"), $event_config['teardown_end_date']) . '' - ]); + heading(_("Teardown ends"), 4), + '%c', + '' . date(_("Y-m-d"), $event_config['teardown_end_date']) . '' + ]); } - + return join("", $elements); } @@ -63,27 +67,39 @@ function EventConfig_info($event_config) if ($event_config == null) { return ""; } - - // Event name, start+end date are set - if ($event_config['event_name'] != null && $event_config['event_start_date'] != null && $event_config['event_end_date'] != null) { - return sprintf(_("%s, from %s to %s"), $event_config['event_name'], date(_("Y-m-d"), $event_config['event_start_date']), date(_("Y-m-d"), $event_config['event_end_date'])); - } - - // Event name, start date are set - if ($event_config['event_name'] != null && $event_config['event_start_date'] != null) { - return sprintf(_("%s, starting %s"), $event_config['event_name'], date(_("Y-m-d"), $event_config['event_start_date'])); - } - - // Event start+end date are set - if ($event_config['event_start_date'] != null && $event_config['event_end_date'] != null) { - return sprintf(_("Event from %s to %s"), date(_("Y-m-d"), $event_config['event_start_date']), date(_("Y-m-d"), $event_config['event_end_date'])); - } - - // Only event name is set - if ($event_config['event_name'] != null) { - return sprintf($event_config['event_name']); - } - + + // Event name, start+end date are set + if ($event_config['event_name'] != null && $event_config['event_start_date'] != null && $event_config['event_end_date'] != null) { + return sprintf( + _("%s, from %s to %s"), + $event_config['event_name'], + date(_("Y-m-d"), $event_config['event_start_date']), + date(_("Y-m-d"), $event_config['event_end_date']) + ); + } + + // Event name, start date are set + if ($event_config['event_name'] != null && $event_config['event_start_date'] != null) { + return sprintf( + _("%s, starting %s"), $event_config['event_name'], + date(_("Y-m-d"), $event_config['event_start_date']) + ); + } + + // Event start+end date are set + if ($event_config['event_start_date'] != null && $event_config['event_end_date'] != null) { + return sprintf( + _("Event from %s to %s"), + date(_("Y-m-d"), $event_config['event_start_date']), + date(_("Y-m-d"), $event_config['event_end_date']) + ); + } + + // Only event name is set + if ($event_config['event_name'] != null) { + return sprintf($event_config['event_name']); + } + return ""; } @@ -94,37 +110,43 @@ function EventConfig_info($event_config) * The event name * @param string $event_welcome_msg * The welcome message - * @param date $buildup_start_date - * @param date $event_start_date - * @param date $event_end_date - * @param date $teardown_end_date + * @param date $buildup_start_date + * @param date $event_start_date + * @param date $event_end_date + * @param date $teardown_end_date */ -function EventConfig_edit_view($event_name, $event_welcome_msg, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date) -{ +function EventConfig_edit_view( + $event_name, + $event_welcome_msg, + $buildup_start_date, + $event_start_date, + $event_end_date, + $teardown_end_date +) { return page_with_title(event_config_title(), [ - msg(), - form([ - div('row', [ - div('col-md-6', [ - form_text('event_name', _("Event Name"), $event_name), - form_info('', _("Event Name is shown on the start page.")), - form_textarea('event_welcome_msg', _("Event Welcome Message"), $event_welcome_msg), - form_info('', _("Welcome message is shown after successful registration. You can use markdown.")) - ]), - div('col-md-3 col-xs-6', [ - form_date('buildup_start_date', _("Buildup date"), $buildup_start_date), - form_date('event_start_date', _("Event start date"), $event_start_date) - ]), - div('col-md-3 col-xs-6', [ - form_date('teardown_end_date', _("Teardown end date"), $teardown_end_date), - form_date('event_end_date', _("Event end date"), $event_end_date) - ]) - ]), - div('row', [ - div('col-md-6', [ - form_submit('submit', _("Save")) - ]) - ]) - ]) - ]); + msg(), + form([ + div('row', [ + div('col-md-6', [ + form_text('event_name', _("Event Name"), $event_name), + form_info('', _("Event Name is shown on the start page.")), + form_textarea('event_welcome_msg', _("Event Welcome Message"), $event_welcome_msg), + form_info('', _("Welcome message is shown after successful registration. You can use markdown.")) + ]), + div('col-md-3 col-xs-6', [ + form_date('buildup_start_date', _("Buildup date"), $buildup_start_date), + form_date('event_start_date', _("Event start date"), $event_start_date) + ]), + div('col-md-3 col-xs-6', [ + form_date('teardown_end_date', _("Teardown end date"), $teardown_end_date), + form_date('event_end_date', _("Event end date"), $event_end_date) + ]) + ]), + div('row', [ + div('col-md-6', [ + form_submit('submit', _("Save")) + ]) + ]) + ]) + ]); } diff --git a/includes/view/Questions_view.php b/includes/view/Questions_view.php index 8446ad8b..0716780c 100644 --- a/includes/view/Questions_view.php +++ b/includes/view/Questions_view.php @@ -6,31 +6,31 @@ function Questions_view($open_questions, $answered_questions, $ask_action) $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") . ''; } - + return page_with_title(questions_title(), [ - msg(), - heading(_("Open questions"), 2), - table([ - 'Question' => _("Question"), - 'actions' => "" - ], $open_questions), - heading(_("Answered questions"), 2), - table([ - 'Question' => _("Question"), - 'answer_user' => _("Answered by"), - 'Answer' => _("Answer"), - 'actions' => "" - ], $answered_questions), - heading(_("Ask the Heaven"), 2), - form([ - form_textarea('question', _("Your Question:"), ""), - form_submit('submit', _("Save")) - ], $ask_action) - ]); + msg(), + heading(_("Open questions"), 2), + table([ + 'Question' => _("Question"), + 'actions' => "" + ], $open_questions), + heading(_("Answered questions"), 2), + table([ + 'Question' => _("Question"), + 'answer_user' => _("Answered by"), + 'Answer' => _("Answer"), + 'actions' => "" + ], $answered_questions), + heading(_("Ask the Heaven"), 2), + form([ + form_textarea('question', _("Your Question:"), ""), + form_submit('submit', _("Save")) + ], $ask_action) + ]); } diff --git a/includes/view/Rooms_view.php b/includes/view/Rooms_view.php index 892c5968..db883fa9 100644 --- a/includes/view/Rooms_view.php +++ b/includes/view/Rooms_view.php @@ -1,13 +1,13 @@ render(room_link($room)) , - $shiftCalendarRenderer->render() - ]); + $shiftsFilterRenderer->render(room_link($room)), + $shiftCalendarRenderer->render() + ]); } function Room_name_render($room) diff --git a/includes/view/ShiftCalendarLane.php b/includes/view/ShiftCalendarLane.php index af674671..529b6a74 100644 --- a/includes/view/ShiftCalendarLane.php +++ b/includes/view/ShiftCalendarLane.php @@ -22,38 +22,38 @@ class ShiftCalendarLane $this->blockCount = $blockCount; } - /** - * Adds a shift to the lane, but only if it fits. - * Returns true on success. - * - * @param Shift $shift - * The shift to add - * @return boolean true on success - */ - public function addShift($shift) - { - if ($this->shiftFits($shift)) { - $this->shifts[] = $shift; - return true; - } - return false; - } + /** + * Adds a shift to the lane, but only if it fits. + * Returns true on success. + * + * @param Shift $shift + * The shift to add + * @return boolean true on success + */ + public function addShift($shift) + { + if ($this->shiftFits($shift)) { + $this->shifts[] = $shift; + return true; + } + return false; + } - /** - * Returns true if given shift fits into this lane. - * - * @param Shift $shift - * The shift to fit into this lane - */ - public function shiftFits($newShift) - { - foreach ($this->shifts as $laneShift) { - if (! ($newShift['start'] >= $laneShift['end'] || $newShift['end'] <= $laneShift['start'])) { - return false; - } - } - return true; - } + /** + * Returns true if given shift fits into this lane. + * + * @param Shift $shift + * The shift to fit into this lane + */ + public function shiftFits($newShift) + { + foreach ($this->shifts as $laneShift) { + if (!($newShift['start'] >= $laneShift['end'] || $newShift['end'] <= $laneShift['start'])) { + return false; + } + } + return true; + } public function getHeader() { diff --git a/includes/view/ShiftCalendarRenderer.php b/includes/view/ShiftCalendarRenderer.php index d40f63a1..c875af39 100644 --- a/includes/view/ShiftCalendarRenderer.php +++ b/includes/view/ShiftCalendarRenderer.php @@ -5,26 +5,26 @@ namespace Engelsystem; class ShiftCalendarRenderer { - /** - * 15m * 60s/m = 900s - */ - const SECONDS_PER_ROW = 900; - - /** - * Height of a block in pixel. - * Do not change - corresponds with theme/css - */ - const BLOCK_HEIGHT = 30; - - /** - * Distance between two shifts in pixels - */ - const MARGIN = 5; - - /** - * Seconds added to the start and end time - */ - const TIME_MARGIN = 1800; + /** + * 15m * 60s/m = 900s + */ + const SECONDS_PER_ROW = 900; + + /** + * Height of a block in pixel. + * Do not change - corresponds with theme/css + */ + const BLOCK_HEIGHT = 30; + + /** + * Distance between two shifts in pixels + */ + const MARGIN = 5; + + /** + * Seconds added to the start and end time + */ + const TIME_MARGIN = 1800; private $lanes; @@ -50,51 +50,51 @@ class ShiftCalendarRenderer $this->shift_entries = $shift_entries; } - /** - * Assigns the shifts to different lanes per room if they collide - * - * @param Shift[] $shifts - * The shifts to assign - * - * @return Returns an array that assigns a room_id to an array of ShiftCalendarLane containing the shifts - */ - private function assignShiftsToLanes($shifts) - { - // array that assigns a room id to a list of lanes (per room) - $lanes = []; - - foreach ($shifts as $shift) { - $room_id = $shift['RID']; - $header = Room_name_render([ - 'RID' => $room_id, - 'Name' => $shift['room_name'] - ]); - if (! isset($lanes[$room_id])) { - // initialize room with one lane - $lanes[$room_id] = [ - new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot()) - ]; - } - // Try to add the shift to the existing lanes for this room - $shift_added = false; - foreach ($lanes[$room_id] as $lane) { - $shift_added = $lane->addShift($shift); - if ($shift_added == true) { - break; - } - } - // If all lanes for this room are busy, create a new lane and add shift to it - if ($shift_added == false) { - $newLane = new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot()); - if (! $newLane->addShift($shift)) { - engelsystem_error("Unable to add shift to new lane."); - } - $lanes[$room_id][] = $newLane; - } - } - - return $lanes; - } + /** + * Assigns the shifts to different lanes per room if they collide + * + * @param Shift[] $shifts + * The shifts to assign + * + * @return Returns an array that assigns a room_id to an array of ShiftCalendarLane containing the shifts + */ + private function assignShiftsToLanes($shifts) + { + // array that assigns a room id to a list of lanes (per room) + $lanes = []; + + foreach ($shifts as $shift) { + $room_id = $shift['RID']; + $header = Room_name_render([ + 'RID' => $room_id, + 'Name' => $shift['room_name'] + ]); + if (!isset($lanes[$room_id])) { + // initialize room with one lane + $lanes[$room_id] = [ + new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot()) + ]; + } + // Try to add the shift to the existing lanes for this room + $shift_added = false; + foreach ($lanes[$room_id] as $lane) { + $shift_added = $lane->addShift($shift); + if ($shift_added == true) { + break; + } + } + // If all lanes for this room are busy, create a new lane and add shift to it + if ($shift_added == false) { + $newLane = new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot()); + if (!$newLane->addShift($shift)) { + engelsystem_error("Unable to add shift to new lane."); + } + $lanes[$room_id][] = $newLane; + } + } + + return $lanes; + } public function getFirstBlockStartTime() { @@ -114,118 +114,119 @@ class ShiftCalendarRenderer return $this->blocksPerSlot; } - /** - * Renders the whole calendar - * - * @return the generated html - */ - public function render() - { - if (count($this->lanes) == 0) { - return ''; - } - return div('shift-calendar', [ - $this->renderTimeLane(), - $this->renderShiftLanes() - ]) . $this->renderLegend(); - } - - /** - * Renders the lanes containing the shifts - */ - private function renderShiftLanes() - { - $html = ""; - foreach ($this->lanes as $room_lanes) { - foreach ($room_lanes as $lane) { - $html .= $this->renderLane($lane); - } - } - - return $html; - } - - /** - * Renders a single lane - * - * @param ShiftCalendarLane $lane - * The lane to render - */ - 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); - $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 - ]); - } - - /** - * Renders a tick/block for given time - * - * @param int $time - * unix timestamp - * @param boolean $label - * Should time labels be generated? - * @return rendered tick html - */ - private function renderTick($time, $label = false) - { - if ($time % (24 * 60 * 60) == 23 * 60 * 60) { - if (! $label) { - return div('tick day'); - } - return div('tick day', [ - date('m-dH:i', $time) - ]); - } elseif ($time % (60 * 60) == 0) { - if (! $label) { - return div('tick hour'); - } - return div('tick hour', [ - date('m-dH:i', $time) - ]); - } - return div('tick'); - } - - /** - * Renders the left time lane including hour/day ticks - */ - private function renderTimeLane() - { - $time_slot = [ - div('header', [ - _("Time") - ]) - ]; - for ($block = 0; $block < $this->getBlocksPerSlot(); $block ++) { - $thistime = $this->getFirstBlockStartTime() + ($block * ShiftCalendarRenderer::SECONDS_PER_ROW); - $time_slot[] = $this->renderTick($thistime, true); - } - return div('lane time', $time_slot); - } + /** + * Renders the whole calendar + * + * @return the generated html + */ + public function render() + { + if (count($this->lanes) == 0) { + return ''; + } + return div('shift-calendar', [ + $this->renderTimeLane(), + $this->renderShiftLanes() + ]) . $this->renderLegend(); + } + + /** + * Renders the lanes containing the shifts + */ + private function renderShiftLanes() + { + $html = ""; + foreach ($this->lanes as $room_lanes) { + foreach ($room_lanes as $lane) { + $html .= $this->renderLane($lane); + } + } + + return $html; + } + + /** + * Renders a single lane + * + * @param ShiftCalendarLane $lane + * The lane to render + */ + 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); + $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 + ]); + } + + /** + * Renders a tick/block for given time + * + * @param int $time + * unix timestamp + * @param boolean $label + * Should time labels be generated? + * @return rendered tick html + */ + private function renderTick($time, $label = false) + { + if ($time % (24 * 60 * 60) == 23 * 60 * 60) { + if (!$label) { + return div('tick day'); + } + return div('tick day', [ + date('m-dH:i', $time) + ]); + } elseif ($time % (60 * 60) == 0) { + if (!$label) { + return div('tick hour'); + } + return div('tick hour', [ + date('m-dH:i', $time) + ]); + } + return div('tick'); + } + + /** + * Renders the left time lane including hour/day ticks + */ + private function renderTimeLane() + { + $time_slot = [ + div('header', [ + _("Time") + ]) + ]; + for ($block = 0; $block < $this->getBlocksPerSlot(); $block++) { + $thistime = $this->getFirstBlockStartTime() + ($block * ShiftCalendarRenderer::SECONDS_PER_ROW); + $time_slot[] = $this->renderTick($thistime, true); + } + return div('lane time', $time_slot); + } private function calcFirstBlockStartTime($shifts) { @@ -254,17 +255,17 @@ class ShiftCalendarRenderer return ceil(($this->getLastBlockEndTime() - $this->getFirstBlockStartTime()) / ShiftCalendarRenderer::SECONDS_PER_ROW); } - /** - * Renders a legend explaining the shift coloring - */ - private function renderLegend() - { - return div('legend', [ - label(_('Your shift'), 'primary'), - label(_('Help needed'), 'danger'), - label(_('Other angeltype needed / collides with my shifts'), 'warning'), - label(_('Shift is full'), 'success'), - label(_('Shift running/ended'), 'default') - ]); - } + /** + * Renders a legend explaining the shift coloring + */ + private function renderLegend() + { + return div('legend', [ + label(_('Your shift'), 'primary'), + label(_('Help needed'), 'danger'), + label(_('Other angeltype needed / collides with my shifts'), 'warning'), + label(_('Shift is full'), 'success'), + label(_('Shift running/ended'), 'default') + ]); + } } diff --git a/includes/view/ShiftCalendarShiftRenderer.php b/includes/view/ShiftCalendarShiftRenderer.php index 6d6523c5..64421637 100644 --- a/includes/view/ShiftCalendarShiftRenderer.php +++ b/includes/view/ShiftCalendarShiftRenderer.php @@ -8,69 +8,77 @@ namespace Engelsystem; class ShiftCalendarShiftRenderer { - /** - * Renders a shift - * - * @param Shift $shift - * The shift to render - * @param User $user - * The user who is viewing the shift calendar - */ - public function render($shift, $needed_angeltypes, $shift_entries, $user) - { - $info_text = ""; - if ($shift['title'] != '') { - $info_text = glyph('info-sign') . $shift['title'] . '
'; - } - list($shift_signup_state, $shifts_row) = $this->renderShiftNeededAngeltypes($shift, $needed_angeltypes, $shift_entries, $user); - - $class = $this->classForSignupState($shift_signup_state); - - $blocks = ceil(($shift["end"] - $shift["start"]) / ShiftCalendarRenderer::SECONDS_PER_ROW); - $blocks = max(1, $blocks); - return [ - $blocks, - div('shift panel panel-' . $class . '" style="height: ' . ($blocks * ShiftCalendarRenderer::BLOCK_HEIGHT - ShiftCalendarRenderer::MARGIN) . 'px"', [ - $this->renderShiftHead($shift), - div('panel-body', [ - $info_text, - Room_name_render([ - 'RID' => $shift['RID'], - 'Name' => $shift['room_name'] - ]) - ]), - $shifts_row, - div('shift-spacer') - ]) - ]; - } + /** + * Renders a shift + * + * @param Shift $shift + * The shift to render + * @param User $user + * The user who is viewing the shift calendar + */ + public function render($shift, $needed_angeltypes, $shift_entries, $user) + { + $info_text = ""; + if ($shift['title'] != '') { + $info_text = glyph('info-sign') . $shift['title'] . '
'; + } + list($shift_signup_state, $shifts_row) = $this->renderShiftNeededAngeltypes( + $shift, + $needed_angeltypes, + $shift_entries, + $user + ); + + $class = $this->classForSignupState($shift_signup_state); + + $blocks = ceil(($shift["end"] - $shift["start"]) / ShiftCalendarRenderer::SECONDS_PER_ROW); + $blocks = max(1, $blocks); + return [ + $blocks, + div( + 'shift panel panel-' . $class . '" style="height: ' . ($blocks * ShiftCalendarRenderer::BLOCK_HEIGHT - ShiftCalendarRenderer::MARGIN) . 'px"', + [ + $this->renderShiftHead($shift), + div('panel-body', [ + $info_text, + Room_name_render([ + 'RID' => $shift['RID'], + 'Name' => $shift['room_name'] + ]) + ]), + $shifts_row, + div('shift-spacer') + ] + ) + ]; + } private function classForSignupState(ShiftSignupState $shiftSignupState) { switch ($shiftSignupState->getState()) { - case ShiftSignupState::ADMIN: - case ShiftSignupState::OCCUPIED: - return 'success'; - - case ShiftSignupState::SIGNED_UP: - return 'primary'; - - case ShiftSignupState::SHIFT_ENDED: - return 'default'; - - case ShiftSignupState::ANGELTYPE: - case ShiftSignupState::COLLIDES: - return 'warning'; - - case ShiftSignupState::FREE: - return 'danger'; - } + case ShiftSignupState::ADMIN: + case ShiftSignupState::OCCUPIED: + return 'success'; + + case ShiftSignupState::SIGNED_UP: + return 'primary'; + + case ShiftSignupState::SHIFT_ENDED: + return 'default'; + + case ShiftSignupState::ANGELTYPE: + case ShiftSignupState::COLLIDES: + return 'warning'; + + case ShiftSignupState::FREE: + return 'danger'; + } } private function renderShiftNeededAngeltypes($shift, $needed_angeltypes, $shift_entries, $user) { global $privileges; - + $shift_entries_filtered = []; foreach ($needed_angeltypes as $needed_angeltype) { $shift_entries_filtered[$needed_angeltype['id']] = []; @@ -78,12 +86,17 @@ class ShiftCalendarShiftRenderer foreach ($shift_entries as $shift_entry) { $shift_entries_filtered[$shift_entry['TID']][] = $shift_entry; } - + $html = ""; $shift_signup_state = null; foreach ($needed_angeltypes as $angeltype) { if ($angeltype['count'] > 0 || count($shift_entries_filtered[$angeltype['id']]) > 0) { - list($angeltype_signup_state, $angeltype_html) = $this->renderShiftNeededAngeltype($shift, $shift_entries_filtered[$angeltype['id']], $angeltype, $user); + list($angeltype_signup_state, $angeltype_html) = $this->renderShiftNeededAngeltype( + $shift, + $shift_entries_filtered[$angeltype['id']], + $angeltype, + $user + ); if ($shift_signup_state == null) { $shift_signup_state = $angeltype_signup_state; } else { @@ -95,105 +108,125 @@ class ShiftCalendarShiftRenderer if ($shift_signup_state == null) { $shift_signup_state = new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, 0); } - + if (in_array('user_shifts_admin', $privileges)) { - $html .= '
  • ' . button(page_link_to('user_shifts') . '&shift_id=' . $shift['SID'], _("Add more angels"), 'btn-xs') . '
  • '; + $html .= '
  • ' . button( + page_link_to('user_shifts') . '&shift_id=' . $shift['SID'], + _("Add more angels"), + 'btn-xs' + ) . '
  • '; } if ($html != '') { return [ - $shift_signup_state, - '
      ' . $html . '
    ' - ]; + $shift_signup_state, + '
      ' . $html . '
    ' + ]; } return [ - $shift_signup_state, - "" - ]; + $shift_signup_state, + "" + ]; } - /** - * Renders a list entry containing the needed angels for an angeltype - * - * @param Shift $shift - * The shift which is rendered - * @param Angeltype $angeltype - * The angeltype, containing informations about needed angeltypes and already signed up angels - * @param User $user - * The user who is viewing the shift calendar - */ - private function renderShiftNeededAngeltype($shift, $shift_entries, $angeltype, $user) - { - $entry_list = []; - foreach ($shift_entries as $entry) { - $style = $entry['freeloaded'] ? " text-decoration: line-through;" : ''; - $entry_list[] = "" . User_Nick_render($entry) . ""; - } - $shift_signup_state = Shift_signup_allowed($user, $shift, $angeltype, null, null, $angeltype, $shift_entries); - $inner_text = sprintf(ngettext("%d helper needed", "%d helpers needed", $shift_signup_state->getFreeEntries()), $shift_signup_state->getFreeEntries()); - switch ($shift_signup_state->getState()) { - case ShiftSignupState::ADMIN: - case ShiftSignupState::FREE: - // When admin or free display a link + button for sign up - $entry_list[] = '' . $inner_text . ' ' . button(page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'], _('Sign up'), 'btn-xs btn-primary'); - break; - - case ShiftSignupState::SHIFT_ENDED: - // No link and add a text hint, when the shift ended - $entry_list[] = $inner_text . ' (' . _('ended') . ')'; - break; - - case ShiftSignupState::ANGELTYPE: - if ($angeltype['restricted'] == 1) { - // User has to be confirmed on the angeltype first - $entry_list[] = $inner_text . glyph('lock'); - } else { - // Add link to join the angeltype first - $entry_list[] = $inner_text . '
    ' . button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], sprintf(_('Become %s'), $angeltype['name']), 'btn-xs'); + /** + * Renders a list entry containing the needed angels for an angeltype + * + * @param Shift $shift + * The shift which is rendered + * @param Angeltype $angeltype + * The angeltype, containing informations about needed angeltypes and already signed up angels + * @param User $user + * The user who is viewing the shift calendar + */ + private function renderShiftNeededAngeltype($shift, $shift_entries, $angeltype, $user) + { + $entry_list = []; + foreach ($shift_entries as $entry) { + $style = $entry['freeloaded'] ? " text-decoration: line-through;" : ''; + $entry_list[] = "" . User_Nick_render($entry) . ""; + } + $shift_signup_state = Shift_signup_allowed($user, $shift, $angeltype, null, null, $angeltype, $shift_entries); + $inner_text = sprintf( + ngettext("%d helper needed", "%d helpers needed", $shift_signup_state->getFreeEntries()), + $shift_signup_state->getFreeEntries() + ); + switch ($shift_signup_state->getState()) { + case ShiftSignupState::ADMIN: + case ShiftSignupState::FREE: + // When admin or free display a link + button for sign up + $entry_list[] = '' + . $inner_text + . ' ' + . button( + page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'], + _('Sign up'), 'btn-xs btn-primary' + ); + break; + + case ShiftSignupState::SHIFT_ENDED: + // No link and add a text hint, when the shift ended + $entry_list[] = $inner_text . ' (' . _('ended') . ')'; + break; + + case ShiftSignupState::ANGELTYPE: + if ($angeltype['restricted'] == 1) { + // User has to be confirmed on the angeltype first + $entry_list[] = $inner_text . glyph('lock'); + } else { + // Add link to join the angeltype first + $entry_list[] = $inner_text . '
    ' + . button( + page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], + sprintf(_('Become %s'), $angeltype['name']), + 'btn-xs' + ); + } + break; + + case ShiftSignupState::COLLIDES: + case ShiftSignupState::SIGNED_UP: + // Shift collides or user is already signed up: No signup allowed + $entry_list[] = $inner_text; + break; + + case ShiftSignupState::OCCUPIED: + // Shift is full + break; + } + + $shifts_row = '
  • '; + $shifts_row .= '' . AngelType_name_render($angeltype) . ': '; + $shifts_row .= join(", ", $entry_list); + $shifts_row .= '
  • '; + return [ + $shift_signup_state, + $shifts_row + ]; + } + + /** + * Renders the shift header + * + * @param Shift $shift + * The shift + */ + private function renderShiftHead($shift) + { + global $privileges; + + $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') + ]) . '
    '; } - break; - - case ShiftSignupState::COLLIDES: - case ShiftSignupState::SIGNED_UP: - // Shift collides or user is already signed up: No signup allowed - $entry_list[] = $inner_text; - break; - - case ShiftSignupState::OCCUPIED: - // Shift is full - break; + $shift_heading = date('H:i', $shift['start']) . ' ‐ ' + . date('H:i', $shift['end']) . ' — ' + . $shift['name']; + return div('panel-heading', [ + '' . $shift_heading . '', + $header_buttons + ]); } - - $shifts_row = '
  • '; - $shifts_row .= '' . AngelType_name_render($angeltype) . ': '; - $shifts_row .= join(", ", $entry_list); - $shifts_row .= '
  • '; - return [ - $shift_signup_state, - $shifts_row - ]; - } - - /** - * Renders the shift header - * - * @param Shift $shift - * The shift - */ - private function renderShiftHead($shift) - { - global $privileges; - - $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') - ]) . '
    '; - } - $shift_heading = date('H:i', $shift['start']) . ' ‐ ' . date('H:i', $shift['end']) . ' — ' . $shift['name']; - return div('panel-heading', [ - '' . $shift_heading . '', - $header_buttons - ]); - } } diff --git a/includes/view/ShiftEntry_view.php b/includes/view/ShiftEntry_view.php index 2c31805c..592dc99c 100644 --- a/includes/view/ShiftEntry_view.php +++ b/includes/view/ShiftEntry_view.php @@ -2,6 +2,7 @@ /** * Display form for adding/editing a shift entry. + * * @param string $angel * @param string $date * @param string $location @@ -11,26 +12,35 @@ * * @return string */ -function ShiftEntry_edit_view($angel, $date, $location, $title, $type, $comment, $freeloaded, $freeload_comment, $user_admin_shifts = false) -{ +function ShiftEntry_edit_view( + $angel, + $date, + $location, + $title, + $type, + $comment, + $freeloaded, + $freeload_comment, + $user_admin_shifts = false +) { $freeload_form = []; if ($user_admin_shifts) { $freeload_form = [ - form_checkbox('freeloaded', _("Freeloaded"), $freeloaded), - form_textarea('freeload_comment', _("Freeload comment (Only for shift coordination):"), $freeload_comment) - ]; + form_checkbox('freeloaded', _("Freeloaded"), $freeloaded), + form_textarea('freeload_comment', _("Freeload comment (Only for shift coordination):"), $freeload_comment) + ]; } return page_with_title(_("Edit shift entry"), [ - msg(), - form([ - form_info(_("Angel:"), $angel), - form_info(_("Date, Duration:"), $date), - form_info(_("Location:"), $location), - form_info(_("Title:"), $title), - form_info(_("Type:"), $type), - form_textarea('comment', _("Comment (for your eyes only):"), $comment), - join("", $freeload_form), - form_submit('submit', _("Save")) - ]) - ]); + msg(), + form([ + form_info(_("Angel:"), $angel), + form_info(_("Date, Duration:"), $date), + form_info(_("Location:"), $location), + form_info(_("Title:"), $title), + form_info(_("Type:"), $type), + form_textarea('comment', _("Comment (for your eyes only):"), $comment), + join("", $freeload_form), + form_submit('submit', _("Save")) + ]) + ]); } diff --git a/includes/view/ShiftTypes_view.php b/includes/view/ShiftTypes_view.php index e2850ab0..827eec4d 100644 --- a/includes/view/ShiftTypes_view.php +++ b/includes/view/ShiftTypes_view.php @@ -12,36 +12,40 @@ function ShiftType_name_render($shifttype) function ShiftType_delete_view($shifttype) { return page_with_title(sprintf(_("Delete shifttype %s"), $shifttype['name']), [ - info(sprintf(_("Do you want to delete shifttype %s?"), $shifttype['name']), true), - buttons([ - button(page_link_to('shifttypes'), _("cancel"), 'cancel'), - button(page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'] . '&confirmed', _("delete"), 'ok') - ]) - ]); + info(sprintf(_("Do you want to delete shifttype %s?"), $shifttype['name']), true), + buttons([ + button(page_link_to('shifttypes'), _("cancel"), 'cancel'), + button( + page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'] . '&confirmed', + _("delete"), + 'ok' + ) + ]) + ]); } function ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id) { $angeltypes_select = [ - '' => _('All') - ]; + '' => _('All') + ]; foreach ($angeltypes as $angeltype) { $angeltypes_select[$angeltype['id']] = $angeltype['name']; } - + return page_with_title($shifttype_id ? _('Edit shifttype') : _('Create shifttype'), [ - msg(), - buttons([ - button(page_link_to('shifttypes'), shifttypes_title(), 'back') - ]), - form([ - form_text('name', _('Name'), $name), - form_select('angeltype_id', _('Angeltype'), $angeltypes_select, $angeltype_id), - form_textarea('description', _('Description'), $description), - form_info('', _('Please use markdown for the description.')), - form_submit('submit', _('Save')) - ]) - ]); + msg(), + buttons([ + button(page_link_to('shifttypes'), shifttypes_title(), 'back') + ]), + form([ + form_text('name', _('Name'), $name), + form_select('angeltype_id', _('Angeltype'), $angeltypes_select, $angeltype_id), + form_textarea('description', _('Description'), $description), + form_info('', _('Please use markdown for the description.')), + form_submit('submit', _('Save')) + ]) + ]); } function ShiftType_view($shifttype, $angeltype) @@ -52,16 +56,23 @@ function ShiftType_view($shifttype, $angeltype) $title .= ' ' . sprintf(_('for team %s'), $angeltype['name']) . ''; } return page_with_title($title, [ - msg(), - buttons([ - button(page_link_to('shifttypes'), shifttypes_title(), 'back'), - $angeltype ? button(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'], _('delete'), 'delete') - ]), - heading(_("Description"), 2), - $parsedown->parse($shifttype['description']) - ]); + msg(), + buttons([ + button(page_link_to('shifttypes'), shifttypes_title(), 'back'), + $angeltype ? button( + 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'], + _('delete'), + 'delete' + ) + ]), + heading(_("Description"), 2), + $parsedown->parse($shifttype['description']) + ]); } function ShiftTypes_list_view($shifttypes) @@ -69,19 +80,23 @@ function ShiftTypes_list_view($shifttypes) foreach ($shifttypes as &$shifttype) { $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'], _('delete'), 'btn-xs') - ]); + 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'], + _('delete'), + 'btn-xs' + ) + ]); } - + return page_with_title(shifttypes_title(), [ - msg(), - buttons([ - button(page_link_to('shifttypes') . '&action=edit', _('New shifttype'), 'add') - ]), - table([ - 'name' => _('Name'), - 'actions' => '' - ], $shifttypes) - ]); + msg(), + buttons([ + button(page_link_to('shifttypes') . '&action=edit', _('New shifttype'), 'add') + ]), + table([ + 'name' => _('Name'), + 'actions' => '' + ], $shifttypes) + ]); } diff --git a/includes/view/ShiftsFilterRenderer.php b/includes/view/ShiftsFilterRenderer.php index 9b7df7cd..81c75e55 100644 --- a/includes/view/ShiftsFilterRenderer.php +++ b/includes/view/ShiftsFilterRenderer.php @@ -5,68 +5,68 @@ namespace Engelsystem; class ShiftsFilterRenderer { - /** - * The shiftFilter to render. - * - * @var ShiftsFilter - */ - private $shiftsFilter; + /** + * The shiftFilter to render. + * + * @var ShiftsFilter + */ + private $shiftsFilter; - /** - * Should the filter display a day selection. - * - * @var boolean - */ - private $daySelectionEnabled = false; + /** + * Should the filter display a day selection. + * + * @var boolean + */ + private $daySelectionEnabled = false; - /** - * Days that can be selected. - * Format Y-m-d - * - * @var string[] - */ - private $days = []; + /** + * Days that can be selected. + * Format Y-m-d + * + * @var string[] + */ + private $days = []; public function __construct(ShiftsFilter $shiftsFilter) { $this->shiftsFilter = $shiftsFilter; } - /** - * Renders the filter. - * - * @return Generated HTML - */ - public function render($link_base) - { - $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); - } - $toolbar[] = toolbar_dropdown('', $selected_day, $day_dropdown_items, 'active'); - } - return div('form-group', [ - toolbar_pills($toolbar) - ]); - } + /** + * Renders the filter. + * + * @return Generated HTML + */ + public function render($link_base) + { + $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); + } + $toolbar[] = toolbar_dropdown('', $selected_day, $day_dropdown_items, 'active'); + } + return div('form-group', [ + toolbar_pills($toolbar) + ]); + } - /** - * Should the filter display a day selection. - */ - public function enableDaySelection($days) - { - $this->daySelectionEnabled = true; - $this->days = $days; - } + /** + * Should the filter display a day selection. + */ + public function enableDaySelection($days) + { + $this->daySelectionEnabled = true; + $this->days = $days; + } - /** - * Should the filter display a day selection. - */ - public function isDaySelectionEnabled() - { - return $this->daySelectionEnabled; - } + /** + * Should the filter display a day selection. + */ + public function isDaySelectionEnabled() + { + return $this->daySelectionEnabled; + } } diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php index 5b73c218..f091829f 100644 --- a/includes/view/Shifts_view.php +++ b/includes/view/Shifts_view.php @@ -5,10 +5,18 @@ function Shift_editor_info_render($shift) { $info = []; if ($shift['created_by_user_id'] != null) { - $info[] = sprintf(glyph('plus') . _("created at %s by %s"), date('Y-m-d H:i', $shift['created_at_timestamp']), User_Nick_render(User($shift['created_by_user_id']))); + $info[] = sprintf( + glyph('plus') . _("created at %s by %s"), + date('Y-m-d H:i', $shift['created_at_timestamp']), + User_Nick_render(User($shift['created_by_user_id'])) + ); } if ($shift['edited_by_user_id'] != null) { - $info[] = sprintf(glyph('pencil') . _("edited at %s by %s"), date('Y-m-d H:i', $shift['edited_at_timestamp']), User_Nick_render(User($shift['edited_by_user_id']))); + $info[] = sprintf( + glyph('pencil') . _("edited at %s by %s"), + date('Y-m-d H:i', $shift['edited_at_timestamp']), + User_Nick_render(User($shift['edited_by_user_id'])) + ); } return join('
    ', $info); } @@ -16,15 +24,22 @@ function Shift_editor_info_render($shift) function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null) { global $user; - + if ($user_angeltype == null) { $user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype); } - + if ($angeltype['shift_signup_state']->isSignupAllowed()) { - return button(page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'], _('Sign up')); + return button( + 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'], sprintf(_('Become %s'), $angeltype['name'])); + return button( + page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], + sprintf(_('Become %s'), + $angeltype['name']) + ); } return ''; } @@ -32,83 +47,90 @@ function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null) function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupState $shift_signup_state) { global $privileges; - + $shift_admin = in_array('admin_shifts', $privileges); $user_shift_admin = in_array('user_shifts_admin', $privileges); $admin_rooms = in_array('admin_rooms', $privileges); $admin_shifttypes = in_array('shifttypes', $privileges); - + $parsedown = new Parsedown(); - + $angeltypes = []; foreach ($angeltypes_source as $angeltype) { $angeltypes[$angeltype['id']] = $angeltype; } - + $needed_angels = ''; foreach ($shift['NeedAngels'] as $needed_angeltype) { $needed_angels .= Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shift, $user_shift_admin); } - - return page_with_title($shift['name'] . ' %c', [ - msg(), - $shift_signup_state->getState() == ShiftSignupState::COLLIDES ? info(_('This shift collides with one of your shifts.'), true) : '', - $shift_signup_state->getState() == ShiftSignupState::SIGNED_UP ? info(_('You are signed up for this shift.'), true) : '', - ($shift_admin || $admin_shifttypes || $admin_rooms) ? buttons([ - $shift_admin ? button(shift_edit_link($shift), glyph('pencil') . _('edit')) : '', - $shift_admin ? button(shift_delete_link($shift), glyph('trash') . _('delete')) : '', - $admin_shifttypes ? button(shifttype_link($shifttype), $shifttype['name']) : '', - $admin_rooms ? button(room_link($room), glyph('map-marker') . $room['Name']) : '' - ]) : '', - div('row', [ - div('col-sm-3 col-xs-6', [ - '

    ' . _('Title') . '

    ', - '

    ' . ($shift['URL'] != '' ? '' . $shift['title'] . '' : $shift['title']) . '

    ' - ]), - div('col-sm-3 col-xs-6', [ - '

    ' . _('Start') . '

    ', - '

    ', - glyph('calendar') . date(_('Y-m-d'), $shift['start']), - '
    ', - glyph('time') . date('H:i', $shift['start']), - '

    ' - ]), - div('col-sm-3 col-xs-6', [ - '

    ' . _('End') . '

    ', - '

    ', - glyph('calendar') . date(_('Y-m-d'), $shift['end']), - '
    ', - glyph('time') . date('H:i', $shift['end']), - '

    ' - ]), - div('col-sm-3 col-xs-6', [ - '

    ' . _('Location') . '

    ', - '

    ' . Room_name_render($room) . '

    ' - ]) - ]), - div('row', [ - div('col-sm-6', [ - '

    ' . _('Needed angels') . '

    ', - '
    ' . $needed_angels . '
    ' - ]), - div('col-sm-6', [ - '

    ' . _('Description') . '

    ', - $parsedown->parse($shifttype['description']) - ]) - ]), - $shift_admin ? Shift_editor_info_render($shift) : '' - ]); + + return page_with_title( + $shift['name'] . ' %c', + [ + msg(), + $shift_signup_state->getState() == ShiftSignupState::COLLIDES + ? info(_('This shift collides with one of your shifts.'), true) + : '', + $shift_signup_state->getState() == ShiftSignupState::SIGNED_UP + ? info(_('You are signed up for this shift.'), true) + : '', + ($shift_admin || $admin_shifttypes || $admin_rooms) ? buttons([ + $shift_admin ? button(shift_edit_link($shift), glyph('pencil') . _('edit')) : '', + $shift_admin ? button(shift_delete_link($shift), glyph('trash') . _('delete')) : '', + $admin_shifttypes ? button(shifttype_link($shifttype), $shifttype['name']) : '', + $admin_rooms ? button(room_link($room), glyph('map-marker') . $room['Name']) : '' + ]) : '', + div('row', [ + div('col-sm-3 col-xs-6', [ + '

    ' . _('Title') . '

    ', + '

    ' . ($shift['URL'] != '' ? '' . $shift['title'] . '' : $shift['title']) . '

    ' + ]), + div('col-sm-3 col-xs-6', [ + '

    ' . _('Start') . '

    ', + '

    ', + glyph('calendar') . date(_('Y-m-d'), $shift['start']), + '
    ', + glyph('time') . date('H:i', $shift['start']), + '

    ' + ]), + div('col-sm-3 col-xs-6', [ + '

    ' . _('End') . '

    ', + '

    ', + glyph('calendar') . date(_('Y-m-d'), $shift['end']), + '
    ', + glyph('time') . date('H:i', $shift['end']), + '

    ' + ]), + div('col-sm-3 col-xs-6', [ + '

    ' . _('Location') . '

    ', + '

    ' . Room_name_render($room) . '

    ' + ]) + ]), + div('row', [ + div('col-sm-6', [ + '

    ' . _('Needed angels') . '

    ', + '
    ' . $needed_angels . '
    ' + ]), + div('col-sm-6', [ + '

    ' . _('Description') . '

    ', + $parsedown->parse($shifttype['description']) + ]) + ]), + $shift_admin ? Shift_editor_info_render($shift) : '' + ] + ); } function Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shift, $user_shift_admin) { global $user; - + $angeltype = $angeltypes[$needed_angeltype['TID']]; $angeltype_supporter = User_is_AngelType_supporter($user, $angeltype); - + $needed_angels = ''; - + $class = 'progress-bar-warning'; if ($needed_angeltype['taken'] == 0) { $class = 'progress-bar-danger'; @@ -117,24 +139,30 @@ function Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shi $class = 'progress-bar-success'; } $needed_angels .= '
    '; - + $needed_angels .= '
    ' . Shift_signup_button_render($shift, $angeltype) . '
    '; - + $needed_angels .= '

    ' . AngelType_name_render($angeltype) . '

    '; $bar_max = max($needed_angeltype['count'] * 10, $needed_angeltype['taken'] * 10, 10); $bar_value = max(1, $needed_angeltype['taken'] * 10); - $needed_angels .= progress_bar(0, $bar_max, $bar_value, $class, $needed_angeltype['taken'] . ' / ' . $needed_angeltype['count']); - + $needed_angels .= progress_bar( + 0, + $bar_max, + $bar_value, + $class, + $needed_angeltype['taken'] . ' / ' . $needed_angeltype['count'] + ); + $angels = []; foreach ($shift['ShiftEntry'] as $shift_entry) { if ($shift_entry['TID'] == $needed_angeltype['TID']) { $angels[] = Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angeltype_supporter); } } - + $needed_angels .= join(', ', $angels); $needed_angels .= '
    '; - + return $needed_angels; } @@ -147,7 +175,11 @@ function Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angelty if ($user_shift_admin || $angeltype_supporter) { $entry .= '
    '; if ($user_shift_admin) { - $entry .= button_glyph(page_link_to('user_myshifts') . '&edit=' . $shift_entry['id'] . '&id=' . $shift_entry['UID'], 'pencil', 'btn-xs'); + $entry .= button_glyph( + 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 .= '
    '; diff --git a/includes/view/UserAngelTypes_view.php b/includes/view/UserAngelTypes_view.php index dcfff2b1..bef07720 100644 --- a/includes/view/UserAngelTypes_view.php +++ b/includes/view/UserAngelTypes_view.php @@ -3,61 +3,90 @@ function UserAngelType_update_view($user_angeltype, $user, $angeltype, $supporter) { return page_with_title($supporter ? _("Add supporter rights") : _("Remove supporter rights"), [ - msg(), - info(sprintf($supporter ? _("Do you really want to add supporter rights for %s to %s?") : _("Do you really want to remove supporter rights for %s from %s?"), $angeltype['name'], 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', _("yes"), 'ok') - ]) - ]); + msg(), + info(sprintf( + $supporter + ? _("Do you really want to add supporter rights for %s to %s?") + : _("Do you really want to remove supporter rights for %s from %s?"), + $angeltype['name'], + 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', + _("yes"), + 'ok' + ) + ]) + ]); } function UserAngelTypes_delete_all_view($angeltype) { return page_with_title(_("Deny all users"), [ - 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', _("yes"), 'ok') - ]) - ]); + 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', + _("yes"), + 'ok' + ) + ]) + ]); } function UserAngelTypes_confirm_all_view($angeltype) { return page_with_title(_("Confirm all users"), [ - 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('user_angeltypes') . '&action=confirm_all&angeltype_id=' . $angeltype['id'] . '&confirmed', _("yes"), 'ok') - ]) - ]); + 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('user_angeltypes') . '&action=confirm_all&angeltype_id=' . $angeltype['id'] . '&confirmed', + _("yes"), + 'ok' + ) + ]) + ]); } function UserAngelType_confirm_view($user_angeltype, $user, $angeltype) { return page_with_title(_("Confirm angeltype for user"), [ - 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', _("yes"), 'ok') - ]) - ]); + 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', + _("yes"), + 'ok' + ) + ]) + ]); } function UserAngelType_delete_view($user_angeltype, $user, $angeltype) { return page_with_title(_("Remove 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', _("yes"), 'ok') - ]) - ]); + 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', + _("yes"), + 'ok' + ) + ]) + ]); } function UserAngelType_add_view($angeltype, $users_source, $user_id) @@ -66,28 +95,32 @@ function UserAngelType_add_view($angeltype, $users_source, $user_id) foreach ($users_source as $user_source) { $users[$user_source['UID']] = User_Nick_render($user_source); } - + return page_with_title(_("Add user to angeltype"), [ - msg(), - buttons([ - button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("back"), 'back') - ]), - form([ - form_info(_("Angeltype"), $angeltype['name']), - form_select('user_id', _("User"), $users, $user_id), - form_submit('submit', _("Add")) - ]) - ]); + msg(), + buttons([ + button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("back"), 'back') + ]), + form([ + form_info(_("Angeltype"), $angeltype['name']), + form_select('user_id', _("User"), $users, $user_id), + form_submit('submit', _("Add")) + ]) + ]); } function UserAngelType_join_view($user, $angeltype) { return page_with_title(sprintf(_("Become a %s"), $angeltype['name']), [ - 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', _("save"), 'ok') - ]) - ]); + 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', + _("save"), + 'ok' + ) + ]) + ]); } diff --git a/includes/view/UserDriverLicenses_view.php b/includes/view/UserDriverLicenses_view.php index bd3393cc..5b203c9c 100644 --- a/includes/view/UserDriverLicenses_view.php +++ b/includes/view/UserDriverLicenses_view.php @@ -3,9 +3,9 @@ /** * Edit a user's driving license information. * - * @param User $user_source + * @param User $user_source * The user - * @param bool $wants_to_drive + * @param bool $wants_to_drive * true, if the user wants to drive * @param UserDriverLicense $user_driver_license * The user driver license @@ -14,27 +14,43 @@ function UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver_license) { return page_with_title(sprintf(_("Edit %s driving license information"), User_Nick_render($user_source)), [ - buttons([ - button(user_link($user_source), _("Back to profile"), 'back') - ]), - msg(), - form([ - form_info(_("Privacy"), _("Your driving license information is only visible for supporters and admins.")), - form_checkbox('wants_to_drive', _("I am willing to operate cars for the PL"), $wants_to_drive), - div('panel panel-default', [ - div('panel-body', [ - form_checkbox('has_car', _("I have my own car with me and am willing to use it for the PL (You'll get reimbursed for fuel)"), $user_driver_license['has_car']), - heading(_("Driver license"), 3), - form_checkbox('has_license_car', _("Car"), $user_driver_license['has_license_car']), - form_checkbox('has_license_3_5t_transporter', _("Transporter 3,5t"), $user_driver_license['has_license_3_5t_transporter']), - form_checkbox('has_license_7_5t_truck', _("Truck 7,5t"), $user_driver_license['has_license_7_5t_truck']), - form_checkbox('has_license_12_5t_truck', _("Truck 12,5t"), $user_driver_license['has_license_12_5t_truck']), - form_checkbox('has_license_forklift', _("Forklift"), $user_driver_license['has_license_forklift']) - ]) - ], 'driving_license'), - form_submit('submit', _("Save")) - ]), - '' - ]); + ]); } diff --git a/includes/view/UserHintsRenderer.php b/includes/view/UserHintsRenderer.php index 30281ea0..cd0f568a 100644 --- a/includes/view/UserHintsRenderer.php +++ b/includes/view/UserHintsRenderer.php @@ -8,54 +8,54 @@ class UserHintsRenderer private $important = false; - /** - * Render the added hints to a popover for the toolbar. - */ - public function render() - { - if (count($this->hints) > 0) { - $hint_class = $this->important ? 'danger' : 'info'; - $glyphicon = $this->important ? 'warning-sign' : 'info-sign'; - - return toolbar_popover($glyphicon . ' text-' . $hint_class, '', $this->hints, 'bg-' . $hint_class); - } - - return ''; - } - - /** - * Add a hint to the list, if its not null and a not empty string. - * - * @param string $hint - * The hint - * @param boolean $important - * Is the hint important? - */ - public function addHint($hint, $important = false) - { - if ($hint != null && $hint != '') { - if ($important) { - $this->important = true; - $this->hints[] = error($hint, true); - } else { - $this->hints[] = info($hint, true); - } - } - } - - /** - * Get all hints. - */ - public function getHints() - { - return $this->hints; - } - - /** - * Are there important hints? This leads to a more intensive icon. - */ - public function isImportant() - { - return $this->important; - } + /** + * Render the added hints to a popover for the toolbar. + */ + public function render() + { + if (count($this->hints) > 0) { + $hint_class = $this->important ? 'danger' : 'info'; + $glyphicon = $this->important ? 'warning-sign' : 'info-sign'; + + return toolbar_popover($glyphicon . ' text-' . $hint_class, '', $this->hints, 'bg-' . $hint_class); + } + + return ''; + } + + /** + * Add a hint to the list, if its not null and a not empty string. + * + * @param string $hint + * The hint + * @param boolean $important + * Is the hint important? + */ + public function addHint($hint, $important = false) + { + if ($hint != null && $hint != '') { + if ($important) { + $this->important = true; + $this->hints[] = error($hint, true); + } else { + $this->hints[] = info($hint, true); + } + } + } + + /** + * Get all hints. + */ + public function getHints() + { + return $this->hints; + } + + /** + * Are there important hints? This leads to a more intensive icon. + */ + public function isImportant() + { + return $this->important; + } } diff --git a/includes/view/User_view.php b/includes/view/User_view.php index e28e2a36..984ff535 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -4,18 +4,18 @@ * Available T-Shirt sizes */ $tshirt_sizes = [ - '' => _("Please select..."), - 'S' => "S", - 'M' => "M", - 'L' => "L", - 'XL' => "XL", - '2XL' => "2XL", - '3XL' => "3XL", - '4XL' => "4XL", - '5XL' => "5XL", - 'S-G' => "S Girl", - 'M-G' => "M Girl", - 'L-G' => "L Girl", + '' => _("Please select..."), + 'S' => "S", + 'M' => "M", + 'L' => "L", + 'XL' => "XL", + '2XL' => "2XL", + '3XL' => "3XL", + '4XL' => "4XL", + '5XL' => "5XL", + 'S-G' => "S Girl", + 'M-G' => "M Girl", + 'L-G' => "L Girl", 'XL-G' => "XL Girl" ]; @@ -23,61 +23,92 @@ $tshirt_sizes = [ * Renders user settings page * * @param User $user_source - * The user - * @param array $locales - * Available languages - * @param array $themes - * Available themes + * The user + * @param array $locales + * Available languages + * @param array $themes + * Available themes */ -function User_settings_view($user_source, $locales, $themes, $buildup_start_date, $teardown_end_date, $enable_tshirt_size, $tshirt_sizes) -{ +function User_settings_view( + $user_source, + $locales, + $themes, + $buildup_start_date, + $teardown_end_date, + $enable_tshirt_size, + $tshirt_sizes +) { return page_with_title(settings_title(), [ - msg(), - div('row', [ - div('col-md-6', [ - form([ - form_info('', _("Here you can change your user details.")), - form_info(entry_required() . ' = ' . _("Entry required!")), - form_text('nick', _("Nick"), $user_source['Nick'], true), - form_text('lastname', _("Last name"), $user_source['Name']), - form_text('prename', _("First name"), $user_source['Vorname']), - form_date('planned_arrival_date', _("Planned date of arrival") . ' ' . entry_required(), $user_source['planned_arrival_date'], $buildup_start_date, $teardown_end_date), - form_date('planned_departure_date', _("Planned date of departure"), $user_source['planned_departure_date'], $buildup_start_date, $teardown_end_date), - form_text('age', _("Age"), $user_source['Alter']), - form_text('tel', _("Phone"), $user_source['Telefon']), - form_text('dect', _("DECT"), $user_source['DECT']), - form_text('mobile', _("Mobile"), $user_source['Handy']), - form_text('mail', _("E-Mail") . ' ' . entry_required(), $user_source['email']), - form_checkbox('email_shiftinfo', _("The engelsystem is allowed to send me an email (e.g. when my shifts change)"), $user_source['email_shiftinfo']), - form_checkbox('email_by_human_allowed', _("Humans are allowed to send me an email (e.g. for ticket vouchers)"), $user_source['email_by_human_allowed']), - form_text('jabber', _("Jabber"), $user_source['jabber']), - form_text('hometown', _("Hometown"), $user_source['Hometown']), - $enable_tshirt_size ? form_select('tshirt_size', _("Shirt size"), $tshirt_sizes, $user_source['Size']) : '', - form_info('', _('Please visit the angeltypes page to manage your angeltypes.')), - form_submit('submit', _("Save")) - ]) - ]), - div('col-md-6', [ - form([ - form_info(_("Here you can change your password.")), - form_password('password', _("Old password:")), - form_password('new_password', _("New password:")), - form_password('new_password2', _("Password confirmation:")), - form_submit('submit_password', _("Save")) - ]), - form([ - form_info(_("Here you can choose your color settings:")), - form_select('theme', _("Color settings:"), $themes, $user_source['color']), - form_submit('submit_theme', _("Save")) - ]), - form([ - form_info(_("Here you can choose your language:")), - form_select('language', _("Language:"), $locales, $user_source['Sprache']), - form_submit('submit_language', _("Save")) - ]) - ]) - ]) - ]); + msg(), + div('row', [ + div('col-md-6', [ + form([ + form_info('', _("Here you can change your user details.")), + form_info(entry_required() . ' = ' . _("Entry required!")), + form_text('nick', _("Nick"), $user_source['Nick'], true), + form_text('lastname', _("Last name"), $user_source['Name']), + form_text('prename', _("First name"), $user_source['Vorname']), + form_date( + 'planned_arrival_date', + _("Planned date of arrival") . ' ' . entry_required(), + $user_source['planned_arrival_date'], + $buildup_start_date, $teardown_end_date + ), + form_date( + 'planned_departure_date', + _("Planned date of departure"), + $user_source['planned_departure_date'], + $buildup_start_date, + $teardown_end_date + ), + form_text('age', _("Age"), $user_source['Alter']), + form_text('tel', _("Phone"), $user_source['Telefon']), + form_text('dect', _("DECT"), $user_source['DECT']), + form_text('mobile', _("Mobile"), $user_source['Handy']), + form_text('mail', _("E-Mail") . ' ' . entry_required(), $user_source['email']), + form_checkbox( + 'email_shiftinfo', + _("The engelsystem is allowed to send me an email (e.g. when my shifts change)"), + $user_source['email_shiftinfo'] + ), + form_checkbox( + 'email_by_human_allowed', + _("Humans are allowed to send me an email (e.g. for ticket vouchers)"), + $user_source['email_by_human_allowed'] + ), + form_text('jabber', _("Jabber"), $user_source['jabber']), + form_text('hometown', _("Hometown"), $user_source['Hometown']), + $enable_tshirt_size ? form_select( + 'tshirt_size', + _("Shirt size"), + $tshirt_sizes, + $user_source['Size'] + ) : '', + form_info('', _('Please visit the angeltypes page to manage your angeltypes.')), + form_submit('submit', _("Save")) + ]) + ]), + div('col-md-6', [ + form([ + form_info(_("Here you can change your password.")), + form_password('password', _("Old password:")), + form_password('new_password', _("New password:")), + form_password('new_password2', _("Password confirmation:")), + form_submit('submit_password', _("Save")) + ]), + form([ + form_info(_("Here you can choose your color settings:")), + form_select('theme', _("Color settings:"), $themes, $user_source['color']), + form_submit('submit_theme', _("Save")) + ]), + form([ + form_info(_("Here you can choose your language:")), + form_select('language', _("Language:"), $locales, $user_source['Sprache']), + form_submit('submit_language', _("Save")) + ]) + ]) + ]) + ]); } /** @@ -88,32 +119,32 @@ 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', [ - div('col-md-4', [ - $event_welcome_message - ]), - div('col-md-4', [ - '

    ' . _("Login") . '

    ', - form([ - form_text('nick', _("Nick"), ""), - form_password('password', _("Password")), - form_submit('submit', _("Login")), - buttons([ - button(page_link_to('user_password_recovery'), _("I forgot my password")) - ]), - info(_("Please note: You have to activate cookies!"), true) - ], page_link_to('login')) - ]), - div('col-md-4', [ - '

    ' . _("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") . ' »') - ]) - ]) - ]) - ]); + msg(), + div('row', [ + div('col-md-4', [ + $event_welcome_message + ]), + div('col-md-4', [ + '

    ' . _("Login") . '

    ', + form([ + form_text('nick', _("Nick"), ""), + form_password('password', _("Password")), + form_submit('submit', _("Login")), + buttons([ + button(page_link_to('user_password_recovery'), _("I forgot my password")) + ]), + info(_("Please note: You have to activate cookies!"), true) + ], page_link_to('login')) + ]), + div('col-md-4', [ + '

    ' . _("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") . ' »') + ]) + ]) + ]) + ]); } /** @@ -122,16 +153,19 @@ function User_registration_success_view($event_welcome_message) function User_delete_view($user) { return page_with_title(sprintf(_("Delete %s"), User_Nick_render($user)), [ - msg(), - buttons([ - button(user_edit_link($user), glyph('chevron-left') . _("back")) - ]), - error(_("Do you really want to delete the user including all his shifts and every other piece of his data?"), true), - form([ - form_password('password', _("Your password")), - form_submit('submit', _("Delete")) - ]) - ]); + msg(), + buttons([ + button(user_edit_link($user), glyph('chevron-left') . _("back")) + ]), + error( + _("Do you really want to delete the user including all his shifts and every other piece of his data?"), + true + ), + form([ + form_password('password', _("Your password")), + form_submit('submit', _("Delete")) + ]) + ]); } /** @@ -140,20 +174,28 @@ function User_delete_view($user) function User_edit_vouchers_view($user) { return page_with_title(sprintf(_("%s's vouchers"), User_Nick_render($user)), [ - msg(), - 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), - 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']) - ]); + msg(), + 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), + 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']) + ]); } -function Users_view($users, $order_by, $arrived_count, $active_count, $force_active_count, $freeloads_count, $tshirts_count, $voucher_count) -{ +function Users_view( + $users, + $order_by, + $arrived_count, + $active_count, + $force_active_count, + $freeloads_count, + $tshirts_count, + $voucher_count +) { foreach ($users as &$user) { $user['Nick'] = User_Nick_render($user); $user['Gekommen'] = glyph_bool($user['Gekommen']); @@ -163,41 +205,41 @@ function Users_view($users, $order_by, $arrived_count, $active_count, $force_act $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[] = [ - 'Nick' => '' . _('Sum') . '', - 'Gekommen' => $arrived_count, - 'got_voucher' => $voucher_count, - 'Aktiv' => $active_count, - 'force_active' => $force_active_count, - 'freeloads' => $freeloads_count, - 'Tshirt' => $tshirts_count, - 'actions' => '' . count($users) . '' - ]; - + 'Nick' => '' . _('Sum') . '', + 'Gekommen' => $arrived_count, + 'got_voucher' => $voucher_count, + 'Aktiv' => $active_count, + 'force_active' => $force_active_count, + 'freeloads' => $freeloads_count, + 'Tshirt' => $tshirts_count, + 'actions' => '' . count($users) . '' + ]; + return page_with_title(_("All users"), [ - msg(), - buttons([ - button(page_link_to('register'), glyph('plus') . _("New user")) - ]), - table([ - 'Nick' => Users_table_header_link('Nick', _("Nick"), $order_by), - 'Vorname' => Users_table_header_link('Vorname', _("Prename"), $order_by), - 'Name' => Users_table_header_link('Name', _("Name"), $order_by), - 'DECT' => Users_table_header_link('DECT', _("DECT"), $order_by), - 'Gekommen' => Users_table_header_link('Gekommen', _("Arrived"), $order_by), - 'got_voucher' => Users_table_header_link('got_voucher', _("Voucher"), $order_by), - 'freeloads' => _('Freeloads'), - 'Aktiv' => Users_table_header_link('Aktiv', _("Active"), $order_by), - 'force_active' => Users_table_header_link('force_active', _("Forced"), $order_by), - 'Tshirt' => Users_table_header_link('Tshirt', _("T-Shirt"), $order_by), - 'Size' => Users_table_header_link('Size', _("Size"), $order_by), - 'lastLogIn' => Users_table_header_link('lastLogIn', _("Last login"), $order_by), - 'actions' => '' - ], $users) - ]); + msg(), + buttons([ + button(page_link_to('register'), glyph('plus') . _("New user")) + ]), + table([ + 'Nick' => Users_table_header_link('Nick', _("Nick"), $order_by), + 'Vorname' => Users_table_header_link('Vorname', _("Prename"), $order_by), + 'Name' => Users_table_header_link('Name', _("Name"), $order_by), + 'DECT' => Users_table_header_link('DECT', _("DECT"), $order_by), + 'Gekommen' => Users_table_header_link('Gekommen', _("Arrived"), $order_by), + 'got_voucher' => Users_table_header_link('got_voucher', _("Voucher"), $order_by), + 'freeloads' => _('Freeloads'), + 'Aktiv' => Users_table_header_link('Aktiv', _("Active"), $order_by), + 'force_active' => Users_table_header_link('force_active', _("Forced"), $order_by), + 'Tshirt' => Users_table_header_link('Tshirt', _("T-Shirt"), $order_by), + 'Size' => Users_table_header_link('Size', _("Size"), $order_by), + 'lastLogIn' => Users_table_header_link('lastLogIn', _("Last login"), $order_by), + 'actions' => '' + ], $users) + ]); } function Users_table_header_link($column, $label, $order_by) @@ -211,11 +253,11 @@ function User_shift_state_render($user) if ($upcoming_shifts === false) { return false; } - + if (count($upcoming_shifts) == 0) { return '' . _("Free") . ''; } - + if ($upcoming_shifts[0]['start'] > time()) { if ($upcoming_shifts[0]['start'] - time() > 3600) { return '' . _("Next shift %c") . ''; @@ -223,7 +265,7 @@ function User_shift_state_render($user) return '' . _("Next shift %c") . ''; } $halfway = ($upcoming_shifts[0]['start'] + $upcoming_shifts[0]['end']) / 2; - + if (time() < $halfway) { return '' . _("Shift starts %c") . ''; } @@ -233,18 +275,18 @@ function User_shift_state_render($user) function User_view_shiftentries($needed_angel_type) { $shift_info = '
    ' . $needed_angel_type['name'] . ': '; - + $shift_entries = []; foreach ($needed_angel_type['users'] as $user_shift) { $member = User_Nick_render($user_shift); if ($user_shift['freeloaded']) { $member = '' . $member . ''; } - + $shift_entries[] = $member; } $shift_info .= join(", ", $shift_entries); - + return $shift_info; } @@ -254,7 +296,7 @@ function User_view_shiftentries($needed_angel_type) function User_view_myshift($shift, $user_source, $its_me) { global $LETZTES_AUSTRAGEN, $privileges; - + $shift_info = '' . $shift['name'] . ''; if ($shift['title']) { $shift_info .= '
    ' . $shift['title'] . ''; @@ -262,15 +304,15 @@ function User_view_myshift($shift, $user_source, $its_me) foreach ($shift['needed_angeltypes'] as $needed_angel_type) { $shift_info .= User_view_shiftentries($needed_angel_type); } - + $myshift = [ - 'date' => date("Y-m-d", $shift['start']), - 'time' => date("H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']), - 'room' => $shift['Name'], - 'shift_info' => $shift_info, - 'comment' => $shift['Comment'] - ]; - + 'date' => date("Y-m-d", $shift['start']), + 'time' => date("H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']), + 'room' => $shift['Name'], + 'shift_info' => $shift_info, + 'comment' => $shift['Comment'] + ]; + if ($shift['freeloaded']) { if (in_array("user_shifts_admin", $privileges)) { $myshift['comment'] .= '

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

    '; @@ -278,18 +320,26 @@ function User_view_myshift($shift, $user_source, $its_me) $myshift['comment'] .= '

    ' . _("Freeloaded") . '

    '; } } - + $myshift['actions'] = [ - button(shift_link($shift), glyph('eye-open') . _('view'), 'btn-xs') - ]; + button(shift_link($shift), glyph('eye-open') . _('view'), 'btn-xs') + ]; if ($its_me || in_array('user_shifts_admin', $privileges)) { - $myshift['actions'][] = button(page_link_to('user_myshifts') . '&edit=' . $shift['id'] . '&id=' . $user_source['UID'], glyph('edit') . _('edit'), 'btn-xs'); + $myshift['actions'][] = button( + page_link_to('user_myshifts') . '&edit=' . $shift['id'] . '&id=' . $user_source['UID'], + glyph('edit') . _('edit'), + 'btn-xs' + ); } if (($shift['start'] > time() + $LETZTES_AUSTRAGEN * 3600) || in_array('user_shifts_admin', $privileges)) { - $myshift['actions'][] = button(page_link_to('user_myshifts') . ((! $its_me) ? '&id=' . $user_source['UID'] : '') . '&cancel=' . $shift['id'], glyph('trash') . _('sign off'), 'btn-xs'); + $myshift['actions'][] = button( + page_link_to('user_myshifts') . ((!$its_me) ? '&id=' . $user_source['UID'] : '') . '&cancel=' . $shift['id'], + glyph('trash') . _('sign off'), + 'btn-xs' + ); } $myshift['actions'] = table_buttons($myshift['actions']); - + return $myshift; } @@ -302,23 +352,23 @@ function User_view_myshifts($shifts, $user_source, $its_me) $timesum = 0; foreach ($shifts as $shift) { $myshifts_table[] = User_view_myshift($shift, $user_source, $its_me); - + if ($shift['freeloaded']) { - $timesum += (- 2 * ($shift['end'] - $shift['start'])); + $timesum += (-2 * ($shift['end'] - $shift['start'])); } else { $timesum += ($shift['end'] - $shift['start']); } } - + if (count($myshifts_table) > 0) { $myshifts_table[] = [ - 'date' => '' . _("Sum:") . '', - 'time' => "" . round($timesum / 3600, 1) . " h", - 'room' => "", - 'shift_info' => "", - 'comment' => "", - 'actions' => "" - ]; + 'date' => '' . _("Sum:") . '', + 'time' => "" . round($timesum / 3600, 1) . " h", + 'room' => "", + 'shift_info' => "", + 'comment' => "", + 'actions' => "" + ]; } return $myshifts_table; } @@ -330,60 +380,116 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel { $user_name = htmlspecialchars($user_source['Vorname']) . " " . htmlspecialchars($user_source['Name']); $myshifts_table = User_view_myshifts($shifts, $user_source, $its_me); - - return page_with_title(' ' . htmlspecialchars($user_source['Nick']) . ' ' . $user_name . '', [ - msg(), - div('row space-top', [ - div('col-md-12', [ - buttons([ - $admin_user_privilege ? button(page_link_to('admin_user') . '&id=' . $user_source['UID'], glyph("edit") . _("edit")) : '', - $admin_user_privilege ? button(user_driver_license_edit_link($user_source), glyph("road") . _("driving license")) : '', - ($admin_user_privilege && ! $user_source['Gekommen']) ? button(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'], 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'], glyph('calendar') . _("iCal Export")) : '', - $its_me ? button(page_link_to('shifts_json_export') . '&key=' . $user_source['api_key'], glyph('export') . _("JSON Export")) : '', - $its_me ? button(page_link_to('user_myshifts') . '&reset', glyph('repeat') . _('Reset API key')) : '' - ]) - ]) - ]), - div('row', [ - div('col-md-3', [ - '

    ', - '', - $user_source['DECT'], - '

    ' - ]), - div('col-md-3', [ - '

    ' . _("User state") . '

    ', - ($admin_user_privilege && $freeloader) ? ' ' . _("Freeloader") . '
    ' : '', - $user_source['Gekommen'] ? User_shift_state_render($user_source) . '
    ' : '', - $admin_user_privilege || $its_me ? ($user_source['Gekommen'] ? ' ' . sprintf(_("Arrived at %s"), date('Y-m-d', $user_source['arrival_date'])) . '' : '' . sprintf(_("Not arrived (Planned: %s)"), date('Y-m-d', $user_source['planned_arrival_date'])) . '') : ($user_source['Gekommen'] ? ' ' . _("Arrived") . '' : '' . _("Not arrived") . ''), - $admin_user_privilege ? ($user_source['got_voucher'] > 0 ? '
    ' . glyph('cutlery') . sprintf(ngettext("Got %s voucher", "Got %s vouchers", $user_source['got_voucher']), $user_source['got_voucher']) . '
    ' : '
    ' . _("Got no vouchers") . '
    ') : '', - ($user_source['Gekommen'] && $admin_user_privilege && $user_source['Aktiv']) ? ' ' . _("Active") . '' : '', - ($user_source['Gekommen'] && $admin_user_privilege && $user_source['Tshirt']) ? ' ' . _("T-Shirt") . '' : '' - ]), - div('col-md-3', [ - '

    ' . _("Angeltypes") . '

    ', - User_angeltypes_render($user_angeltypes) - ]), - div('col-md-3', [ - '

    ' . _("Rights") . '

    ', - User_groups_render($user_groups) - ]) - ]), - ($its_me || $admin_user_privilege) ? '

    ' . _("Shifts") . '

    ' : '', - ($its_me || $admin_user_privilege) ? table([ - 'date' => _("Day"), - 'time' => _("Time"), - 'room' => _("Location"), - 'shift_info' => _("Name & workmates"), - '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 && count($shifts) == 0 ? error(sprintf(_("Go to the shifts table to sign yourself up for some shifts."), page_link_to('user_shifts')), true) : '' - ]); + + return page_with_title( + ' ' . htmlspecialchars($user_source['Nick']) . ' ' . $user_name . '', + [ + msg(), + div('row space-top', [ + div('col-md-12', [ + buttons([ + $admin_user_privilege ? button( + page_link_to('admin_user') . '&id=' . $user_source['UID'], + glyph("edit") . _("edit") + ) : '', + $admin_user_privilege ? button( + user_driver_license_edit_link($user_source), + glyph("road") . _("driving license") + ) : '', + ($admin_user_privilege && !$user_source['Gekommen']) ? button( + 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'], + 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'], + glyph('calendar') . _("iCal Export") + ) : '', + $its_me ? button( + page_link_to('shifts_json_export') . '&key=' . $user_source['api_key'], + glyph('export') . _("JSON Export") + ) : '', + $its_me ? button( + page_link_to('user_myshifts') . '&reset', + glyph('repeat') . _('Reset API key') + ) : '' + ]) + ]) + ]), + div('row', [ + div('col-md-3', [ + '

    ', + '', + $user_source['DECT'], + '

    ' + ]), + div('col-md-3', [ + '

    ' . _("User state") . '

    ', + ($admin_user_privilege && $freeloader) + ? ' ' . _("Freeloader") . '
    ' + : '', + $user_source['Gekommen'] + ? User_shift_state_render($user_source) . '
    ' + : '', + $admin_user_privilege || $its_me + ? ( + $user_source['Gekommen'] + ? ' ' + . sprintf(_("Arrived at %s"), date('Y-m-d', $user_source['arrival_date'])) + . '' + : '' + . sprintf(_("Not arrived (Planned: %s)"), date('Y-m-d', $user_source['planned_arrival_date'])) + . '' + ) + : ( + $user_source['Gekommen'] + ? ' ' . _("Arrived") . '' + : '' . _("Not arrived") . ''), + $admin_user_privilege + ? ( + $user_source['got_voucher'] > 0 + ? '
    ' + . glyph('cutlery') + . sprintf( + ngettext("Got %s voucher", "Got %s vouchers", $user_source['got_voucher']), + $user_source['got_voucher'] + ) + . '
    ' + : '
    ' . _("Got no vouchers") . '
    ') + : '', + ($user_source['Gekommen'] && $admin_user_privilege && $user_source['Aktiv']) ? ' ' . _("Active") . '' : '', + ($user_source['Gekommen'] && $admin_user_privilege && $user_source['Tshirt']) ? ' ' . _("T-Shirt") . '' : '' + ]), + div('col-md-3', [ + '

    ' . _("Angeltypes") . '

    ', + User_angeltypes_render($user_angeltypes) + ]), + div('col-md-3', [ + '

    ' . _("Rights") . '

    ', + User_groups_render($user_groups) + ]) + ]), + ($its_me || $admin_user_privilege) ? '

    ' . _("Shifts") . '

    ' : '', + ($its_me || $admin_user_privilege) ? table([ + 'date' => _("Day"), + 'time' => _("Time"), + 'room' => _("Location"), + 'shift_info' => _("Name & workmates"), + '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 && count($shifts) == 0 + ? error(sprintf( + _("Go to the shifts table to sign yourself up for some shifts."), + page_link_to('user_shifts') + ), true) + : '' + ]); } /** @@ -392,13 +498,13 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel function User_password_recovery_view() { return page_with_title(user_password_recovery_title(), [ - msg(), - _("We will send you an e-mail with a password recovery link. Please use the email address you used for registration."), - form([ - form_text('email', _("E-Mail"), ""), - form_submit('submit', _("Recover")) - ]) - ]); + msg(), + _("We will send you an e-mail with a password recovery link. Please use the email address you used for registration."), + form([ + form_text('email', _("E-Mail"), ""), + form_submit('submit', _("Recover")) + ]) + ]); } /** @@ -407,14 +513,14 @@ function User_password_recovery_view() function User_password_set_view() { return page_with_title(user_password_recovery_title(), [ - msg(), - _("Please enter a new password."), - form([ - form_password('password', _("Password")), - form_password('password2', _("Confirm password")), - form_submit('submit', _("Save")) - ]) - ]); + msg(), + _("Please enter a new password."), + form([ + form_password('password', _("Password")), + form_password('password2', _("Confirm password")), + form_submit('submit', _("Save")) + ]) + ]); } function User_angeltypes_render($user_angeltypes) @@ -459,22 +565,25 @@ function User_Nick_render($user_source) function render_user_departure_date_hint() { global $user; - - if (! isset($user['planned_departure_date']) || $user['planned_departure_date'] == null) { + + if (!isset($user['planned_departure_date']) || $user['planned_departure_date'] == null) { return _("Please enter your planned date of departure on your settings page to give us a feeling for teardown capacities."); } - + return null; } function render_user_freeloader_hint() { global $user, $max_freeloadable_shifts; - + if (User_is_freeloader($user)) { - return sprintf(_("You freeloaded at least %s shifts. Shift signup is locked. Please go to heavens desk to be unlocked again."), $max_freeloadable_shifts); + return sprintf( + _("You freeloaded at least %s shifts. Shift signup is locked. Please go to heavens desk to be unlocked again."), + $max_freeloadable_shifts + ); } - + return null; } @@ -482,32 +591,32 @@ function render_user_freeloader_hint() function render_user_arrived_hint() { global $user; - + if ($user['Gekommen'] == 0) { 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."); } - + return null; } function render_user_tshirt_hint() { global $enable_tshirt_size, $user; - + if ($enable_tshirt_size && $user['Size'] == "") { return _("You need to specify a tshirt size in your settings!"); } - + return null; } function render_user_dect_hint() { global $user; - + if ($user['DECT'] == "") { return _("You need to specify a DECT phone number in your settings! If you don't have a DECT phone, just enter \"-\"."); } - + return null; } -- cgit v1.2.3-54-g00ecf