diff options
author | Philip Häusler <msquare@notrademark.de> | 2014-12-25 22:32:18 +0100 |
---|---|---|
committer | Philip Häusler <msquare@notrademark.de> | 2014-12-25 22:32:18 +0100 |
commit | e89acc0c1d1188662da7490e3a75a4a5c3950a75 (patch) | |
tree | f646260cc23195008f6ca5152426b17641fc4f69 /includes/view | |
parent | bcd33c02c814a8d82c08c078c8fae287d1cd95a5 (diff) | |
parent | 544a51612f14c4f3cf7d1c4a6de26a99ea94b788 (diff) |
merge feature-shift-types
Diffstat (limited to 'includes/view')
-rw-r--r-- | includes/view/AngelTypes_view.php | 74 | ||||
-rw-r--r-- | includes/view/Rooms_view.php | 10 | ||||
-rw-r--r-- | includes/view/ShiftTypes_view.php | 80 | ||||
-rw-r--r-- | includes/view/Shifts_view.php | 112 | ||||
-rw-r--r-- | includes/view/User_view.php | 86 |
5 files changed, 288 insertions, 74 deletions
diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php index 7b3e162a..78563c0b 100644 --- a/includes/view/AngelTypes_view.php +++ b/includes/view/AngelTypes_view.php @@ -1,9 +1,19 @@ <?php + /** * AngelTypes */ /** + * Renders the angeltypes name as link. + * + * @param AngelType $angeltype + */ +function AngelType_name_render($angeltype) { + return '<a href="' . page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'] . '">' . ($angeltype['restricted'] ? glyph('lock') : '') . $angeltype['name'] . '</a>'; +} + +/** * Render angeltype membership state * * @param UserAngelType $user_angeltype @@ -35,15 +45,15 @@ function AngelType_delete_view($angeltype) { info(sprintf(_("Do you want to delete angeltype %s?"), $angeltype['name']), true), buttons(array( button(page_link_to('angeltypes'), _("cancel"), 'cancel'), - button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'] . '&confirmed', _("delete"), 'ok') - )) + button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'] . '&confirmed', _("delete"), 'ok') + )) )); } function AngelType_edit_view($name, $restricted, $description, $coordinator_mode) { return page_with_title(sprintf(_("Edit %s"), $name), array( buttons(array( - button(page_link_to('angeltypes'), _("Angeltypes"), 'back') + button(page_link_to('angeltypes'), _("Angeltypes"), 'back') )), msg(), form(array( @@ -52,16 +62,16 @@ function AngelType_edit_view($name, $restricted, $description, $coordinator_mode form_info("", _("Restricted angel types can only be used by an angel if enabled by an archangel (double opt-in).")), form_textarea('description', _("Description"), $description), form_info("", _("Please use markdown for the description.")), - form_submit('submit', _("Save")) - )) + form_submit('submit', _("Save")) + )) )); } function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angeltypes, $admin_angeltypes, $coordinator) { $buttons = array( - button(page_link_to('angeltypes'), _("Angeltypes"), 'back') + button(page_link_to('angeltypes'), _("Angeltypes"), 'back') ); - + if ($user_angeltype == null) $buttons[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), 'add'); else { @@ -69,24 +79,24 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel 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) $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'); - + $page = array( msg(), - buttons($buttons) + buttons($buttons) ); - + $page[] = '<h3>' . _("Description") . '</h3>'; $parsedown = new Parsedown(); if ($angeltype['description'] != "") $page[] = '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>'; - + // Team-Coordinators list missing - + $coordinators = array(); $members_confirmed = array(); $members_unconfirmed = array(); @@ -95,7 +105,7 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel if ($angeltype['restricted'] && $member['confirm_user_id'] == null) { $member['actions'] = join(" ", array( '<a href="' . page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $member['user_angeltype_id'] . '" class="ok">' . _("confirm") . '</a>', - '<a href="' . page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'] . '" class="cancel">' . _("deny") . '</a>' + '<a href="' . page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'] . '" class="cancel">' . _("deny") . '</a>' )); $members_unconfirmed[] = $member; } elseif ($member['coordinator']) { @@ -108,7 +118,7 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel if ($admin_user_angeltypes) $member['actions'] = join(" ", array( $admin_angeltypes ? '<a href="' . page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&coordinator=1" class="add">' . _("Add coordinator rights") . '</a>' : '', - '<a href="' . page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'] . '" class="cancel">' . _("remove") . '</a>' + '<a href="' . page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'] . '" class="cancel">' . _("remove") . '</a>' )); $members_confirmed[] = $member; } @@ -118,74 +128,74 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel $page[] = table(array( 'Nick' => _("Nick"), 'DECT' => _("DECT"), - 'actions' => "" + 'actions' => "" ), $coordinators); } $page[] = '<h3>' . _("Members") . '</h3>'; if ($admin_user_angeltypes) $page[] = buttons(array( - 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(array( 'Nick' => _("Nick"), 'DECT' => _("DECT"), - 'actions' => "" + 'actions' => "" ), $members_confirmed); - + if ($admin_user_angeltypes && $angeltype['restricted'] && count($members_unconfirmed) > 0) { $page[] = '<h3>' . _("Unconfirmed") . '</h3>'; $page[] = buttons(array( 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=delete_all&angeltype_id=' . $angeltype['id'], _("deny all"), 'cancel') )); $page[] = table(array( 'Nick' => _("Nick"), 'DECT' => _("DECT"), - 'actions' => "" + 'actions' => "" ), $members_unconfirmed); } - + return page_with_title(sprintf(_("Team %s"), $angeltype['name']), $page); } /** * Display the list of angeltypes. * - * @param array $angeltypes + * @param array $angeltypes */ function AngelTypes_list_view($angeltypes, $admin_angeltypes) { return page_with_title(angeltypes_title(), array( msg(), buttons(array( $admin_angeltypes ? button(page_link_to('angeltypes') . '&action=edit', _("New angeltype"), 'add') : '', - button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description")) + button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description")) )), table(array( 'name' => _("Name"), 'restricted' => glyph('lock') . _("Restricted"), 'membership' => _("Membership"), - 'actions' => "" - ), $angeltypes) + 'actions' => "" + ), $angeltypes) )); } function AngelTypes_about_view($angeltypes, $user_logged_in) { global $faq_url; - + $content = array( buttons(array( ! $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") + button($faq_url, _("FAQ"), "btn-primary") )), '<p>' . _("Here is the list of teams and their tasks. If you have questions, read the FAQ.") . '</p>', - '<hr />' + '<hr />' ); $parsedown = new Parsedown(); foreach ($angeltypes as $angeltype) { $content[] = '<h2>' . $angeltype['name'] . '</h2>'; - + if (isset($angeltype['user_angeltype_id'])) { $buttons = array(); if ($angeltype['user_angeltype_id'] != null) @@ -194,14 +204,14 @@ function AngelTypes_about_view($angeltypes, $user_logged_in) { $buttons[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), 'add'); $content[] = buttons($buttons); } - + 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'] != "") $content[] = '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>'; $content[] = '<hr />'; } - + return page_with_title(_("Teams/Job description"), $content); } diff --git a/includes/view/Rooms_view.php b/includes/view/Rooms_view.php new file mode 100644 index 00000000..bb41a4d3 --- /dev/null +++ b/includes/view/Rooms_view.php @@ -0,0 +1,10 @@ +<?php + +function Room_name_render($room) { + global $privileges; + if (in_array('admin_rooms', $privileges)) + return '<a href="' . room_link($room) . '">' . glyph('map-marker') . $room['Name'] . '</a>'; + return $room['Name']; +} + +?>
\ No newline at end of file diff --git a/includes/view/ShiftTypes_view.php b/includes/view/ShiftTypes_view.php new file mode 100644 index 00000000..10431440 --- /dev/null +++ b/includes/view/ShiftTypes_view.php @@ -0,0 +1,80 @@ +<?php + +function ShiftType_name_render($shifttype) { + global $privileges; + if (in_array('shifttypes', $privileges)) + return '<a href="' . shifttype_link($shifttype) . '">' . $shifttype['name'] . '</a>'; + return $shifttype['name']; +} + +function ShiftType_delete_view($shifttype) { + return page_with_title(sprintf(_("Delete shifttype %s"), $shifttype['name']), array( + info(sprintf(_("Do you want to delete shifttype %s?"), $shifttype['name']), true), + buttons(array( + 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) + $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')) + ]) + ]); +} + +function ShiftType_view($shifttype, $angeltype) { + $parsedown = new Parsedown(); + $title = $shifttype['name']; + if ($angeltype) + $title .= ' <small>' . sprintf(_('for team %s'), $angeltype['name']) . '</small>'; + 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') + ]), + $parsedown->parse($shifttype['description']) + ]); +} + +function ShiftTypes_list_view($shifttypes) { + foreach ($shifttypes as &$shifttype) { + $shifttype['name'] = '<a href="' . page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype['id'] . '">' . $shifttype['name'] . '</a>'; + $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') + ]); + } + + return page_with_title(shifttypes_title(), [ + msg(), + buttons([ + button(page_link_to('shifttypes') . '&action=edit', _('New shifttype'), 'add') + ]), + table([ + 'name' => _('Name'), + 'actions' => '' + ], $shifttypes) + ]); +} + +?>
\ No newline at end of file diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php index d0e7d809..00c18572 100644 --- a/includes/view/Shifts_view.php +++ b/includes/view/Shifts_view.php @@ -1,7 +1,117 @@ <?php + +function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null, $user_shifts = null) { + global $user; + + if ($user_angeltype == null) { + $user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype); + if ($user_angeltype === false) + engelsystem_error('Unable to load user angeltype.'); + } + + 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) + return button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], sprintf('Become %s', $angeltype['name'])); + else + 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) + $angeltypes[$angeltype['id']] = $angeltype; + + $needed_angels = ''; + foreach ($shift['NeedAngels'] as $needed_angeltype) { + $class = 'progress-bar-warning'; + if ($needed_angeltype['taken'] == 0) + $class = 'progress-bar-danger'; + if ($needed_angeltype['taken'] >= $needed_angeltype['count']) + $class = 'progress-bar-success'; + $needed_angels .= '<div class="list-group-item">'; + + $needed_angels .= '<div class="pull-right">' . Shift_signup_button_render($shift, $angeltypes[$needed_angeltype['TID']]) . '</div>'; + + $needed_angels .= '<h3>' . AngelType_name_render($angeltypes[$needed_angeltype['TID']]) . '</h3>'; + $needed_angels .= progress_bar(0, $needed_angeltype['count'], $needed_angeltype['taken'], $class, $needed_angeltype['taken'] . ' / ' . $needed_angeltype['count']); + + $angels = []; + 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']) + $entry = '<strike>' . $entry . '</strike>'; + if ($user_shift_admin) { + $entry .= ' <div class="btn-group">'; + $entry .= button_glyph(page_link_to('user_myshifts') . '&edit=' . $shift['SID'] . '&id=' . $shift_entry['UID'], 'pencil', 'btn-xs'); + $entry .= button_glyph(page_link_to('user_shifts') . '&entry_id=' . $shift_entry['id'], 'trash', 'btn-xs'); + $entry .= '</div>'; + } + $angels[] = $entry; + } + } + + $needed_angels .= join(', ', $angels); + + $needed_angels .= '</div>'; + } + + return page_with_title($shift['name'] . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>', [ + 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) : '', + ($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', [ + '<h4>' . _('Title') . '</h4>', + '<p class="lead">' . ($shift['URL'] != '' ? '<a href="' . $shift['URL'] . '">' . $shift['title'] . '</a>' : $shift['title']) . '</p>' + ]), + div('col-sm-3 col-xs-6', [ + '<h4>' . _('Start') . '</h4>', + '<p class="lead' . (time() >= $shift['start'] ? ' text-success' : '') . '">', + glyph('calendar') . date('y-m-d', $shift['start']), + '<br />', + glyph('time') . date('H:i', $shift['start']), + '</p>' + ]), + div('col-sm-3 col-xs-6', [ + '<h4>' . _('End') . '</h4>', + '<p class="lead' . (time() >= $shift['end'] ? ' text-success' : '') . '">', + glyph('calendar') . date('y-m-d', $shift['end']), + '<br />', + glyph('time') . date('H:i', $shift['end']), + '</p>' + ]), + div('col-sm-3 col-xs-6', [ + '<h4>' . _('Location') . '</h4>', + '<p class="lead">' . glyph('map-marker') . $room['Name'] . '</p>' + ]) + ]), + div('row', [ + div('col-sm-6', [ + '<h2>' . _('Needed angels') . '</h2>', + '<div class="list-group">' . $needed_angels . '</div>' + ]), + div('col-sm-6', [ + '<h2>' . _('Description') . '</h2>', + $parsedown->parse($shifttype['description']) + ]) + ]) + ]); +} + /** * Calc shift length in format 12:23h. - * @param Shift $shift + * + * @param Shift $shift */ function shift_length($shift) { $length = floor(($shift['end'] - $shift['start']) / (60 * 60)) . ":"; diff --git a/includes/view/User_view.php b/includes/view/User_view.php index 99ca3eeb..a7d77b19 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -16,7 +16,7 @@ $tshirt_sizes = array( 'S-G' => "S Girl", 'M-G' => "M Girl", 'L-G' => "L Girl", - 'XL-G' => "XL Girl" + 'XL-G' => "XL Girl" ); function Users_view($users, $order_by, $arrived_count, $active_count, $force_active_count, $freeloads_count, $tshirts_count) { @@ -28,7 +28,7 @@ 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(array( - 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[] = array( @@ -38,13 +38,13 @@ function Users_view($users, $order_by, $arrived_count, $active_count, $force_act 'force_active' => $force_active_count, 'freeloads' => $freeloads_count, 'Tshirt' => $tshirts_count, - 'actions' => '<strong>' . count($users) . '</strong>' + 'actions' => '<strong>' . count($users) . '</strong>' ); - + return page_with_title(_('All users'), array( msg(), buttons(array( - button(page_link_to('register'), glyph('plus') . _('New user')) + button(page_link_to('register'), glyph('plus') . _('New user')) )), table(array( 'Nick' => Users_table_header_link('Nick', _('Nick'), $order_by), @@ -58,8 +58,8 @@ function Users_view($users, $order_by, $arrived_count, $active_count, $force_act '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) + 'actions' => '' + ), $users) )); } @@ -71,18 +71,18 @@ function User_shift_state_render($user) { $upcoming_shifts = ShiftEntries_upcoming_for_user($user); if ($upcoming_shifts === false) return false; - + if (count($upcoming_shifts) == 0) return '<span class="text-success">' . _("Free") . '</span>'; - + if ($upcoming_shifts[0]['start'] > time()) if ($upcoming_shifts[0]['start'] - time() > 3600) return '<span class="text-success moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Next shift %c") . '</span>'; else return '<span class="text-warning moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Next shift %c") . '</span>'; - + $halfway = ($upcoming_shifts[0]['start'] + $upcoming_shifts[0]['end']) / 2; - + if (time() < $halfway) return '<span class="text-danger moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Shift starts %c") . '</span>'; else @@ -91,17 +91,19 @@ function User_shift_state_render($user) { function User_view($user_source, $admin_user_privilege, $freeloader, $user_angeltypes, $user_groups, $shifts, $its_me) { global $LETZTES_AUSTRAGEN, $privileges; - + $user_name = htmlspecialchars($user_source['Vorname']) . " " . htmlspecialchars($user_source['Name']); - + $myshifts_table = array(); $html = ""; $timesum = 0; foreach ($shifts as $shift) { - $shift_info = $shift['name']; + $shift_info = '<a href="' . shift_link($shift) . '">' . $shift['name'] . '</a>'; + if ($shift['title']) + $shift_info .= '<br /><a href="' . shift_link($shift) . '">' . $shift['title'] . '</a>'; foreach ($shift['needed_angeltypes'] as $needed_angel_type) { $shift_info .= '<br><b>' . $needed_angel_type['name'] . ':</b> '; - + $shift_entries = array(); foreach ($needed_angel_type['users'] as $user_shift) { if ($its_me) @@ -110,34 +112,36 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel $member = User_Nick_render($user_shift); if ($user_shift['freeloaded']) $member = '<strike>' . $member . '</strike>'; - + $shift_entries[] = $member; } $shift_info .= join(", ", $shift_entries); } - + $myshift = array( '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'] + 'comment' => $shift['Comment'] ); - + if ($shift['freeloaded']) { if (in_array("user_shifts_admin", $privileges)) $myshift['comment'] .= '<br /><p class="error">' . _("Freeloaded") . ': ' . $shift['freeload_comment'] . '</p>'; else $myshift['comment'] .= '<br /><p class="error">' . _("Freeloaded") . '</p>'; } - - $myshift['actions'] = array(); + + $myshift['actions'] = [ + 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'); 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']) $timesum += - 2 * ($shift['end'] - $shift['start']); else @@ -151,9 +155,9 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel 'room' => "", 'shift_info' => "", 'comment' => "", - 'actions' => "" + 'actions' => "" ); - + return page_with_title('<span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . ' <small>' . $user_name . '</small>', array( msg(), div('row', array( @@ -161,7 +165,7 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel '<h1>', '<span class="glyphicon glyphicon-phone"></span>', $user_source['DECT'], - '</h1>' + '</h1>' )), div('col-md-3', array( '<h4>' . _("User state") . '</h4>', @@ -169,28 +173,28 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel $user_source['Gekommen'] ? User_shift_state_render($user_source) . '<br />' : '', ($user_source['Gekommen'] ? '<span class="text-success"><span class="glyphicon glyphicon-home"></span> ' . _("Arrived") . '</span>' : '<span class="text-danger">' . _("Not arrived") . '</span>'), ($user_source['Gekommen'] && $admin_user_privilege && $user_source['Aktiv']) ? ' <span class="text-success">' . _("Active") . '</span>' : '', - ($user_source['Gekommen'] && $admin_user_privilege && $user_source['Tshirt']) ? ' <span class="text-success">' . _("T-Shirt") . '</span>' : '' + ($user_source['Gekommen'] && $admin_user_privilege && $user_source['Tshirt']) ? ' <span class="text-success">' . _("T-Shirt") . '</span>' : '' )), div('col-md-3', array( '<h4>' . _("Angeltypes") . '</h4>', - User_angeltypes_render($user_angeltypes) + User_angeltypes_render($user_angeltypes) )), div('col-md-3', array( '<h4>' . _("Rights") . '</h4>', - User_groups_render($user_groups) - )) + User_groups_render($user_groups) + )) )), div('row space-top', array( div('col-md-12', array( buttons(array( $admin_user_privilege ? button(page_link_to('admin_user') . '&id=' . $user_source['UID'], glyph("edit") . _("edit")) : '', - ($admin_user_privilege && !$user_source['Gekommen']) ? button(page_link_to('admin_arrive') . '&arrived=' . $user_source['UID'], _("arrived")) : '', + ($admin_user_privilege && ! $user_source['Gekommen']) ? button(page_link_to('admin_arrive') . '&arrived=' . $user_source['UID'], _("arrived")) : '', $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')) : '' - )) - )) + $its_me ? button(page_link_to('user_myshifts') . '&reset', glyph('repeat') . _('Reset API key')) : '' + )) + )) )), ($its_me || $admin_user_privilege) ? '<h2>' . _("Shifts") . '</h2>' : '', ($its_me || $admin_user_privilege) ? table(array( @@ -199,9 +203,9 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel 'room' => _("Location"), 'shift_info' => _("Name & workmates"), 'comment' => _("Comment"), - 'actions' => _("Action") + 'actions' => _("Action") ), $myshifts_table) : '', - $its_me && count($shifts) == 0 ? error(sprintf(_("Go to the <a href=\"%s\">shifts table</a> to sign yourself up for some shifts."), page_link_to('user_shifts')), true) : '' + $its_me && count($shifts) == 0 ? error(sprintf(_("Go to the <a href=\"%s\">shifts table</a> to sign yourself up for some shifts."), page_link_to('user_shifts')), true) : '' )); } @@ -214,8 +218,8 @@ function User_password_recovery_view() { _("We will send you an e-mail with a password recovery link. Please use the email address you used for registration."), form(array( form_text('email', _("E-Mail"), ""), - form_submit('submit', _("Recover")) - )) + form_submit('submit', _("Recover")) + )) )); } @@ -229,8 +233,8 @@ function User_password_set_view() { form(array( form_password('password', _("Password")), form_password('password2', _("Confirm password")), - form_submit('submit', _("Save")) - )) + form_submit('submit', _("Save")) + )) )); } @@ -261,7 +265,7 @@ function User_groups_render($user_groups) { /** * Render a users avatar. * - * @param User $user + * @param User $user * @return string */ function User_Avatar_render($user) { @@ -271,7 +275,7 @@ function User_Avatar_render($user) { /** * Render a user nickname. * - * @param User $user_source + * @param User $user_source * @return string */ function User_Nick_render($user_source) { |