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();
$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');
} else {
redirect(page_link_to('user_shifts'));
@ -33,7 +33,7 @@ function shift_entry_add_controller()
$shift['Name'] = $room_array[$shift['RID']];
$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');
} else {
redirect(page_link_to('user_shifts'));
@ -64,7 +64,7 @@ function shift_entry_add_controller()
if (
$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('shiftentry_edit_angeltype_supporter', $privileges)

View File

@ -8,10 +8,13 @@ use Engelsystem\ShiftSignupState;
*/
function shift_link($shift)
{
$link = page_link_to('shifts', ['action' => 'view']);
$parameters = ['action' => 'view'];
if (isset($shift['SID'])) {
$link .= '&shift_id=' . $shift['SID'];
$parameters['shift_id'] = $shift['SID'];
}
$link = page_link_to('shifts', $parameters);
return $link;
}
@ -201,7 +204,7 @@ function shift_delete_controller()
}
// 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'));
}
$shift_id = $request->input('delete_shift');
@ -316,8 +319,6 @@ function shifts_controller()
/**
* Redirects the user to his next shift.
*
* @return false
*/
function shift_next_controller()
{

View File

@ -23,7 +23,7 @@ function admin_arrive()
$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_source = User($user_id);
if ($user_source != null) {
@ -39,7 +39,7 @@ function admin_arrive()
} else {
$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_source = User($user_id);
if ($user_source != null) {

View File

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

View File

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

View File

@ -46,7 +46,7 @@ function user_myshifts()
),
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');
$shift = DB::selectOne('
SELECT
@ -124,7 +124,7 @@ function user_myshifts()
} else {
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');
$shift = DB::selectOne('
SELECT *

View File

@ -170,7 +170,11 @@ function strip_request_item($name, $default_value = null)
function test_request_int($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)
{
return page_with_title(glyph('map-marker') . $room['Name'], [
$shiftsFilterRenderer->render(room_link($room)),
$shiftsFilterRenderer->render($room),
$shiftCalendarRenderer->render()
]);
}

View File

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

View File

@ -39,17 +39,22 @@ class ShiftsFilterRenderer
/**
* Renders the filter.
*
* @param string $link_base
* @param array $room
* @return string Generated HTML
*/
public function render($link_base)
public function render($room)
{
$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);
$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');
}