Changed user_link and some other user functions to use the user id

This commit is contained in:
Igor Scheller 2018-10-09 20:38:13 +02:00 committed by msquare
parent 2dcb7cc2de
commit b069a938c6
11 changed files with 37 additions and 37 deletions

View File

@ -17,7 +17,7 @@ function shift_entries_controller()
$action = strip_request_item('action'); $action = strip_request_item('action');
if (empty($action)) { if (empty($action)) {
redirect(user_link($user)); redirect(user_link($user['UID']));
} }
switch ($action) { switch ($action) {
@ -44,7 +44,7 @@ function shift_entry_create_controller()
$shift = Shift($request->input('shift_id')); $shift = Shift($request->input('shift_id'));
if (empty($shift)) { if (empty($shift)) {
redirect(user_link($user)); redirect(user_link($user['UID']));
} }
$angeltype = AngelType($request->input('angeltype_id')); $angeltype = AngelType($request->input('angeltype_id'));
@ -54,7 +54,7 @@ function shift_entry_create_controller()
} }
if (empty($angeltype)) { if (empty($angeltype)) {
redirect(user_link($user)); redirect(user_link($user['UID']));
} }
if (User_is_AngelType_supporter($user, $angeltype)) { if (User_is_AngelType_supporter($user, $angeltype)) {
@ -345,7 +345,7 @@ function shift_entry_delete_controller()
$signout_user = User($shiftEntry['UID']); $signout_user = User($shiftEntry['UID']);
if (!Shift_signout_allowed($shift, $angeltype, $signout_user)) { 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.')); 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')) { if ($request->has('continue')) {

View File

@ -130,7 +130,7 @@ function user_driver_license_edit_controller()
} }
engelsystem_log('Driver license information updated.'); engelsystem_log('Driver license information updated.');
success(__('Your driver license information has been saved.')); success(__('Your driver license information has been saved.'));
redirect(user_link($user_source)); redirect(user_link($user_source['UID']));
} else { } else {
error(__('Please select at least one driving license.')); error(__('Please select at least one driving license.'));
} }
@ -138,7 +138,7 @@ function user_driver_license_edit_controller()
UserDriverLicenses_delete($user_source['UID']); UserDriverLicenses_delete($user_source['UID']);
engelsystem_log('Driver license information removed.'); engelsystem_log('Driver license information removed.');
success(__('Your driver license information has been removed.')); success(__('Your driver license information has been removed.'));
redirect(user_link($user_source)); redirect(user_link($user_source['UID']));
} }
} }

View File

