From e965f8d04150fbd17ee1b5fcbca5ae85bbe6d6bd Mon Sep 17 00:00:00 2001 From: msquare Date: Thu, 29 Sep 2016 11:18:17 +0200 Subject: prohibit inline control structures on model and view --- includes/view/AngelTypes_view.php | 119 +++++++++++++++------------- includes/view/Questions_view.php | 22 +++--- includes/view/Rooms_view.php | 3 +- includes/view/ShiftEntry_view.php | 14 ++-- includes/view/ShiftTypes_view.php | 17 ++-- includes/view/Shifts_view.php | 30 +++++--- includes/view/UserAngelTypes_view.php | 66 ++++++++-------- includes/view/User_view.php | 141 +++++++++++++++++++--------------- 8 files changed, 224 insertions(+), 188 deletions(-) (limited to 'includes/view') diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php index fae52713..65abe0f3 100644 --- a/includes/view/AngelTypes_view.php +++ b/includes/view/AngelTypes_view.php @@ -21,42 +21,39 @@ function AngelType_name_render($angeltype) { * @return string */ function AngelType_render_membership($user_angeltype) { - $membership = ""; if ($user_angeltype['user_angeltype_id'] != null) { if ($user_angeltype['restricted']) { - if ($user_angeltype['confirm_user_id'] == null) - $membership = glyph('lock') . _("Unconfirmed"); - elseif ($user_angeltype['coordinator']) - $membership = glyph_bool(true) . _("Coordinator"); - else - $membership = glyph_bool(true) . _("Member"); - } elseif ($user_angeltype['coordinator']) - $membership = glyph_bool(true) . _("Coordinator"); - else - $membership = glyph_bool(true) . _("Member"); - } else { - $membership = glyph_bool(false); + if ($user_angeltype['confirm_user_id'] == null) { + return glyph('lock') . _("Unconfirmed"); + } elseif ($user_angeltype['coordinator']) { + return glyph_bool(true) . _("Coordinator"); + } + return glyph_bool(true) . _("Member"); + } elseif ($user_angeltype['coordinator']) { + return glyph_bool(true) . _("Coordinator"); + } + return glyph_bool(true) . _("Member"); } - return $membership; + return glyph_bool(false); } function AngelType_delete_view($angeltype) { return page_with_title(sprintf(_("Delete angeltype %s"), $angeltype['name']), array( info(sprintf(_("Do you want to delete angeltype %s?"), $angeltype['name']), true), - buttons(array( + buttons([ button(page_link_to('angeltypes'), _("cancel"), 'cancel'), button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'] . '&confirmed', _("delete"), 'ok') - )) + ]) )); } function AngelType_edit_view($name, $restricted, $description, $coordinator_mode, $requires_driver_license) { return page_with_title(sprintf(_("Edit %s"), $name), array( - buttons(array( + buttons([ button(page_link_to('angeltypes'), _("Angeltypes"), 'back') - )), + ]), msg(), - form(array( + form([ $coordinator_mode ? form_info(_("Name"), $name) : form_text('name', _("Name"), $name), $coordinator_mode ? form_info(_("Restricted"), $restricted ? _("Yes") : _("No")) : form_checkbox('restricted', _("Restricted"), $restricted), $coordinator_mode ? form_info(_("Requires driver license"), $requires_driver_license ? _("Yes") : _("No")) : form_checkbox('requires_driver_license', _("Requires driver license"), $requires_driver_license), @@ -64,7 +61,7 @@ function AngelType_edit_view($name, $restricted, $description, $coordinator_mode form_textarea('description', _("Description"), $description), form_info("", _("Please use markdown for the description.")), form_submit('submit', _("Save")) - )) + ]) )); } @@ -73,38 +70,44 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel button(page_link_to('angeltypes'), _("Angeltypes"), 'back') ]; - if ($angeltype['requires_driver_license']) + if ($angeltype['requires_driver_license']) { $buttons[] = button(user_driver_license_edit_link($user), glyph("road") . _("my driving license")); + } - if ($user_angeltype == null) + if ($user_angeltype == null) { $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) + } 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) + 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'])); + } $buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'], _("leave"), 'cancel'); } - if ($admin_angeltypes || $coordinator) + if ($admin_angeltypes || $coordinator) { $buttons[] = button(page_link_to('angeltypes') . '&action=edit&angeltype_id=' . $angeltype['id'], _("edit"), 'edit'); - if ($admin_angeltypes) + } + if ($admin_angeltypes) { $buttons[] = button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'], _("delete"), 'delete'); + } - $page = array( + $page = [ msg(), buttons($buttons) - ); + ]; $page[] = '

