From b069a938c6721ab5adddcbec4cff858ded6f0e1e Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Tue, 9 Oct 2018 20:38:13 +0200 Subject: [PATCH] Changed user_link and some other user functions to use the user id --- .../controller/shift_entries_controller.php | 8 +++---- .../user_driver_licenses_controller.php | 4 ++-- .../controller/user_worklog_controller.php | 16 +++++++------- includes/controller/users_controller.php | 22 +++++++++---------- includes/pages/admin_arrive.php | 4 ++-- includes/pages/admin_user.php | 2 +- includes/view/ShiftEntry_view.php | 4 ++-- includes/view/Shifts_view.php | 2 +- includes/view/UserDriverLicenses_view.php | 2 +- includes/view/UserWorkLog_view.php | 6 ++--- includes/view/User_view.php | 4 ++-- 11 files changed, 37 insertions(+), 37 deletions(-) diff --git a/includes/controller/shift_entries_controller.php b/includes/controller/shift_entries_controller.php index 2c57f550..356a9db8 100644 --- a/includes/controller/shift_entries_controller.php +++ b/includes/controller/shift_entries_controller.php @@ -17,7 +17,7 @@ function shift_entries_controller() $action = strip_request_item('action'); if (empty($action)) { - redirect(user_link($user)); + redirect(user_link($user['UID'])); } switch ($action) { @@ -44,7 +44,7 @@ function shift_entry_create_controller() $shift = Shift($request->input('shift_id')); if (empty($shift)) { - redirect(user_link($user)); + redirect(user_link($user['UID'])); } $angeltype = AngelType($request->input('angeltype_id')); @@ -54,7 +54,7 @@ function shift_entry_create_controller() } if (empty($angeltype)) { - redirect(user_link($user)); + redirect(user_link($user['UID'])); } if (User_is_AngelType_supporter($user, $angeltype)) { @@ -345,7 +345,7 @@ function shift_entry_delete_controller() $signout_user = User($shiftEntry['UID']); if (!Shift_signout_allowed($shift, $angeltype, $signout_user)) { error(__('You are not allowed to remove this shift entry. If necessary, ask your supporter or heaven to do so.')); - redirect(user_link($signout_user)); + redirect(user_link($signout_user['UID'])); } if ($request->has('continue')) { diff --git a/includes/controller/user_driver_licenses_controller.php b/includes/controller/user_driver_licenses_controller.php index 422ad382..2a3f7023 100644 --- a/includes/controller/user_driver_licenses_controller.php +++ b/includes/controller/user_driver_licenses_controller.php @@ -130,7 +130,7 @@ function user_driver_license_edit_controller() } engelsystem_log('Driver license information updated.'); success(__('Your driver license information has been saved.')); - redirect(user_link($user_source)); + redirect(user_link($user_source['UID'])); } else { error(__('Please select at least one driving license.')); } @@ -138,7 +138,7 @@ function user_driver_license_edit_controller() UserDriverLicenses_delete($user_source['UID']); engelsystem_log('Driver license information removed.'); success(__('Your driver license information has been removed.')); - redirect(user_link($user_source)); + redirect(user_link($user_source['UID'])); } } diff --git a/includes/controller/user_worklog_controller.php b/includes/controller/user_worklog_controller.php index 640dcaba..a431643f 100644 --- a/includes/controller/user_worklog_controller.php +++ b/includes/controller/user_worklog_controller.php @@ -12,7 +12,7 @@ function user_worklog_delete_controller() $request = request(); $userWorkLog = UserWorkLog($request->input('user_worklog_id')); if (empty($userWorkLog)) { - redirect(user_link($user)); + redirect(user_link($user['UID'])); } $user_source = User($userWorkLog['user_id']); @@ -20,7 +20,7 @@ function user_worklog_delete_controller() UserWorkLog_delete($userWorkLog); success(__('Work log entry deleted.')); - redirect(user_link($user_source)); + redirect(user_link($user_source['UID'])); } return [ @@ -41,7 +41,7 @@ function user_worklog_edit_controller() $request = request(); $userWorkLog = UserWorkLog($request->input('user_worklog_id')); if (empty($userWorkLog)) { - redirect(user_link($user)); + redirect(user_link($user['UID'])); } $user_source = User($userWorkLog['user_id']); @@ -52,7 +52,7 @@ function user_worklog_edit_controller() UserWorkLog_update($userWorkLog); success(__('Work log entry updated.')); - redirect(user_link($user_source)); + redirect(user_link($user_source['UID'])); } } @@ -113,7 +113,7 @@ function user_worklog_add_controller() $request = request(); $user_source = User($request->input('user_id')); if (empty($user_source)) { - redirect(user_link($user)); + redirect(user_link($user['UID'])); } $userWorkLog = UserWorkLog_new($user_source); @@ -125,7 +125,7 @@ function user_worklog_add_controller() UserWorkLog_create($userWorkLog); success(__('Work log entry created.')); - redirect(user_link($user_source)); + redirect(user_link($user_source['UID'])); } } @@ -189,13 +189,13 @@ function user_worklog_controller() global $user, $privileges; if (!in_array('admin_user_worklog', $privileges)) { - redirect(user_link($user)); + redirect(user_link($user['UID'])); } $request = request(); $action = $request->input('action'); if (!$request->has('action')) { - redirect(user_link($user)); + redirect(user_link($user['UID'])); } switch ($action) { diff --git a/includes/controller/users_controller.php b/includes/controller/users_controller.php index 13264fd1..f49439da 100644 --- a/includes/controller/users_controller.php +++ b/includes/controller/users_controller.php @@ -59,7 +59,7 @@ function user_delete_controller() // You cannot delete yourself if ($user['UID'] == $user_source['UID']) { error(__('You cannot delete yourself.')); - redirect(user_link($user)); + redirect(user_link($user['UID'])); } if ($request->has('submit')) { @@ -101,30 +101,30 @@ function users_link() } /** - * @param array $user + * @param int $userId * @return string */ -function user_edit_link($user) +function user_edit_link($userId) { - return page_link_to('admin_user', ['user_id' => $user['UID']]); + return page_link_to('admin_user', ['user_id' => $userId]); } /** - * @param array $user + * @param int $userId * @return string */ -function user_delete_link($user) +function user_delete_link($userId) { - return page_link_to('users', ['action' => 'delete', 'user_id' => $user['UID']]); + return page_link_to('users', ['action' => 'delete', 'user_id' => $userId]); } /** - * @param array $user + * @param int $userId * @return string */ -function user_link($user) +function user_link($userId) { - return page_link_to('users', ['action' => 'view', 'user_id' => $user['UID']]); + return page_link_to('users', ['action' => 'view', 'user_id' => $userId]); } /** @@ -169,7 +169,7 @@ function user_edit_vouchers_controller() engelsystem_log(User_Nick_render($user_source) . ': ' . sprintf('Got %s vouchers', $user_source['got_voucher'])); - redirect(user_link($user_source)); + redirect(user_link($user_source['UID'])); } } diff --git a/includes/pages/admin_arrive.php b/includes/pages/admin_arrive.php index cb03437f..4f29b85d 100644 --- a/includes/pages/admin_arrive.php +++ b/includes/pages/admin_arrive.php @@ -36,7 +36,7 @@ function admin_arrive() ', [$user_id]); engelsystem_log('User set to not arrived: ' . User_Nick_render($user_source)); success(__('Reset done. Angel has not arrived.')); - redirect(user_link($user_source)); + redirect(user_link($user_source['UID'])); } else { $msg = error(__('Angel not found.'), true); } @@ -52,7 +52,7 @@ function admin_arrive() ', [time(), $user_id]); engelsystem_log('User set has arrived: ' . User_Nick_render($user_source)); success(__('Angel has been marked as arrived.')); - redirect(user_link($user_source)); + redirect(user_link($user_source['UID'])); } else { $msg = error(__('Angel not found.'), true); } diff --git a/includes/pages/admin_user.php b/includes/pages/admin_user.php index 2ef48eb7..b4dd9c1b 100644 --- a/includes/pages/admin_user.php +++ b/includes/pages/admin_user.php @@ -165,7 +165,7 @@ function admin_user() } $html .= buttons([ - button(user_delete_link($user_source), glyph('lock') . __('delete'), 'btn-danger') + button(user_delete_link($user_source['UID']), glyph('lock') . __('delete'), 'btn-danger') ]); $html .= "
"; diff --git a/includes/view/ShiftEntry_view.php b/includes/view/ShiftEntry_view.php index 7884e404..1d6ba3a3 100644 --- a/includes/view/ShiftEntry_view.php +++ b/includes/view/ShiftEntry_view.php @@ -22,7 +22,7 @@ function ShiftEntry_delete_view_admin($shiftEntry, $shift, $angeltype, $signoff_ $angeltype['name'] ), true), buttons([ - button(user_link($signoff_user), glyph('remove') . __('cancel')), + button(user_link($signoff_user['UID']), glyph('remove') . __('cancel')), button(shift_entry_delete_link($shiftEntry, [ 'continue' => 1 ]), glyph('ok') . __('delete'), 'btn-danger') @@ -51,7 +51,7 @@ function ShiftEntry_delete_view($shiftEntry, $shift, $angeltype, $signoff_user) $angeltype['name'] ), true), buttons([ - button(user_link($signoff_user), glyph('remove') . __('cancel')), + button(user_link($signoff_user['UID']), glyph('remove') . __('cancel')), button(shift_entry_delete_link($shiftEntry, [ 'continue' => 1 ]), glyph('ok') . __('delete'), 'btn-danger') diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php index 0aa89f2e..92447efd 100644 --- a/includes/view/Shifts_view.php +++ b/includes/view/Shifts_view.php @@ -141,7 +141,7 @@ function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupSt $admin_rooms ? button(room_link($room), glyph('map-marker') . $room['Name']) : '', ]; } - $buttons[] = button(user_link($user), ' ' . __('My shifts')); + $buttons[] = button(user_link($user['UID']), ' ' . __('My shifts')); $content[] = buttons($buttons); $content[] = Shift_view_header($shift, $room); diff --git a/includes/view/UserDriverLicenses_view.php b/includes/view/UserDriverLicenses_view.php index 317910b6..664a5d58 100644 --- a/includes/view/UserDriverLicenses_view.php +++ b/includes/view/UserDriverLicenses_view.php @@ -12,7 +12,7 @@ function UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver { return page_with_title(sprintf(__('Edit %s driving license information'), User_Nick_render($user_source)), [ buttons([ - button(user_link($user_source), __('Back to profile'), 'back') + button(user_link($user_source['UID']), __('Back to profile'), 'back') ]), msg(), form([ diff --git a/includes/view/UserWorkLog_view.php b/includes/view/UserWorkLog_view.php index e64f5412..1c2ffb40 100644 --- a/includes/view/UserWorkLog_view.php +++ b/includes/view/UserWorkLog_view.php @@ -15,7 +15,7 @@ function UserWorkLog_delete_view($user_source, $userWorkLog) User_Nick_render($user_source) ), true), buttons([ - button(user_link($user_source), glyph('remove') . __('cancel')), + button(user_link($user_source['UID']), glyph('remove') . __('cancel')), button(user_worklog_delete_link($userWorkLog, [ 'confirmed' => 1 ]), glyph('ok') . __('delete'), 'btn-danger') @@ -60,7 +60,7 @@ function UserWorkLog_edit_view($user_source, $userWorkLog) { return page_with_title(UserWorkLog_edit_title(), [ buttons([ - button(user_link($user_source), __('back')) + button(user_link($user_source['UID']), __('back')) ]), msg(), UserWorkLog_edit_form($user_source, $userWorkLog) @@ -78,7 +78,7 @@ function UserWorkLog_add_view($user_source, $userWorkLog) { return page_with_title(UserWorkLog_add_title(), [ buttons([ - button(user_link($user_source), __('back')) + button(user_link($user_source['UID']), __('back')) ]), msg(), UserWorkLog_edit_form($user_source, $userWorkLog) diff --git a/includes/view/User_view.php b/includes/view/User_view.php index 1b3c0daf..ccd5e5d2 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -153,7 +153,7 @@ function User_delete_view($user) return page_with_title(sprintf(__('Delete %s'), User_Nick_render($user)), [ msg(), buttons([ - button(user_edit_link($user), glyph('chevron-left') . __('back')) + button(user_edit_link($user['UID']), glyph('chevron-left') . __('back')) ]), error( __('Do you really want to delete the user including all his shifts and every other piece of his data?'), @@ -177,7 +177,7 @@ function User_edit_vouchers_view($user) return page_with_title(sprintf(__('%s\'s vouchers'), User_Nick_render($user)), [ msg(), buttons([ - button(user_link($user), glyph('chevron-left') . __('back')) + button(user_link($user['UID']), glyph('chevron-left') . __('back')) ]), info(sprintf( __('Angel should receive at least %d vouchers.'),