@ -12,7 +12,7 @@ function user_worklog_delete_controller()
$request = request(); $request = request();
$userWorkLog = UserWorkLog($request->input('user_worklog_id')); $userWorkLog = UserWorkLog($request->input('user_worklog_id'));
if (empty($userWorkLog)) { if (empty($userWorkLog)) {
redirect(user_link($user)); redirect(user_link($user['UID']));
} }
$user_source = User($userWorkLog['user_id']); $user_source = User($userWorkLog['user_id']);
@ -20,7 +20,7 @@ function user_worklog_delete_controller()
UserWorkLog_delete($userWorkLog); UserWorkLog_delete($userWorkLog);
success(__('Work log entry deleted.')); success(__('Work log entry deleted.'));
redirect(user_link($user_source)); redirect(user_link($user_source['UID']));
} }
return [ return [
@ -41,7 +41,7 @@ function user_worklog_edit_controller()
$request = request(); $request = request();
$userWorkLog = UserWorkLog($request->input('user_worklog_id')); $userWorkLog = UserWorkLog($request->input('user_worklog_id'));
if (empty($userWorkLog)) { if (empty($userWorkLog)) {
redirect(user_link($user)); redirect(user_link($user['UID']));
} }
$user_source = User($userWorkLog['user_id']); $user_source = User($userWorkLog['user_id']);
@ -52,7 +52,7 @@ function user_worklog_edit_controller()
UserWorkLog_update($userWorkLog); UserWorkLog_update($userWorkLog);
success(__('Work log entry updated.')); 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(); $request = request();
$user_source = User($request->input('user_id')); $user_source = User($request->input('user_id'));
if (empty($user_source)) { if (empty($user_source)) {
redirect(user_link($user)); redirect(user_link($user['UID']));
} }
$userWorkLog = UserWorkLog_new($user_source); $userWorkLog = UserWorkLog_new($user_source);
@ -125,7 +125,7 @@ function user_worklog_add_controller()
UserWorkLog_create($userWorkLog); UserWorkLog_create($userWorkLog);
success(__('Work log entry created.')); 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; global $user, $privileges;
if (!in_array('admin_user_worklog', $privileges)) { if (!in_array('admin_user_worklog', $privileges)) {
redirect(user_link($user)); redirect(user_link($user['UID']));
} }
$request = request(); $request = request();
$action = $request->input('action'); $action = $request->input('action');
if (!$request->has('action')) { if (!$request->has('action')) {
redirect(user_link($user)); redirect(user_link($user['UID']));
} }
switch ($action) { switch ($action) {

View File

@ -59,7 +59,7 @@ function user_delete_controller()
// You cannot delete yourself // You cannot delete yourself
if ($user['UID'] == $user_source['UID']) { if ($user['UID'] == $user_source['UID']) {
error(__('You cannot delete yourself.')); error(__('You cannot delete yourself.'));
redirect(user_link($user)); redirect(user_link($user['UID']));
} }
if ($request->has('submit')) { if ($request->has('submit')) {
@ -101,30 +101,30 @@ function users_link()
} }
/** /**
* @param array $user * @param int $userId
* @return string * @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 * @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 * @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', engelsystem_log(User_Nick_render($user_source) . ': ' . sprintf('Got %s vouchers',
$user_source['got_voucher'])); $user_source['got_voucher']));
redirect(user_link($user_source)); redirect(user_link($user_source['UID']));
} }
} }

View File

@ -36,7 +36,7 @@ function admin_arrive()
', [$user_id]); ', [$user_id]);
engelsystem_log('User set to not arrived: ' . User_Nick_render($user_source)); engelsystem_log('User set to not arrived: ' . User_Nick_render($user_source));
success(__('Reset done. Angel has not arrived.')); success(__('Reset done. Angel has not arrived.'));
redirect(user_link($user_source)); redirect(user_link($user_source['UID']));
} else { } else {
$msg = error(__('Angel not found.'), true); $msg = error(__('Angel not found.'), true);
} }
@ -52,7 +52,7 @@ function admin_arrive()
', [time(), $user_id]); ', [time(), $user_id]);
engelsystem_log('User set has arrived: ' . User_Nick_render($user_source)); engelsystem_log('User set has arrived: ' . User_Nick_render($user_source));
success(__('Angel has been marked as arrived.')); success(__('Angel has been marked as arrived.'));
redirect(user_link($user_source)); redirect(user_link($user_source['UID']));
} else { } else {
$msg = error(__('Angel not found.'), true); $msg = error(__('Angel not found.'), true);
} }

View File

@ -165,7 +165,7 @@ function admin_user()
} }
$html .= buttons([ $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 .= "<hr />"; $html .= "<hr />";

View File

@ -22,7 +22,7 @@ function ShiftEntry_delete_view_admin($shiftEntry, $shift, $angeltype, $signoff_
$angeltype['name'] $angeltype['name']
), true), ), true),
buttons([ buttons([
button(user_link($signoff_user), glyph('remove') . __('cancel')), button(user_link($signoff_user['UID']), glyph('remove') . __('cancel')),
button(shift_entry_delete_link($shiftEntry, [ button(shift_entry_delete_link($shiftEntry, [
'continue' => 1 'continue' => 1
]), glyph('ok') . __('delete'), 'btn-danger') ]), glyph('ok') . __('delete'), 'btn-danger')
@ -51,7 +51,7 @@ function ShiftEntry_delete_view($shiftEntry, $shift, $angeltype, $signoff_user)
$angeltype['name'] $angeltype['name']
), true), ), true),
buttons([ buttons([
button(user_link($signoff_user), glyph('remove') . __('cancel')), button(user_link($signoff_user['UID']), glyph('remove') . __('cancel')),
button(shift_entry_delete_link($shiftEntry, [ button(shift_entry_delete_link($shiftEntry, [
'continue' => 1 'continue' => 1
]), glyph('ok') . __('delete'), 'btn-danger') ]), glyph('ok') . __('delete'), 'btn-danger')

View File

@ -141,7 +141,7 @@ function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupSt
$admin_rooms ? button(room_link($room), glyph('map-marker') . $room['Name']) : '', $admin_rooms ? button(room_link($room), glyph('map-marker') . $room['Name']) : '',
]; ];
} }
$buttons[] = button(user_link($user), '<span class="icon-icon_angel"></span> ' . __('My shifts')); $buttons[] = button(user_link($user['UID']), '<span class="icon-icon_angel"></span> ' . __('My shifts'));
$content[] = buttons($buttons); $content[] = buttons($buttons);
$content[] = Shift_view_header($shift, $room); $content[] = Shift_view_header($shift, $room);

View File

@ -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)), [ return page_with_title(sprintf(__('Edit %s driving license information'), User_Nick_render($user_source)), [
buttons([ buttons([
button(user_link($user_source), __('Back to profile'), 'back') button(user_link($user_source['UID']), __('Back to profile'), 'back')
]), ]),
msg(), msg(),
form([ form([

View File

@ -15,7 +15,7 @@ function UserWorkLog_delete_view($user_source, $userWorkLog)
User_Nick_render($user_source) User_Nick_render($user_source)
), true), ), true),
buttons([ buttons([
button(user_link($user_source), glyph('remove') . __('cancel')), button(user_link($user_source['UID']), glyph('remove') . __('cancel')),
button(user_worklog_delete_link($userWorkLog, [ button(user_worklog_delete_link($userWorkLog, [
'confirmed' => 1 'confirmed' => 1
]), glyph('ok') . __('delete'), 'btn-danger') ]), glyph('ok') . __('delete'), 'btn-danger')
@ -60,7 +60,7 @@ function UserWorkLog_edit_view($user_source, $userWorkLog)
{ {
return page_with_title(UserWorkLog_edit_title(), [ return page_with_title(UserWorkLog_edit_title(), [
buttons([ buttons([
button(user_link($user_source), __('back')) button(user_link($user_source['UID']), __('back'))
]), ]),
msg(), msg(),
UserWorkLog_edit_form($user_source, $userWorkLog) UserWorkLog_edit_form($user_source, $userWorkLog)
@ -78,7 +78,7 @@ function UserWorkLog_add_view($user_source, $userWorkLog)
{ {
return page_with_title(UserWorkLog_add_title(), [ return page_with_title(UserWorkLog_add_title(), [
buttons([ buttons([
button(user_link($user_source), __('back')) button(user_link($user_source['UID']), __('back'))
]), ]),
msg(), msg(),
UserWorkLog_edit_form($user_source, $userWorkLog) UserWorkLog_edit_form($user_source, $userWorkLog)

View File

@ -153,7 +153,7 @@ function User_delete_view($user)
return page_with_title(sprintf(__('Delete %s'), User_Nick_render($user)), [ return page_with_title(sprintf(__('Delete %s'), User_Nick_render($user)), [
msg(), msg(),
buttons([ buttons([
button(user_edit_link($user), glyph('chevron-left') . __('back')) button(user_edit_link($user['UID']), glyph('chevron-left') . __('back'))
]), ]),
error( error(
__('Do you really want to delete the user including all his shifts and every other piece of his data?'), __('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)), [ return page_with_title(sprintf(__('%s\'s vouchers'), User_Nick_render($user)), [
msg(), msg(),
buttons([ buttons([
button(user_link($user), glyph('chevron-left') . __('back')) button(user_link($user['UID']), glyph('chevron-left') . __('back'))
]), ]),
info(sprintf( info(sprintf(
__('Angel should receive at least %d vouchers.'), __('Angel should receive at least %d vouchers.'),