' . _("Description") . '

'; $parsedown = new Parsedown(); - if ($angeltype['description'] != "") + if ($angeltype['description'] != "") { $page[] = '
' . $parsedown->parse($angeltype['description']) . '
'; + } - $coordinators = array(); - $members_confirmed = array(); - $members_unconfirmed = array(); + $coordinators = []; + $members_confirmed = []; + $members_unconfirmed = []; foreach ($members as $member) { $member['Nick'] = User_Nick_render($member); @@ -125,19 +128,21 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel ]); $members_unconfirmed[] = $member; } elseif ($member['coordinator']) { - if ($admin_angeltypes) + if ($admin_angeltypes) { $member['actions'] = table_buttons([ button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&coordinator=0', _("Remove coordinator rights"), 'btn-xs') ]); - else + } else { $member['actions'] = ''; + } $coordinators[] = $member; } else { - if ($admin_user_angeltypes) + 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'] . '&coordinator=1', _("Add coordinator rights"), 'btn-xs') : '', button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'], _("remove"), 'btn-xs') ]); + } $members_confirmed[] = $member; } } @@ -167,25 +172,28 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel $page[] = table($table_headers, $coordinators); } - if (count($members_confirmed) > 0) + if (count($members_confirmed) > 0) { $members_confirmed[] = [ 'Nick' => _('Sum'), 'DECT' => count($members_confirmed), 'actions' => '' ]; + } - if (count($members_unconfirmed) > 0) + if (count($members_unconfirmed) > 0) { $members_unconfirmed[] = [ 'Nick' => _('Sum'), 'DECT' => count($members_unconfirmed), 'actions' => '' ]; + } $page[] = '

' . _("Members") . '

'; - if ($admin_user_angeltypes) + if ($admin_user_angeltypes) { $page[] = buttons([ 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) { @@ -206,51 +214,54 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel * @param array $angeltypes */ function AngelTypes_list_view($angeltypes, $admin_angeltypes) { - return page_with_title(angeltypes_title(), array( + return page_with_title(angeltypes_title(), [ msg(), - buttons(array( + buttons([ $admin_angeltypes ? button(page_link_to('angeltypes') . '&action=edit', _("New angeltype"), 'add') : '', button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description")) - )), - table(array( + ]), + table([ 'name' => _("Name"), 'restricted' => glyph('lock') . _("Restricted"), 'membership' => _("Membership"), 'actions' => "" - ), $angeltypes) - )); + ], $angeltypes) + ]); } function AngelTypes_about_view($angeltypes, $user_logged_in) { global $faq_url; - $content = array( - buttons(array( + $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.") . '

', '
' - ); + ]; $parsedown = new Parsedown(); foreach ($angeltypes as $angeltype) { $content[] = '

' . $angeltype['name'] . '

