summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2017-08-30 14:59:27 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2017-08-30 15:35:12 +0200
commit96f1d9fd541d0c5ef78151f8c69a89c41684b67a (patch)
treee39f5afde165a55f49857d064675fa1876a66808 /includes
parenta473a56f1dbf568dc66cd6fcffe6b638308c542e (diff)
Bugfixes
Diffstat (limited to 'includes')
-rw-r--r--includes/controller/shift_entries_controller.php6
-rw-r--r--includes/controller/shifts_controller.php11
-rw-r--r--includes/pages/admin_arrive.php4
-rw-r--r--includes/pages/admin_import.php20
-rw-r--r--includes/pages/admin_user.php4
-rw-r--r--includes/pages/user_myshifts.php4
-rw-r--r--includes/sys_page.php6
-rw-r--r--includes/view/Rooms_view.php2
-rw-r--r--includes/view/ShiftCalendarShiftRenderer.php14
-rw-r--r--includes/view/ShiftsFilterRenderer.php11
10 files changed, 50 insertions, 32 deletions
diff --git a/includes/controller/shift_entries_controller.php b/includes/controller/shift_entries_controller.php
index 148b19fb..150db2e9 100644
--- a/includes/controller/shift_entries_controller.php
+++ b/includes/controller/shift_entries_controller.php
@@ -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)
diff --git a/includes/controller/shifts_controller.php b/includes/controller/shifts_controller.php
index c359850f..70011821 100644
--- a/includes/controller/shifts_controller.php
+++ b/includes/controller/shifts_controller.php
@@ -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()
{
diff --git a/includes/pages/admin_arrive.php b/includes/pages/admin_arrive.php
index 2f312b1f..48e2c91f 100644
--- a/includes/pages/admin_arrive.php
+++ b/includes/pages/admin_arrive.php
@@ -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) {
diff --git a/includes/pages/admin_import.php b/includes/pages/admin_import.php
index bf8c498c..e97f95e1 100644
--- a/includes/pages/admin_import.php
+++ b/includes/pages/admin_import.php
@@ -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;
diff --git a/includes/pages/admin_user.php b/includes/pages/admin_user.php
index 9b3b0f44..0620155b 100644
--- a/includes/pages/admin_user.php
+++ b/includes/pages/admin_user.php
@@ -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]
);
diff --git a/includes/pages/user_myshifts.php b/includes/pages/user_myshifts.php
index 60a26922..836bd566 100644
--- a/includes/pages/user_myshifts.php
+++ b/includes/pages/user_myshifts.php
@@ -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 *
diff --git a/includes/sys_page.php b/includes/sys_page.php
index df57d08a..33ec18b9 100644
--- a/includes/sys_page.php
+++ b/includes/sys_page.php
@@ -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);
}
/**
diff --git a/includes/view/Rooms_view.php b/includes/view/Rooms_view.php
index 76ce33a5..3c0440a4 100644
--- a/includes/view/Rooms_view.php
+++ b/includes/view/Rooms_view.php
@@ -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()
]);
}
diff --git a/includes/view/ShiftCalendarShiftRenderer.php b/includes/view/ShiftCalendarShiftRenderer.php
index f0488e83..0e5fc8c3 100644
--- a/includes/view/ShiftCalendarShiftRenderer.php
+++ b/includes/view/ShiftCalendarShiftRenderer.php
@@ -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'),
- 'btn-xs'
- ) . '</li>';
+ $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'
+ );
+ }
+ $html .= '</li>';
}
if ($html != '') {
return [
diff --git a/includes/view/ShiftsFilterRenderer.php b/includes/view/ShiftsFilterRenderer.php
index 43a23ef6..c3e0ccf1 100644
--- a/includes/view/ShiftsFilterRenderer.php
+++ b/includes/view/ShiftsFilterRenderer.php
@@ -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');
}