This commit is contained in:
Igor Scheller 2017-08-30 14:59:27 +02:00
parent a473a56f1d
commit 96f1d9fd54
10 changed files with 50 additions and 32 deletions

View File

@ -13,7 +13,7 @@ function shift_entry_add_controller()
$request = request(); $request = request();
$shift_id = 0; $shift_id = 0;
if ($request->has('shift_id') && preg_match('/^\d*$/', $request->input('shift_id'))) { if ($request->has('shift_id') && preg_match('/^\d+$/', $request->input('shift_id'))) {
$shift_id = $request->input('shift_id'); $shift_id = $request->input('shift_id');
} else { } else {
redirect(page_link_to('user_shifts')); redirect(page_link_to('user_shifts'));
@ -33,7 +33,7 @@ function shift_entry_add_controller()
$shift['Name'] = $room_array[$shift['RID']]; $shift['Name'] = $room_array[$shift['RID']];
$type_id = 0; $type_id = 0;
if ($request->has('type_id') && preg_match('/^\d*$/', $request->input('type_id'))) { if ($request->has('type_id') && preg_match('/^\d+$/', $request->input('type_id'))) {
$type_id = $request->input('type_id'); $type_id = $request->input('type_id');
} else { } else {
redirect(page_link_to('user_shifts')); redirect(page_link_to('user_shifts'));
@ -64,7 +64,7 @@ function shift_entry_add_controller()
if ( if (
$request->has('user_id') $request->has('user_id')
&& preg_match('/^\d*$/', $request->input('user_id')) && preg_match('/^\d+$/', $request->input('user_id'))
&& ( && (
in_array('user_shifts_admin', $privileges) in_array('user_shifts_admin', $privileges)
|| in_array('shiftentry_edit_angeltype_supporter', $privileges) || in_array('shiftentry_edit_angeltype_supporter', $privileges)

View File

@ -8,10 +8,13 @@ use Engelsystem\ShiftSignupState;
*/ */
function shift_link($shift) function shift_link($shift)
{ {
$link = page_link_to('shifts', ['action' => 'view']); $parameters = ['action' => 'view'];
if (isset($shift['SID'])) { if (isset($shift['SID'])) {
$link .= '&shift_id=' . $shift['SID']; $parameters['shift_id'] = $shift['SID'];
} }
$link = page_link_to('shifts', $parameters);
return $link; return $link;
} }
@ -201,7 +204,7 @@ function shift_delete_controller()
} }
// Schicht komplett löschen (nur für admins/user mit user_shifts_admin privileg) // Schicht komplett löschen (nur für admins/user mit user_shifts_admin privileg)
if (!$request->has('delete_shift') || !preg_match('/^\d*$/', $request->input('delete_shift'))) { if (!$request->has('delete_shift') || !preg_match('/^\d+$/', $request->input('delete_shift'))) {
redirect(page_link_to('user_shifts')); redirect(page_link_to('user_shifts'));
} }
$shift_id = $request->input('delete_shift'); $shift_id = $request->input('delete_shift');
@ -316,8 +319,6 @@ function shifts_controller()
/** /**
* Redirects the user to his next shift. * Redirects the user to his next shift.
*
* @return false
*/ */
function shift_next_controller() function shift_next_controller()
{ {

View File

@ -23,7 +23,7 @@ function admin_arrive()
$search = strip_request_item('search'); $search = strip_request_item('search');
} }
if ($request->has('reset') && preg_match('/^\d*$/', $request->input('reset'))) { if ($request->has('reset') && preg_match('/^\d+$/', $request->input('reset'))) {
$user_id = $request->input('reset'); $user_id = $request->input('reset');
$user_source = User($user_id); $user_source = User($user_id);
if ($user_source != null) { if ($user_source != null) {
@ -39,7 +39,7 @@ function admin_arrive()
} else { } else {
$msg = error(_('Angel not found.'), true); $msg = error(_('Angel not found.'), true);
} }
} elseif ($request->has('arrived') && preg_match('/^\d*$/', $request->input('arrived'))) { } elseif ($request->has('arrived') && preg_match('/^\d+$/', $request->input('arrived'))) {
$user_id = $request->input('arrived'); $user_id = $request->input('arrived');
$user_source = User($user_id); $user_source = User($user_id);
if ($user_source != null) { if ($user_source != null) {

View File

@ -98,10 +98,12 @@ function admin_import()
if ($valid) { if ($valid) {
redirect( redirect(
page_link_to('admin_import') page_link_to('admin_import', [
. '&step=check&shifttype_id=' . $shifttype_id 'step' => 'check',
. '&add_minutes_end=' . $add_minutes_end 'shifttype_id' => $shifttype_id,
. '&add_minutes_start=' . $add_minutes_start 'add_minutes_end' => $add_minutes_end,
'add_minutes_start' => $add_minutes_start,
])
); );
} else { } else {
$html .= div('well well-sm text-center', [ $html .= div('well well-sm text-center', [
@ -207,10 +209,12 @@ function admin_import()
], shifts_printable($events_deleted, $shifttypes)), ], shifts_printable($events_deleted, $shifttypes)),
form_submit('submit', _('Import')) form_submit('submit', _('Import'))
], ],
page_link_to('admin_import') page_link_to('admin_import', [
. '&step=import&shifttype_id=' . $shifttype_id 'step' => 'import',
. '&add_minutes_end=' . $add_minutes_end 'shifttype_id' => $shifttype_id,
. '&add_minutes_start=' . $add_minutes_start 'add_minutes_end' => $add_minutes_end,
'add_minutes_start' => $add_minutes_start,
])
); );
break; break;

View File

@ -179,11 +179,11 @@ function admin_user()
switch ($request->input('action')) { switch ($request->input('action')) {
case 'save_groups': case 'save_groups':
if ($user_id != $user['UID']) { if ($user_id != $user['UID']) {
$my_highest_group = DB::select( $my_highest_group = DB::selectOne(
'SELECT * FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id`', 'SELECT * FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id`',
[$user['UID']] [$user['UID']]
); );
$his_highest_group = DB::select( $his_highest_group = DB::selectOne(
'SELECT * FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id`', 'SELECT * FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id`',
[$user_id] [$user_id]
); );

View File

@ -46,7 +46,7 @@ function user_myshifts()
), ),
button(page_link_to('user_myshifts', ['reset' => 'ack']), _('Continue'), 'btn-danger') button(page_link_to('user_myshifts', ['reset' => 'ack']), _('Continue'), 'btn-danger')
]); ]);
} elseif ($request->has('edit') && preg_match('/^\d*$/', $request->input('edit'))) { } elseif ($request->has('edit') && preg_match('/^\d+$/', $request->input('edit'))) {
$user_id = $request->input('edit'); $user_id = $request->input('edit');
$shift = DB::selectOne(' $shift = DB::selectOne('
SELECT SELECT
@ -124,7 +124,7 @@ function user_myshifts()
} else { } else {
redirect(page_link_to('user_myshifts')); redirect(page_link_to('user_myshifts'));
} }
} elseif ($request->has('cancel') && preg_match('/^\d*$/', $request->input('cancel'))) { } elseif ($request->has('cancel') && preg_match('/^\d+$/', $request->input('cancel'))) {
$user_id = $request->input('cancel'); $user_id = $request->input('cancel');
$shift = DB::selectOne(' $shift = DB::selectOne('
SELECT * SELECT *

View File

@ -170,7 +170,11 @@ function strip_request_item($name, $default_value = null)
function test_request_int($name) function test_request_int($name)
{ {
$input = request()->input($name); $input = request()->input($name);
return preg_match('/^\d*$/', $input); if (is_null($input)) {
return false;
}
return preg_match('/^\d+$/', $input);
} }
/** /**

View File

@ -12,7 +12,7 @@ use Engelsystem\ShiftsFilterRenderer;
function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer) function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer)
{ {
return page_with_title(glyph('map-marker') . $room['Name'], [ return page_with_title(glyph('map-marker') . $room['Name'], [
$shiftsFilterRenderer->render(room_link($room)), $shiftsFilterRenderer->render($room),
$shiftCalendarRenderer->render() $shiftCalendarRenderer->render()
]); ]);
} }

View File

@ -124,11 +124,15 @@ class ShiftCalendarShiftRenderer
} }
if (in_array('user_shifts_admin', $privileges)) { if (in_array('user_shifts_admin', $privileges)) {
$html .= '<li class="list-group-item">' . button( $html .= '<li class="list-group-item">' . _('Add more angels') . ':';
page_link_to('user_shifts', ['shift_id' => $shift['SID']]), foreach ($needed_angeltypes as $angeltype) {
_('Add more angels'), $html .= ' ' . button(
'btn-xs' page_link_to('user_shifts', ['shift_id' => $shift['SID'], 'type_id' => $angeltype['id']]),
) . '</li>'; $angeltype['name'],
'btn-xs'
);
}
$html .= '</li>';
} }
if ($html != '') { if ($html != '') {
return [ return [

View File

@ -39,17 +39,22 @@ class ShiftsFilterRenderer
/** /**
* Renders the filter. * Renders the filter.
* *
* @param string $link_base * @param array $room
* @return string Generated HTML * @return string Generated HTML
*/ */
public function render($link_base) public function render($room)
{ {
$toolbar = []; $toolbar = [];
if ($this->daySelectionEnabled && !empty($this->days)) { if ($this->daySelectionEnabled && !empty($this->days)) {
$selected_day = date('Y-m-d', $this->shiftsFilter->getStartTime()); $selected_day = date('Y-m-d', $this->shiftsFilter->getStartTime());
$day_dropdown_items = []; $day_dropdown_items = [];
foreach ($this->days as $day) { foreach ($this->days as $day) {
$day_dropdown_items[] = toolbar_item_link($link_base . '&shifts_filter_day=' . $day, '', $day); $link = page_link_to('rooms', [
'action' => 'view',
'room_id' => $room['RID'],
'shifts_filter_day' => $day,
]);
$day_dropdown_items[] = toolbar_item_link($link, '', $day);
} }
$toolbar[] = toolbar_dropdown('', $selected_day, $day_dropdown_items, 'active'); $toolbar[] = toolbar_dropdown('', $selected_day, $day_dropdown_items, 'active');
} }