'; if (isset($angeltype['user_angeltype_id'])) { - $buttons = array(); - if ($angeltype['user_angeltype_id'] != null) + $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'); - else + } else { $buttons[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), 'add'); + } $content[] = buttons($buttons); } - if ($angeltype['restricted']) + if ($angeltype['restricted']) { $content[] = info(_("This angeltype is restricted by double-opt-in by a team coordinator. Please show up at the according introduction meetings."), true); - if ($angeltype['description'] != "") + } + if ($angeltype['description'] != "") { $content[] = '
' . $parsedown->parse($angeltype['description']) . '
'; + } $content[] = '
'; } diff --git a/includes/view/Questions_view.php b/includes/view/Questions_view.php index c766125b..bdcb8a86 100644 --- a/includes/view/Questions_view.php +++ b/includes/view/Questions_view.php @@ -12,26 +12,26 @@ function Questions_view($open_questions, $answered_questions, $ask_action) { $question['actions'] = '' . _("delete") . ''; } - return page_with_title(questions_title(), array( + return page_with_title(questions_title(), [ msg(), - '

' . _("Open questions") . '

', - table(array( + heading(_("Open questions"), 2), + table([ 'Question' => _("Question"), 'actions' => "" - ), $open_questions), - '

' . _("Answered questions") . '

', - table(array( + ], $open_questions), + heading(_("Answered questions"), 2), + table([ 'Question' => _("Question"), 'answer_user' => _("Answered by"), 'Answer' => _("Answer"), 'actions' => "" - ), $answered_questions), - '

' . _("Ask an archangel") . '

', - form(array( + ], $answered_questions), + heading(_("Ask an archangel"), 2), + form([ form_textarea('question', _("Your Question:"), ""), form_submit('submit', _("Save")) - ), $ask_action) - )); + ], $ask_action) + ]); } ?> \ No newline at end of file diff --git a/includes/view/Rooms_view.php b/includes/view/Rooms_view.php index e1d411cb..c820e983 100644 --- a/includes/view/Rooms_view.php +++ b/includes/view/Rooms_view.php @@ -2,8 +2,9 @@ function Room_name_render($room) { global $privileges; - if (in_array('admin_rooms', $privileges)) + if (in_array('admin_rooms', $privileges)) { return '' . glyph('map-marker') . $room['Name'] . ''; + } return glyph('map-marker') . $room['Name']; } diff --git a/includes/view/ShiftEntry_view.php b/includes/view/ShiftEntry_view.php index 9665e426..fab5be66 100644 --- a/includes/view/ShiftEntry_view.php +++ b/includes/view/ShiftEntry_view.php @@ -13,16 +13,16 @@ */ function ShiftEntry_edit_view($angel, $date, $location, $title, $type, $comment, $freeloaded, $freeload_comment, $user_admin_shifts = false) { if ($user_admin_shifts) { - $freeload_form = array( + $freeload_form = [ form_checkbox('freeloaded', _("Freeloaded"), $freeloaded), form_textarea('freeload_comment', _("Freeload comment (Only for shift coordination):"), $freeload_comment) - ); + ]; } else { - $freeload_form = array(); + $freeload_form = []; } - return page_with_title(_("Edit shift entry"), array( + return page_with_title(_("Edit shift entry"), [ msg(), - form(array( + form([ form_info(_("Angel:"), $angel), form_info(_("Date, Duration:"), $date), form_info(_("Location:"), $location), @@ -31,8 +31,8 @@ function ShiftEntry_edit_view($angel, $date, $location, $title, $type, $comment, form_textarea('comment', _("Comment (for your eyes only):"), $comment), join("", $freeload_form), form_submit('submit', _("Save")) - )) - )); + ]) + ]); } ?> \ No newline at end of file diff --git a/includes/view/ShiftTypes_view.php b/includes/view/ShiftTypes_view.php index 10431440..163d6646 100644 --- a/includes/view/ShiftTypes_view.php +++ b/includes/view/ShiftTypes_view.php @@ -2,27 +2,29 @@ function ShiftType_name_render($shifttype) { global $privileges; - if (in_array('shifttypes', $privileges)) + if (in_array('shifttypes', $privileges)) { return '' . $shifttype['name'] . ''; + } return $shifttype['name']; } function ShiftType_delete_view($shifttype) { - return page_with_title(sprintf(_("Delete shifttype %s"), $shifttype['name']), array( + return page_with_title(sprintf(_("Delete shifttype %s"), $shifttype['name']), [ info(sprintf(_("Do you want to delete shifttype %s?"), $shifttype['name']), true), - buttons(array( + 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') ]; - foreach ($angeltypes as $angeltype) + foreach ($angeltypes as $angeltype) { $angeltypes_select[$angeltype['id']] = $angeltype['name']; + } return page_with_title($shifttype_id ? _('Edit shifttype') : _('Create shifttype'), [ msg(), @@ -42,8 +44,9 @@ function ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $s function ShiftType_view($shifttype, $angeltype) { $parsedown = new Parsedown(); $title = $shifttype['name']; - if ($angeltype) + if ($angeltype) { $title .= ' ' . sprintf(_('for team %s'), $angeltype['name']) . ''; + } return page_with_title($title, [ msg(), buttons([ diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php index c67ca740..95282eb5 100644 --- a/includes/view/Shifts_view.php +++ b/includes/view/Shifts_view.php @@ -2,10 +2,12 @@ function Shift_editor_info_render($shift) { $info = []; - if ($shift['created_by_user_id'] != null) + 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']))); - if ($shift['edited_by_user_id'] != null) + } + 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']))); + } return join('
', $info); } @@ -14,32 +16,36 @@ function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null, if ($user_angeltype == null) { $user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype); - if ($user_angeltype === false) + if ($user_angeltype === false) { engelsystem_error('Unable to load user angeltype.'); + } } - if (Shift_signup_allowed($shift, $angeltype, $user_angeltype, $user_shifts)) + if (Shift_signup_allowed($shift, $angeltype, $user_angeltype, $user_shifts)) { return button(page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'], _('Sign up')); - elseif ($user_angeltype == null) + } elseif ($user_angeltype == null) { return button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], sprintf(_('Become %s'), $angeltype['name'])); - else - return ''; + } + return ''; } function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source, $user_shift_admin, $admin_rooms, $admin_shifttypes, $user_shifts, $signed_up) { $parsedown = new Parsedown(); $angeltypes = []; - foreach ($angeltypes_source as $angeltype) + foreach ($angeltypes_source as $angeltype) { $angeltypes[$angeltype['id']] = $angeltype; + } $needed_angels = ''; foreach ($shift['NeedAngels'] as $needed_angeltype) { $class = 'progress-bar-warning'; - if ($needed_angeltype['taken'] == 0) + if ($needed_angeltype['taken'] == 0) { $class = 'progress-bar-danger'; - if ($needed_angeltype['taken'] >= $needed_angeltype['count']) + } + if ($needed_angeltype['taken'] >= $needed_angeltype['count']) { $class = 'progress-bar-success'; + } $needed_angels .= '
'; $needed_angels .= '
' . Shift_signup_button_render($shift, $angeltypes[$needed_angeltype['TID']]) . '
'; @@ -51,8 +57,9 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source, foreach ($shift['ShiftEntry'] as $shift_entry) { if ($shift_entry['TID'] == $needed_angeltype['TID']) { $entry = User_Nick_render(User($shift_entry['UID'])); - if ($shift_entry['freeloaded']) + if ($shift_entry['freeloaded']) { $entry = '' . $entry . ''; + } if ($user_shift_admin) { $entry .= '
'; $entry .= button_glyph(page_link_to('user_myshifts') . '&edit=' . $shift_entry['id'] . '&id=' . $shift_entry['UID'], 'pencil', 'btn-xs'); @@ -69,7 +76,6 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source, } return page_with_title($shift['name'] . ' %c', [ - msg(), Shift_collides($shift, $user_shifts) ? info(_('This shift collides with one of your shifts.'), true) : '', $signed_up ? info(_('You are signed up for this shift.'), true) : '', diff --git a/includes/view/UserAngelTypes_view.php b/includes/view/UserAngelTypes_view.php index 29bde3c4..802ec5aa 100644 --- a/includes/view/UserAngelTypes_view.php +++ b/includes/view/UserAngelTypes_view.php @@ -1,86 +1,88 @@ \ No newline at end of file diff --git a/includes/view/User_view.php b/includes/view/User_view.php index 4f61006e..5c258fc7 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -3,7 +3,7 @@ /** * Available T-Shirt sizes */ -$tshirt_sizes = array( +$tshirt_sizes = [ '' => _("Please select..."), 'S' => "S", 'M' => "M", @@ -17,7 +17,7 @@ $tshirt_sizes = array( 'M-G' => "M Girl", 'L-G' => "L Girl", 'XL-G' => "XL Girl" -); +]; /** * Displays the welcome message to the user and shows a login form. @@ -112,12 +112,12 @@ function Users_view($users, $order_by, $arrived_count, $active_count, $force_act 'actions' => '' . count($users) . '' ); - return page_with_title(_('All users'), array( + return page_with_title(_('All users'), [ msg(), - buttons(array( + buttons([ button(page_link_to('register'), glyph('plus') . _('New user')) - )), - table(array( + ]), + 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), @@ -131,8 +131,8 @@ function Users_view($users, $order_by, $arrived_count, $active_count, $force_act 'Size' => Users_table_header_link('Size', _('Size'), $order_by), 'lastLogIn' => Users_table_header_link('lastLogIn', _('Last login'), $order_by), 'actions' => '' - ), $users) - )); + ], $users) + ]); } function Users_table_header_link($column, $label, $order_by) { @@ -141,24 +141,28 @@ function Users_table_header_link($column, $label, $order_by) { function User_shift_state_render($user) { $upcoming_shifts = ShiftEntries_upcoming_for_user($user); - if ($upcoming_shifts === false) + if ($upcoming_shifts === false) { return false; + } - if (count($upcoming_shifts) == 0) + if (count($upcoming_shifts) == 0) { return '' . _("Free") . ''; + } - if ($upcoming_shifts[0]['start'] > time()) - if ($upcoming_shifts[0]['start'] - time() > 3600) + if ($upcoming_shifts[0]['start'] > time()) { + if ($upcoming_shifts[0]['start'] - time() > 3600) { return '' . _("Next shift %c") . ''; - else + } else { return '' . _("Next shift %c") . ''; - + } + } $halfway = ($upcoming_shifts[0]['start'] + $upcoming_shifts[0]['end']) / 2; - if (time() < $halfway) + if (time() < $halfway) { return '' . _("Shift starts %c") . ''; - else + } else { return '' . _("Shift ends %c") . ''; + } } function User_view($user_source, $admin_user_privilege, $freeloader, $user_angeltypes, $user_groups, $shifts, $its_me) { @@ -166,76 +170,83 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel $user_name = htmlspecialchars($user_source['Vorname']) . " " . htmlspecialchars($user_source['Name']); - $myshifts_table = array(); + $myshifts_table = []; $timesum = 0; foreach ($shifts as $shift) { $shift_info = '' . $shift['name'] . ''; - if ($shift['title']) + if ($shift['title']) { $shift_info .= '
' . $shift['title'] . ''; + } foreach ($shift['needed_angeltypes'] as $needed_angel_type) { $shift_info .= '
' . $needed_angel_type['name'] . ': '; - $shift_entries = array(); + $shift_entries = []; foreach ($needed_angel_type['users'] as $user_shift) { $member = User_Nick_render($user_shift); - if ($user_shift['freeloaded']) + if ($user_shift['freeloaded']) { $member = '' . $member . ''; + } $shift_entries[] = $member; } $shift_info .= join(", ", $shift_entries); } - $myshift = array( + $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'] - ); + ]; if ($shift['freeloaded']) { - if (in_array("user_shifts_admin", $privileges)) + if (in_array("user_shifts_admin", $privileges)) { $myshift['comment'] .= '

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

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

' . _("Freeloaded") . '

'; + } } $myshift['actions'] = [ button(shift_link($shift), glyph('eye-open') . _('view'), 'btn-xs') ]; - if ($its_me || in_array('user_shifts_admin', $privileges)) + 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'); - if (($shift['start'] > time() + $LETZTES_AUSTRAGEN * 3600) || in_array('user_shifts_admin', $privileges)) + } + 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'] = table_buttons($myshift['actions']); - if ($shift['freeloaded']) + if ($shift['freeloaded']) { $timesum += (- 2 * ($shift['end'] - $shift['start'])); - else + } else { $timesum += ($shift['end'] - $shift['start']); + } $myshifts_table[] = $myshift; } - if (count($myshifts_table) > 0) - $myshifts_table[] = array( + if (count($myshifts_table) > 0) { + $myshifts_table[] = [ 'date' => '' . _("Sum:") . '', 'time' => "" . round($timesum / 3600, 1) . " h", 'room' => "", 'shift_info' => "", 'comment' => "", 'actions' => "" - ); + ]; + } - return page_with_title(' ' . htmlspecialchars($user_source['Nick']) . ' ' . $user_name . '', array( + return page_with_title(' ' . htmlspecialchars($user_source['Nick']) . ' ' . $user_name . '', [ msg(), - div('row', array( - div('col-md-3', array( + div('row', [ + div('col-md-3', [ '

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

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

