fix shift view
This commit is contained in:
parent
ec40e10ebd
commit
15243f15fc
|
@ -200,17 +200,19 @@ function shift_controller() {
|
||||||
$angeltypes = AngelTypes();
|
$angeltypes = AngelTypes();
|
||||||
$user_shifts = Shifts_by_user($user);
|
$user_shifts = Shifts_by_user($user);
|
||||||
|
|
||||||
$signed_up = false;
|
$shift_signup_state = null;
|
||||||
foreach ($user_shifts as $user_shift) {
|
foreach ($angeltypes as $angeltype) {
|
||||||
if ($user_shift['SID'] == $shift['SID']) {
|
$angeltype_signup_state = Shift_signup_allowed($user, $shift, $angeltype, null, $user_shifts);
|
||||||
$signed_up = true;
|
if ($shift_signup_state == null) {
|
||||||
break;
|
$shift_signup_state = $angeltype_signup_state;
|
||||||
|
} else {
|
||||||
|
$shift_signup_state = $shift_signup_state->combineWith($angeltype_signup_state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
$shift['name'],
|
$shift['name'],
|
||||||
Shift_view($shift, $shifttype, $room, in_array('admin_shifts', $privileges), $angeltypes, in_array('user_shifts_admin', $privileges), in_array('admin_rooms', $privileges), in_array('shifttypes', $privileges), $user_shifts, $signed_up)
|
Shift_view($shift, $shifttype, $room, $angeltypes, $user_shifts, $shift_signup_state)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
use Engelsystem\ShiftSignupState;
|
||||||
|
|
||||||
function Shift_editor_info_render($shift) {
|
function Shift_editor_info_render($shift) {
|
||||||
$info = [];
|
$info = [];
|
||||||
|
@ -27,7 +28,14 @@ function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null,
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source, $user_shift_admin, $admin_rooms, $admin_shifttypes, $user_shifts, $signed_up) {
|
function Shift_view($shift, $shifttype, $room, $angeltypes_source, $user_shifts, 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();
|
$parsedown = new Parsedown();
|
||||||
|
|
||||||
$angeltypes = [];
|
$angeltypes = [];
|
||||||
|
@ -76,7 +84,7 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
|
||||||
return page_with_title($shift['name'] . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>', [
|
return page_with_title($shift['name'] . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>', [
|
||||||
msg(),
|
msg(),
|
||||||
Shift_collides($shift, $user_shifts) ? info(_('This shift collides with one of your shifts.'), true) : '',
|
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_signup_state->getState() == ShiftSignupState::SIGNED_UP ? info(_('You are signed up for this shift.'), true) : '',
|
||||||
($shift_admin || $admin_shifttypes || $admin_rooms) ? buttons([
|
($shift_admin || $admin_shifttypes || $admin_rooms) ? buttons([
|
||||||
$shift_admin ? button(shift_edit_link($shift), glyph('pencil') . _('edit')) : '',
|
$shift_admin ? button(shift_edit_link($shift), glyph('pencil') . _('edit')) : '',
|
||||||
$shift_admin ? button(shift_delete_link($shift), glyph('trash') . _('delete')) : '',
|
$shift_admin ? button(shift_delete_link($shift), glyph('trash') . _('delete')) : '',
|
||||||
|
|
Loading…
Reference in New Issue