' . _("User state") . '

', ($admin_user_privilege && $freeloader) ? ' ' . _("Freeloader") . '
' : '', $user_source['Gekommen'] ? User_shift_state_render($user_source) . '
' : '', @@ -243,19 +254,19 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel $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', array( + ]), + div('col-md-3', [ '

' . _("Angeltypes") . '

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

' . _("Rights") . '

', User_groups_render($user_groups) - )) - )), - div('row space-top', array( - div('col-md-12', array( - buttons(array( + ]) + ]), + 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")) : '', @@ -264,63 +275,65 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel $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')) : '' - )) - )) - )), + ]) + ]) + ]), ($its_me || $admin_user_privilege) ? '

' . _("Shifts") . '

' : '', - ($its_me || $admin_user_privilege) ? table(array( + ($its_me || $admin_user_privilege) ? table([ 'date' => _("Day"), 'time' => _("Time"), 'room' => _("Location"), 'shift_info' => _("Name & workmates"), 'comment' => _("Comment"), 'actions' => _("Action") - ), $myshifts_table) : '', + ], $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) : '' - )); + ]); } /** * View for password recovery step 1: E-Mail */ function User_password_recovery_view() { - return page_with_title(user_password_recovery_title(), array( + 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(array( + form([ form_text('email', _("E-Mail"), ""), form_submit('submit', _("Recover")) - )) - )); + ]) + ]); } /** * View for password recovery step 2: New password */ function User_password_set_view() { - return page_with_title(user_password_recovery_title(), array( + return page_with_title(user_password_recovery_title(), [ msg(), _("Please enter a new password."), - form(array( + form([ form_password('password', _("Password")), form_password('password2', _("Confirm password")), form_submit('submit', _("Save")) - )) - )); + ]) + ]); } function User_angeltypes_render($user_angeltypes) { - $output = array(); + $output = []; foreach ($user_angeltypes as $angeltype) { $class = ""; - if ($angeltype['restricted'] == 1) - if ($angeltype['confirm_user_id'] != null) + if ($angeltype['restricted'] == 1) { + if ($angeltype['confirm_user_id'] != null) { $class = 'text-success'; - else + } else { $class = 'text-warning'; - else + } + } else { $class = 'text-success'; + } $output[] = '' . ($angeltype['coordinator'] ? glyph('education') : '') . $angeltype['name'] . ''; } return join('
', $output); -- cgit v1.2.3-54-g00ecf