Renamed redirect() to throwRedirect()

This commit is contained in:
Bot 2019-09-08 02:25:49 +02:00 committed by Igor Scheller
parent 72123fcd31
commit be39c63f46
28 changed files with 162 additions and 162 deletions

View File

@ -79,7 +79,7 @@ function angeltypes_about_controller()
function angeltype_delete_controller() function angeltype_delete_controller()
{ {
if (!auth()->can('admin_angel_types')) { if (!auth()->can('admin_angel_types')) {
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
$angeltype = load_angeltype(); $angeltype = load_angeltype();
@ -87,7 +87,7 @@ function angeltype_delete_controller()
if (request()->hasPostData('delete')) { if (request()->hasPostData('delete')) {
AngelType_delete($angeltype); AngelType_delete($angeltype);
success(sprintf(__('Angeltype %s deleted.'), AngelType_name_render($angeltype))); success(sprintf(__('Angeltype %s deleted.'), AngelType_name_render($angeltype)));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
return [ return [
@ -112,13 +112,13 @@ function angeltype_edit_controller()
$angeltype = load_angeltype(); $angeltype = load_angeltype();
if (!User_is_AngelType_supporter(auth()->user(), $angeltype)) { if (!User_is_AngelType_supporter(auth()->user(), $angeltype)) {
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
} else { } else {
// New angeltype // New angeltype
if ($supporter_mode) { if ($supporter_mode) {
// Supporters aren't allowed to create new angeltypes. // Supporters aren't allowed to create new angeltypes.
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
$angeltype = AngelType_new(); $angeltype = AngelType_new();
} }
@ -157,7 +157,7 @@ function angeltype_edit_controller()
} }
success('Angel type saved.'); success('Angel type saved.');
redirect(angeltype_link($angeltype['id'])); throw_redirect(angeltype_link($angeltype['id']));
} }
} }
@ -177,7 +177,7 @@ function angeltype_controller()
$user = auth()->user(); $user = auth()->user();
if (!auth()->can('angeltypes')) { if (!auth()->can('angeltypes')) {
redirect(page_link_to('/')); throw_redirect(page_link_to('/'));
} }
$angeltype = load_angeltype(); $angeltype = load_angeltype();
@ -275,7 +275,7 @@ function angeltypes_list_controller()
$user = auth()->user(); $user = auth()->user();
if (!auth()->can('angeltypes')) { if (!auth()->can('angeltypes')) {
redirect(page_link_to('/')); throw_redirect(page_link_to('/'));
} }
$angeltypes = AngelTypes_with_user($user->id); $angeltypes = AngelTypes_with_user($user->id);
@ -346,13 +346,13 @@ function load_angeltype()
{ {
$request = request(); $request = request();
if (!$request->has('angeltype_id')) { if (!$request->has('angeltype_id')) {
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
$angeltype = AngelType($request->input('angeltype_id')); $angeltype = AngelType($request->input('angeltype_id'));
if (empty($angeltype)) { if (empty($angeltype)) {
error(__('Angeltype doesn\'t exist . ')); error(__('Angeltype doesn\'t exist . '));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
return $angeltype; return $angeltype;

View File

@ -17,7 +17,7 @@ function event_config_title()
function event_config_edit_controller() function event_config_edit_controller()
{ {
if (!auth()->can('admin_event_config')) { if (!auth()->can('admin_event_config')) {
redirect(page_link_to('/')); throw_redirect(page_link_to('/'));
} }
$request = request(); $request = request();
@ -118,7 +118,7 @@ function event_config_edit_controller()
) )
); );
success(__('Settings saved.')); success(__('Settings saved.'));
redirect(page_link_to('admin_event_config')); throw_redirect(page_link_to('admin_event_config'));
} }
} }

View File

@ -15,7 +15,7 @@ use Engelsystem\ShiftsFilterRenderer;
function room_controller() function room_controller()
{ {
if (!auth()->can('view_rooms')) { if (!auth()->can('view_rooms')) {
redirect(page_link_to()); throw_redirect(page_link_to());
} }
$request = request(); $request = request();
@ -74,7 +74,7 @@ function rooms_controller()
return room_controller(); return room_controller();
case 'list': case 'list':
default: default:
redirect(page_link_to('admin_rooms')); throw_redirect(page_link_to('admin_rooms'));
} }
} }
@ -104,12 +104,12 @@ function room_edit_link($room)
function load_room() function load_room()
{ {
if (!test_request_int('room_id')) { if (!test_request_int('room_id')) {
redirect(page_link_to()); throw_redirect(page_link_to());
} }
$room = Room(request()->input('room_id')); $room = Room(request()->input('room_id'));
if (empty($room)) { if (empty($room)) {
redirect(page_link_to()); throw_redirect(page_link_to());
} }
return $room; return $room;

View File

@ -13,12 +13,12 @@ function shift_entries_controller()
{ {
$user = auth()->user(); $user = auth()->user();
if (!$user) { if (!$user) {
redirect(page_link_to('login')); throw_redirect(page_link_to('login'));
} }
$action = strip_request_item('action'); $action = strip_request_item('action');
if (empty($action)) { if (empty($action)) {
redirect(user_link($user->id)); throw_redirect(user_link($user->id));
} }
switch ($action) { switch ($action) {
@ -40,12 +40,12 @@ function shift_entry_create_controller()
$request = request(); $request = request();
if (User_is_freeloader($user)) { if (User_is_freeloader($user)) {
redirect(page_link_to('user_myshifts')); throw_redirect(page_link_to('user_myshifts'));
} }
$shift = Shift($request->input('shift_id')); $shift = Shift($request->input('shift_id'));
if (empty($shift)) { if (empty($shift)) {
redirect(user_link($user->id)); throw_redirect(user_link($user->id));
} }
$angeltype = AngelType($request->input('angeltype_id')); $angeltype = AngelType($request->input('angeltype_id'));
@ -55,7 +55,7 @@ function shift_entry_create_controller()
} }
if (empty($angeltype)) { if (empty($angeltype)) {
redirect(user_link($user->id)); throw_redirect(user_link($user->id));
} }
if (User_is_AngelType_supporter($user, $angeltype)) { if (User_is_AngelType_supporter($user, $angeltype)) {
@ -82,7 +82,7 @@ function shift_entry_create_controller_admin($shift, $angeltype)
$signup_user = User::find($request->input('user_id')); $signup_user = User::find($request->input('user_id'));
} }
if (!$signup_user) { if (!$signup_user) {
redirect(shift_link($shift)); throw_redirect(shift_link($shift));
} }
$angeltypes = AngelTypes(); $angeltypes = AngelTypes();
@ -91,7 +91,7 @@ function shift_entry_create_controller_admin($shift, $angeltype)
} }
if (empty($angeltype)) { if (empty($angeltype)) {
if (count($angeltypes) == 0) { if (count($angeltypes) == 0) {
redirect(shift_link($shift)); throw_redirect(shift_link($shift));
} }
$angeltype = $angeltypes[0]; $angeltype = $angeltypes[0];
} }
@ -107,7 +107,7 @@ function shift_entry_create_controller_admin($shift, $angeltype)
]); ]);
success(sprintf(__('%s has been subscribed to the shift.'), User_Nick_render($signup_user))); success(sprintf(__('%s has been subscribed to the shift.'), User_Nick_render($signup_user)));
redirect(shift_link($shift)); throw_redirect(shift_link($shift));
} }
/** @var User[]|Collection $users */ /** @var User[]|Collection $users */
@ -147,7 +147,7 @@ function shift_entry_create_controller_supporter($shift, $angeltype)
} }
if (!UserAngelType_exists($signup_user->id, $angeltype)) { if (!UserAngelType_exists($signup_user->id, $angeltype)) {
error(__('User is not in angeltype.')); error(__('User is not in angeltype.'));
redirect(shift_link($shift)); throw_redirect(shift_link($shift));
} }
$needed_angeltype = NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype); $needed_angeltype = NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype);
@ -165,7 +165,7 @@ function shift_entry_create_controller_supporter($shift, $angeltype)
if ($shift_signup_state->getState() == ShiftSignupState::OCCUPIED) { if ($shift_signup_state->getState() == ShiftSignupState::OCCUPIED) {
error(__('This shift is already occupied.')); error(__('This shift is already occupied.'));
} }
redirect(shift_link($shift)); throw_redirect(shift_link($shift));
} }
if ($request->hasPostData('submit')) { if ($request->hasPostData('submit')) {
@ -179,7 +179,7 @@ function shift_entry_create_controller_supporter($shift, $angeltype)
]); ]);
success(sprintf(__('%s has been subscribed to the shift.'), User_Nick_render($signup_user))); success(sprintf(__('%s has been subscribed to the shift.'), User_Nick_render($signup_user)));
redirect(shift_link($shift)); throw_redirect(shift_link($shift));
} }
$users = Users_by_angeltype($angeltype); $users = Users_by_angeltype($angeltype);
@ -245,7 +245,7 @@ function shift_entry_create_controller_user($shift, $angeltype)
); );
if (!$shift_signup_state->isSignupAllowed()) { if (!$shift_signup_state->isSignupAllowed()) {
shift_entry_error_message($shift_signup_state); shift_entry_error_message($shift_signup_state);
redirect(shift_link($shift)); throw_redirect(shift_link($shift));
} }
$comment = ''; $comment = '';
@ -265,7 +265,7 @@ function shift_entry_create_controller_user($shift, $angeltype)
} }
success(__('You are subscribed. Thank you!')); success(__('You are subscribed. Thank you!'));
redirect(shift_link($shift)); throw_redirect(shift_link($shift));
} }
$room = Room($shift['RID']); $room = Room($shift['RID']);
@ -319,12 +319,12 @@ function shift_entry_load()
$request = request(); $request = request();
if (!$request->has('shift_entry_id') || !test_request_int('shift_entry_id')) { if (!$request->has('shift_entry_id') || !test_request_int('shift_entry_id')) {
redirect(page_link_to('user_shifts')); throw_redirect(page_link_to('user_shifts'));
} }
$shiftEntry = ShiftEntry($request->input('shift_entry_id')); $shiftEntry = ShiftEntry($request->input('shift_entry_id'));
if (empty($shiftEntry)) { if (empty($shiftEntry)) {
error(__('Shift entry not found.')); error(__('Shift entry not found.'));
redirect(page_link_to('user_shifts')); throw_redirect(page_link_to('user_shifts'));
} }
return $shiftEntry; return $shiftEntry;
@ -346,13 +346,13 @@ function shift_entry_delete_controller()
$signout_user = User::find($shiftEntry['UID']); $signout_user = User::find($shiftEntry['UID']);
if (!Shift_signout_allowed($shift, $angeltype, $signout_user->id)) { if (!Shift_signout_allowed($shift, $angeltype, $signout_user->id)) {
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->id)); throw_redirect(user_link($signout_user->id));
} }
if ($request->hasPostData('delete')) { if ($request->hasPostData('delete')) {
ShiftEntry_delete($shiftEntry); ShiftEntry_delete($shiftEntry);
success(__('Shift entry removed.')); success(__('Shift entry removed.'));
redirect(shift_link($shift)); throw_redirect(shift_link($shift));
} }
if ($user->id == $signout_user->id) { if ($user->id == $signout_user->id) {

View File

@ -49,11 +49,11 @@ function shift_edit_controller()
$request = request(); $request = request();
if (!auth()->can('admin_shifts')) { if (!auth()->can('admin_shifts')) {
redirect(page_link_to('user_shifts')); throw_redirect(page_link_to('user_shifts'));
} }
if (!$request->has('edit_shift') || !test_request_int('edit_shift')) { if (!$request->has('edit_shift') || !test_request_int('edit_shift')) {
redirect(page_link_to('user_shifts')); throw_redirect(page_link_to('user_shifts'));
} }
$shift_id = $request->input('edit_shift'); $shift_id = $request->input('edit_shift');
@ -164,7 +164,7 @@ function shift_edit_controller()
); );
success(__('Shift updated.')); success(__('Shift updated.'));
redirect(shift_link([ throw_redirect(shift_link([
'SID' => $shift_id 'SID' => $shift_id
])); ]));
} }
@ -205,18 +205,18 @@ function shift_delete_controller()
$request = request(); $request = request();
if (!auth()->can('user_shifts_admin')) { if (!auth()->can('user_shifts_admin')) {
redirect(page_link_to('user_shifts')); throw_redirect(page_link_to('user_shifts'));
} }
// 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')); throw_redirect(page_link_to('user_shifts'));
} }
$shift_id = $request->input('delete_shift'); $shift_id = $request->input('delete_shift');
$shift = Shift($shift_id); $shift = Shift($shift_id);
if (empty($shift)) { if (empty($shift)) {
redirect(page_link_to('user_shifts')); throw_redirect(page_link_to('user_shifts'));
} }
// Schicht löschen bestätigt // Schicht löschen bestätigt
@ -230,7 +230,7 @@ function shift_delete_controller()
. ' to ' . date('Y-m-d H:i', $shift['end']) . ' to ' . date('Y-m-d H:i', $shift['end'])
); );
success(__('Shift deleted.')); success(__('Shift deleted.'));
redirect(page_link_to('user_shifts')); throw_redirect(page_link_to('user_shifts'));
} }
return page_with_title(shifts_title(), [ return page_with_title(shifts_title(), [
@ -256,17 +256,17 @@ function shift_controller()
$request = request(); $request = request();
if (!auth()->can('user_shifts')) { if (!auth()->can('user_shifts')) {
redirect(page_link_to('/')); throw_redirect(page_link_to('/'));
} }
if (!$request->has('shift_id')) { if (!$request->has('shift_id')) {
redirect(page_link_to('user_shifts')); throw_redirect(page_link_to('user_shifts'));
} }
$shift = Shift($request->input('shift_id')); $shift = Shift($request->input('shift_id'));
if (empty($shift)) { if (empty($shift)) {
error(__('Shift could not be found.')); error(__('Shift could not be found.'));
redirect(page_link_to('user_shifts')); throw_redirect(page_link_to('user_shifts'));
} }
$shifttype = ShiftType($shift['shifttype_id']); $shifttype = ShiftType($shift['shifttype_id']);
@ -309,7 +309,7 @@ function shifts_controller()
{ {
$request = request(); $request = request();
if (!$request->has('action')) { if (!$request->has('action')) {
redirect(page_link_to('user_shifts')); throw_redirect(page_link_to('user_shifts'));
} }
switch ($request->input('action')) { switch ($request->input('action')) {
@ -319,7 +319,7 @@ function shifts_controller()
case 'next': case 'next':
shift_next_controller(); shift_next_controller();
default: default:
redirect(page_link_to('/')); throw_redirect(page_link_to('/'));
} }
return false; return false;
@ -331,16 +331,16 @@ function shifts_controller()
function shift_next_controller() function shift_next_controller()
{ {
if (!auth()->can('user_shifts')) { if (!auth()->can('user_shifts')) {
redirect(page_link_to('/')); throw_redirect(page_link_to('/'));
} }
$upcoming_shifts = ShiftEntries_upcoming_for_user(auth()->user()->id); $upcoming_shifts = ShiftEntries_upcoming_for_user(auth()->user()->id);
if (!empty($upcoming_shifts)) { if (!empty($upcoming_shifts)) {
redirect(shift_link($upcoming_shifts[0])); throw_redirect(shift_link($upcoming_shifts[0]));
} }
redirect(page_link_to('user_shifts')); throw_redirect(page_link_to('user_shifts'));
} }
/** /**

View File

@ -18,12 +18,12 @@ function shifttype_delete_controller()
{ {
$request = request(); $request = request();
if (!$request->has('shifttype_id')) { if (!$request->has('shifttype_id')) {
redirect(page_link_to('shifttypes')); throw_redirect(page_link_to('shifttypes'));
} }
$shifttype = ShiftType($request->input('shifttype_id')); $shifttype = ShiftType($request->input('shifttype_id'));
if (empty($shifttype)) { if (empty($shifttype)) {
redirect(page_link_to('shifttypes')); throw_redirect(page_link_to('shifttypes'));
} }
if ($request->hasPostData('delete')) { if ($request->hasPostData('delete')) {
@ -31,7 +31,7 @@ function shifttype_delete_controller()
engelsystem_log('Deleted shifttype ' . $shifttype['name']); engelsystem_log('Deleted shifttype ' . $shifttype['name']);
success(sprintf(__('Shifttype %s deleted.'), $shifttype['name'])); success(sprintf(__('Shifttype %s deleted.'), $shifttype['name']));
redirect(page_link_to('shifttypes')); throw_redirect(page_link_to('shifttypes'));
} }
return [ return [
@ -59,7 +59,7 @@ function shifttype_edit_controller()
$shifttype = ShiftType($request->input('shifttype_id')); $shifttype = ShiftType($request->input('shifttype_id'));
if (empty($shifttype)) { if (empty($shifttype)) {
error(__('Shifttype not found.')); error(__('Shifttype not found.'));
redirect(page_link_to('shifttypes')); throw_redirect(page_link_to('shifttypes'));
} }
$shifttype_id = $shifttype['id']; $shifttype_id = $shifttype['id'];
$name = $shifttype['name']; $name = $shifttype['name'];
@ -99,7 +99,7 @@ function shifttype_edit_controller()
engelsystem_log('Created shifttype ' . $name); engelsystem_log('Created shifttype ' . $name);
success(__('Created shifttype.')); success(__('Created shifttype.'));
} }
redirect(page_link_to('shifttypes', ['action' => 'view', 'shifttype_id' => $shifttype_id])); throw_redirect(page_link_to('shifttypes', ['action' => 'view', 'shifttype_id' => $shifttype_id]));
} }
} }
@ -116,11 +116,11 @@ function shifttype_controller()
{ {
$request = request(); $request = request();
if (!$request->has('shifttype_id')) { if (!$request->has('shifttype_id')) {
redirect(page_link_to('shifttypes')); throw_redirect(page_link_to('shifttypes'));
} }
$shifttype = ShiftType($request->input('shifttype_id')); $shifttype = ShiftType($request->input('shifttype_id'));
if (empty($shifttype)) { if (empty($shifttype)) {
redirect(page_link_to('shifttypes')); throw_redirect(page_link_to('shifttypes'));
} }
$angeltype = []; $angeltype = [];

View File

@ -45,18 +45,18 @@ function user_angeltypes_delete_all_controller()
if (!$request->has('angeltype_id')) { if (!$request->has('angeltype_id')) {
error(__('Angeltype doesn\'t exist.')); error(__('Angeltype doesn\'t exist.'));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
$angeltype = AngelType($request->input('angeltype_id')); $angeltype = AngelType($request->input('angeltype_id'));
if (empty($angeltype)) { if (empty($angeltype)) {
error(__('Angeltype doesn\'t exist.')); error(__('Angeltype doesn\'t exist.'));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
if (!User_is_AngelType_supporter(auth()->user(), $angeltype)) { if (!User_is_AngelType_supporter(auth()->user(), $angeltype)) {
error(__('You are not allowed to delete all users for this angeltype.')); error(__('You are not allowed to delete all users for this angeltype.'));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
if ($request->hasPostData('deny_all')) { if ($request->hasPostData('deny_all')) {
@ -64,7 +64,7 @@ function user_angeltypes_delete_all_controller()
engelsystem_log(sprintf('Denied all users for angeltype %s', AngelType_name_render($angeltype, true))); engelsystem_log(sprintf('Denied all users for angeltype %s', AngelType_name_render($angeltype, true)));
success(sprintf(__('Denied all users for angeltype %s.'), AngelType_name_render($angeltype))); success(sprintf(__('Denied all users for angeltype %s.'), AngelType_name_render($angeltype)));
redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']])); throw_redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
} }
return [ return [
@ -85,18 +85,18 @@ function user_angeltypes_confirm_all_controller()
if (!$request->has('angeltype_id')) { if (!$request->has('angeltype_id')) {
error(__('Angeltype doesn\'t exist.')); error(__('Angeltype doesn\'t exist.'));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
$angeltype = AngelType($request->input('angeltype_id')); $angeltype = AngelType($request->input('angeltype_id'));
if (empty($angeltype)) { if (empty($angeltype)) {
error(__('Angeltype doesn\'t exist.')); error(__('Angeltype doesn\'t exist.'));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
if (!auth()->can('admin_user_angeltypes') && !User_is_AngelType_supporter($user, $angeltype)) { if (!auth()->can('admin_user_angeltypes') && !User_is_AngelType_supporter($user, $angeltype)) {
error(__('You are not allowed to confirm all users for this angeltype.')); error(__('You are not allowed to confirm all users for this angeltype.'));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
if ($request->hasPostData('confirm_all')) { if ($request->hasPostData('confirm_all')) {
@ -104,7 +104,7 @@ function user_angeltypes_confirm_all_controller()
engelsystem_log(sprintf('Confirmed all users for angeltype %s', AngelType_name_render($angeltype, true))); engelsystem_log(sprintf('Confirmed all users for angeltype %s', AngelType_name_render($angeltype, true)));
success(sprintf(__('Confirmed all users for angeltype %s.'), AngelType_name_render($angeltype))); success(sprintf(__('Confirmed all users for angeltype %s.'), AngelType_name_render($angeltype)));
redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']])); throw_redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
} }
return [ return [
@ -125,30 +125,30 @@ function user_angeltype_confirm_controller()
if (!$request->has('user_angeltype_id')) { if (!$request->has('user_angeltype_id')) {
error(__('User angeltype doesn\'t exist.')); error(__('User angeltype doesn\'t exist.'));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
$user_angeltype = UserAngelType($request->input('user_angeltype_id')); $user_angeltype = UserAngelType($request->input('user_angeltype_id'));
if (empty($user_angeltype)) { if (empty($user_angeltype)) {
error(__('User angeltype doesn\'t exist.')); error(__('User angeltype doesn\'t exist.'));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
$angeltype = AngelType($user_angeltype['angeltype_id']); $angeltype = AngelType($user_angeltype['angeltype_id']);
if (empty($angeltype)) { if (empty($angeltype)) {
error(__('Angeltype doesn\'t exist.')); error(__('Angeltype doesn\'t exist.'));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
if (!User_is_AngelType_supporter($user, $angeltype)) { if (!User_is_AngelType_supporter($user, $angeltype)) {
error(__('You are not allowed to confirm this users angeltype.')); error(__('You are not allowed to confirm this users angeltype.'));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
$user_source = User::find($user_angeltype['user_id']); $user_source = User::find($user_angeltype['user_id']);
if (!$user_source) { if (!$user_source) {
error(__('User doesn\'t exist.')); error(__('User doesn\'t exist.'));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
if ($request->hasPostData('confirm_user')) { if ($request->hasPostData('confirm_user')) {
@ -164,7 +164,7 @@ function user_angeltype_confirm_controller()
User_Nick_render($user_source), User_Nick_render($user_source),
AngelType_name_render($angeltype) AngelType_name_render($angeltype)
)); ));
redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']])); throw_redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
} }
return [ return [
@ -185,30 +185,30 @@ function user_angeltype_delete_controller()
if (!$request->has('user_angeltype_id')) { if (!$request->has('user_angeltype_id')) {
error(__('User angeltype doesn\'t exist.')); error(__('User angeltype doesn\'t exist.'));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
$user_angeltype = UserAngelType($request->input('user_angeltype_id')); $user_angeltype = UserAngelType($request->input('user_angeltype_id'));
if (empty($user_angeltype)) { if (empty($user_angeltype)) {
error(__('User angeltype doesn\'t exist.')); error(__('User angeltype doesn\'t exist.'));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
$angeltype = AngelType($user_angeltype['angeltype_id']); $angeltype = AngelType($user_angeltype['angeltype_id']);
if (empty($angeltype)) { if (empty($angeltype)) {
error(__('Angeltype doesn\'t exist.')); error(__('Angeltype doesn\'t exist.'));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
$user_source = User::find($user_angeltype['user_id']); $user_source = User::find($user_angeltype['user_id']);
if (!$user_source) { if (!$user_source) {
error(__('User doesn\'t exist.')); error(__('User doesn\'t exist.'));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
if ($user->id != $user_angeltype['user_id'] && !User_is_AngelType_supporter($user, $angeltype)) { if ($user->id != $user_angeltype['user_id'] && !User_is_AngelType_supporter($user, $angeltype)) {
error(__('You are not allowed to delete this users angeltype.')); error(__('You are not allowed to delete this users angeltype.'));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
if ($request->hasPostData('delete')) { if ($request->hasPostData('delete')) {
@ -217,7 +217,7 @@ function user_angeltype_delete_controller()
engelsystem_log(sprintf('User %s removed from %s.', User_Nick_render($user_source, true), $angeltype['name'])); engelsystem_log(sprintf('User %s removed from %s.', User_Nick_render($user_source, true), $angeltype['name']));
success(sprintf(__('User %s removed from %s.'), User_Nick_render($user_source), $angeltype['name'])); success(sprintf(__('User %s removed from %s.'), User_Nick_render($user_source), $angeltype['name']));
redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']])); throw_redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
} }
return [ return [
@ -238,37 +238,37 @@ function user_angeltype_update_controller()
if (!auth()->can('admin_angel_types')) { if (!auth()->can('admin_angel_types')) {
error(__('You are not allowed to set supporter rights.')); error(__('You are not allowed to set supporter rights.'));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
if (!$request->has('user_angeltype_id')) { if (!$request->has('user_angeltype_id')) {
error(__('User angeltype doesn\'t exist.')); error(__('User angeltype doesn\'t exist.'));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
if ($request->has('supporter') && preg_match('/^[01]$/', $request->input('supporter'))) { if ($request->has('supporter') && preg_match('/^[01]$/', $request->input('supporter'))) {
$supporter = $request->input('supporter') == '1'; $supporter = $request->input('supporter') == '1';
} else { } else {
error(__('No supporter update given.')); error(__('No supporter update given.'));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
$user_angeltype = UserAngelType($request->input('user_angeltype_id')); $user_angeltype = UserAngelType($request->input('user_angeltype_id'));
if (empty($user_angeltype)) { if (empty($user_angeltype)) {
error(__('User angeltype doesn\'t exist.')); error(__('User angeltype doesn\'t exist.'));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
$angeltype = AngelType($user_angeltype['angeltype_id']); $angeltype = AngelType($user_angeltype['angeltype_id']);
if (empty($angeltype)) { if (empty($angeltype)) {
error(__('Angeltype doesn\'t exist.')); error(__('Angeltype doesn\'t exist.'));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
$user_source = User::find($user_angeltype['user_id']); $user_source = User::find($user_angeltype['user_id']);
if (!$user_source) { if (!$user_source) {
error(__('User doesn\'t exist.')); error(__('User doesn\'t exist.'));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
if ($request->hasPostData('submit')) { if ($request->hasPostData('submit')) {
@ -288,7 +288,7 @@ function user_angeltype_update_controller()
User_Nick_render($user_source) User_Nick_render($user_source)
)); ));
redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']])); throw_redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
} }
return [ return [
@ -343,7 +343,7 @@ function user_angeltype_add_controller()
AngelType_name_render($angeltype, true) AngelType_name_render($angeltype, true)
)); ));
redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']])); throw_redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
} }
} }
@ -366,7 +366,7 @@ function user_angeltype_join_controller($angeltype)
$user_angeltype = UserAngelType_by_User_and_AngelType($user->id, $angeltype); $user_angeltype = UserAngelType_by_User_and_AngelType($user->id, $angeltype);
if (!empty($user_angeltype)) { if (!empty($user_angeltype)) {
error(sprintf(__('You are already a %s.'), $angeltype['name'])); error(sprintf(__('You are already a %s.'), $angeltype['name']));
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
if (request()->hasPostData('submit')) { if (request()->hasPostData('submit')) {
@ -389,7 +389,7 @@ function user_angeltype_join_controller($angeltype)
)); ));
} }
redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']])); throw_redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
} }
return [ return [
@ -407,7 +407,7 @@ function user_angeltypes_controller()
{ {
$request = request(); $request = request();
if (!$request->has('action')) { if (!$request->has('action')) {
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
switch ($request->input('action')) { switch ($request->input('action')) {
@ -424,6 +424,6 @@ function user_angeltypes_controller()
case 'add': case 'add':
return user_angeltype_add_controller(); return user_angeltype_add_controller();
default: default:
redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
} }

View File

@ -42,7 +42,7 @@ function user_driver_licenses_controller()
$user = auth()->user(); $user = auth()->user();
if (!$user) { if (!$user) {
redirect(page_link_to('')); throw_redirect(page_link_to(''));
} }
$action = strip_request_item('action', 'edit'); $action = strip_request_item('action', 'edit');
@ -82,7 +82,7 @@ function user_driver_license_load_user()
if ($request->has('user_id')) { if ($request->has('user_id')) {
$user_source = User::find($request->input('user_id')); $user_source = User::find($request->input('user_id'));
if (empty($user_source)) { if (empty($user_source)) {
redirect(user_driver_license_edit_link()); throw_redirect(user_driver_license_edit_link());
} }
} }
@ -102,7 +102,7 @@ function user_driver_license_edit_controller()
// only privilege admin_user can edit other users driver license information // only privilege admin_user can edit other users driver license information
if ($user->id != $user_source->id && !auth()->can('admin_user')) { if ($user->id != $user_source->id && !auth()->can('admin_user')) {
redirect(user_driver_license_edit_link()); throw_redirect(user_driver_license_edit_link());
} }
$user_driver_license = UserDriverLicense($user_source->id); $user_driver_license = UserDriverLicense($user_source->id);
@ -131,7 +131,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->id)); throw_redirect(user_link($user_source->id));
} else { } else {
error(__('Please select at least one driving license.')); error(__('Please select at least one driving license.'));
} }
@ -139,7 +139,7 @@ function user_driver_license_edit_controller()
UserDriverLicenses_delete($user_source->id); UserDriverLicenses_delete($user_source->id);
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->id)); throw_redirect(user_link($user_source->id));
} }
} }

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(auth()->user()->id)); throw_redirect(user_link(auth()->user()->id));
} }
$user_source = User::find($userWorkLog['user_id']); $user_source = User::find($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->id)); throw_redirect(user_link($user_source->id));
} }
return [ return [
@ -39,7 +39,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(auth()->user()->id)); throw_redirect(user_link(auth()->user()->id));
} }
$user_source = User::find($userWorkLog['user_id']); $user_source = User::find($userWorkLog['user_id']);
@ -50,7 +50,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->id)); throw_redirect(user_link($user_source->id));
} }
} }
@ -109,7 +109,7 @@ function user_worklog_add_controller()
$request = request(); $request = request();
$user_source = User::find($request->input('user_id')); $user_source = User::find($request->input('user_id'));
if (!$user_source) { if (!$user_source) {
redirect(user_link(auth()->user()->id)); throw_redirect(user_link(auth()->user()->id));
} }
$userWorkLog = UserWorkLog_new($user_source->id); $userWorkLog = UserWorkLog_new($user_source->id);
@ -121,7 +121,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->id)); throw_redirect(user_link($user_source->id));
} }
} }
@ -185,13 +185,13 @@ function user_worklog_controller()
$user = auth()->user(); $user = auth()->user();
if (!auth()->can('admin_user_worklog')) { if (!auth()->can('admin_user_worklog')) {
redirect(user_link($user->id)); throw_redirect(user_link($user->id));
} }
$request = request(); $request = request();
$action = $request->input('action'); $action = $request->input('action');
if (!$request->has('action')) { if (!$request->has('action')) {
redirect(user_link($user->id)); throw_redirect(user_link($user->id));
} }
switch ($action) { switch ($action) {

View File

@ -17,7 +17,7 @@ function users_controller()
$request = request(); $request = request();
if (!$user) { if (!$user) {
redirect(page_link_to('')); throw_redirect(page_link_to(''));
} }
$action = 'list'; $action = 'list';
@ -56,13 +56,13 @@ function user_delete_controller()
} }
if (!auth()->can('admin_user')) { if (!auth()->can('admin_user')) {
redirect(page_link_to('')); throw_redirect(page_link_to(''));
} }
// You cannot delete yourself // You cannot delete yourself
if ($user->id == $user_source->id) { if ($user->id == $user_source->id) {
error(__('You cannot delete yourself.')); error(__('You cannot delete yourself.'));
redirect(user_link($user->id)); throw_redirect(user_link($user->id));
} }
if ($request->hasPostData('submit')) { if ($request->hasPostData('submit')) {
@ -85,7 +85,7 @@ function user_delete_controller()
success(__('User deleted.')); success(__('User deleted.'));
engelsystem_log(sprintf('Deleted %s', User_Nick_render($user_source, true))); engelsystem_log(sprintf('Deleted %s', User_Nick_render($user_source, true)));
redirect(users_link()); throw_redirect(users_link());
} }
} }
@ -145,7 +145,7 @@ function user_edit_vouchers_controller()
} }
if (!auth()->can('admin_user')) { if (!auth()->can('admin_user')) {
redirect(page_link_to('')); throw_redirect(page_link_to(''));
} }
if ($request->hasPostData('submit')) { if ($request->hasPostData('submit')) {
@ -171,7 +171,7 @@ function user_edit_vouchers_controller()
engelsystem_log(User_Nick_render($user_source, true) . ': ' . sprintf('Got %s vouchers', engelsystem_log(User_Nick_render($user_source, true) . ': ' . sprintf('Got %s vouchers',
$user_source->state->got_voucher)); $user_source->state->got_voucher));
redirect(user_link($user_source->id)); throw_redirect(user_link($user_source->id));
} }
} }
@ -194,7 +194,7 @@ function user_controller()
$user_source = User::find($request->input('user_id')); $user_source = User::find($request->input('user_id'));
if (!$user_source) { if (!$user_source) {
error(__('User not found.')); error(__('User not found.'));
redirect(page_link_to('/')); throw_redirect(page_link_to('/'));
} }
} }
@ -261,7 +261,7 @@ function users_list_controller()
$request = request(); $request = request();
if (!auth()->can('admin_user')) { if (!auth()->can('admin_user')) {
redirect(page_link_to('')); throw_redirect(page_link_to(''));
} }
$order_by = 'name'; $order_by = 'name';
@ -319,13 +319,13 @@ function load_user()
{ {
$request = request(); $request = request();
if (!$request->has('user_id')) { if (!$request->has('user_id')) {
redirect(page_link_to()); throw_redirect(page_link_to());
} }
$user = User::find($request->input('user_id')); $user = User::find($request->input('user_id'));
if (!$user) { if (!$user) {
error(__('User doesn\'t exist.')); error(__('User doesn\'t exist.'));
redirect(page_link_to()); throw_redirect(page_link_to());
} }
return $user; return $user;

View File

@ -42,11 +42,11 @@ function admin_active()
__('At least %s angels are forced to be active. The number has to be greater.'), __('At least %s angels are forced to be active. The number has to be greater.'),
$forced_count $forced_count
)); ));
redirect(page_link_to('admin_active')); throw_redirect(page_link_to('admin_active'));
} }
} else { } else {
$msg .= error(__('Please enter a number of angels to be marked as active.')); $msg .= error(__('Please enter a number of angels to be marked as active.'));
redirect(page_link_to('admin_active')); throw_redirect(page_link_to('admin_active'));
} }
if ($request->hasPostData('ack')) { if ($request->hasPostData('ack')) {

View File

@ -39,7 +39,7 @@ function admin_arrive()
engelsystem_log('User set to not arrived: ' . User_Nick_render($user_source, true)); engelsystem_log('User set to not arrived: ' . User_Nick_render($user_source, true));
success(__('Reset done. Angel has not arrived.')); success(__('Reset done. Angel has not arrived.'));
redirect(user_link($user_source->id)); throw_redirect(user_link($user_source->id));
} else { } else {
$msg = error(__('Angel not found.'), true); $msg = error(__('Angel not found.'), true);
} }
@ -57,7 +57,7 @@ function admin_arrive()
engelsystem_log('User set has arrived: ' . User_Nick_render($user_source, true)); engelsystem_log('User set has arrived: ' . User_Nick_render($user_source, true));
success(__('Angel has been marked as arrived.')); success(__('Angel has been marked as arrived.'));
redirect(user_link($user_source->id)); throw_redirect(user_link($user_source->id));
} else { } else {
$msg = error(__('Angel not found.'), true); $msg = error(__('Angel not found.'), true);
} }

View File

@ -148,7 +148,7 @@ function admin_groups()
'Group privileges of group ' . $group['Name'] 'Group privileges of group ' . $group['Name']
. ' edited: ' . join(', ', $privilege_names) . ' edited: ' . join(', ', $privilege_names)
); );
redirect(page_link_to('admin_groups')); throw_redirect(page_link_to('admin_groups'));
} else { } else {
return error('No Group found.', true); return error('No Group found.', true);
} }

View File

@ -98,7 +98,7 @@ function admin_import()
} }
if ($valid) { if ($valid) {
redirect( throw_redirect(
page_link_to('admin_import', [ page_link_to('admin_import', [
'step' => 'check', 'step' => 'check',
'shifttype_id' => $shifttype_id, 'shifttype_id' => $shifttype_id,
@ -134,28 +134,28 @@ function admin_import()
case 'check': case 'check':
if (!file_exists($import_file)) { if (!file_exists($import_file)) {
error(__('Missing import file.')); error(__('Missing import file.'));
redirect(page_link_to('admin_import')); throw_redirect(page_link_to('admin_import'));
} }
if ($request->has('shifttype_id') && isset($shifttypes[$request->input('shifttype_id')])) { if ($request->has('shifttype_id') && isset($shifttypes[$request->input('shifttype_id')])) {
$shifttype_id = $request->input('shifttype_id'); $shifttype_id = $request->input('shifttype_id');
} else { } else {
error(__('Please select a shift type.')); error(__('Please select a shift type.'));
redirect(page_link_to('admin_import')); throw_redirect(page_link_to('admin_import'));
} }
if ($request->has('add_minutes_start') && is_numeric(trim($request->input('add_minutes_start')))) { if ($request->has('add_minutes_start') && is_numeric(trim($request->input('add_minutes_start')))) {
$add_minutes_start = trim($request->input('add_minutes_start')); $add_minutes_start = trim($request->input('add_minutes_start'));
} else { } else {
error(__('Please enter an amount of minutes to add to a talk\'s begin.')); error(__('Please enter an amount of minutes to add to a talk\'s begin.'));
redirect(page_link_to('admin_import')); throw_redirect(page_link_to('admin_import'));
} }
if ($request->has('add_minutes_end') && is_numeric(trim($request->input(('add_minutes_end'))))) { if ($request->has('add_minutes_end') && is_numeric(trim($request->input(('add_minutes_end'))))) {
$add_minutes_end = trim($request->input('add_minutes_end')); $add_minutes_end = trim($request->input('add_minutes_end'));
} else { } else {
error(__('Please enter an amount of minutes to add to a talk\'s end.')); error(__('Please enter an amount of minutes to add to a talk\'s end.'));
redirect(page_link_to('admin_import')); throw_redirect(page_link_to('admin_import'));
} }
list($rooms_new, $rooms_deleted) = prepare_rooms($import_file); list($rooms_new, $rooms_deleted) = prepare_rooms($import_file);
@ -229,32 +229,32 @@ function admin_import()
case 'import': case 'import':
if (!file_exists($import_file)) { if (!file_exists($import_file)) {
error(__('Missing import file.')); error(__('Missing import file.'));
redirect(page_link_to('admin_import')); throw_redirect(page_link_to('admin_import'));
} }
if (!file_exists($import_file)) { if (!file_exists($import_file)) {
redirect(page_link_to('admin_import')); throw_redirect(page_link_to('admin_import'));
} }
if ($request->has('shifttype_id') && isset($shifttypes[$request->input('shifttype_id')])) { if ($request->has('shifttype_id') && isset($shifttypes[$request->input('shifttype_id')])) {
$shifttype_id = $request->input('shifttype_id'); $shifttype_id = $request->input('shifttype_id');
} else { } else {
error(__('Please select a shift type.')); error(__('Please select a shift type.'));
redirect(page_link_to('admin_import')); throw_redirect(page_link_to('admin_import'));
} }
if ($request->has('add_minutes_start') && is_numeric(trim($request->input('add_minutes_start')))) { if ($request->has('add_minutes_start') && is_numeric(trim($request->input('add_minutes_start')))) {
$add_minutes_start = trim($request->input('add_minutes_start')); $add_minutes_start = trim($request->input('add_minutes_start'));
} else { } else {
error(__('Please enter an amount of minutes to add to a talk\'s begin.')); error(__('Please enter an amount of minutes to add to a talk\'s begin.'));
redirect(page_link_to('admin_import')); throw_redirect(page_link_to('admin_import'));
} }
if ($request->has('add_minutes_end') && is_numeric(trim($request->input('add_minutes_end')))) { if ($request->has('add_minutes_end') && is_numeric(trim($request->input('add_minutes_end')))) {
$add_minutes_end = trim($request->input('add_minutes_end')); $add_minutes_end = trim($request->input('add_minutes_end'));
} else { } else {
error(__('Please enter an amount of minutes to add to a talk\'s end.')); error(__('Please enter an amount of minutes to add to a talk\'s end.'));
redirect(page_link_to('admin_import')); throw_redirect(page_link_to('admin_import'));
} }
list($rooms_new, $rooms_deleted) = prepare_rooms($import_file); list($rooms_new, $rooms_deleted) = prepare_rooms($import_file);
@ -297,7 +297,7 @@ function admin_import()
]) . success(__('It\'s done!'), true); ]) . success(__('It\'s done!'), true);
break; break;
default: default:
redirect(page_link_to('admin_import')); throw_redirect(page_link_to('admin_import'));
} }
return page_with_title(admin_import_title(), [ return page_with_title(admin_import_title(), [

View File

@ -10,7 +10,7 @@ function admin_news()
$request = request(); $request = request();
if (!$request->has('action')) { if (!$request->has('action')) {
redirect(page_link_to('news')); throw_redirect(page_link_to('news'));
} }
$html = '<div class="col-md-12"><h1>' . __('Edit news entry') . '</h1>' . msg(); $html = '<div class="col-md-12"><h1>' . __('Edit news entry') . '</h1>' . msg();
@ -70,17 +70,17 @@ function admin_news()
engelsystem_log('News updated: ' . $request->postData('eBetreff')); engelsystem_log('News updated: ' . $request->postData('eBetreff'));
success(__('News entry updated.')); success(__('News entry updated.'));
redirect(page_link_to('news')); throw_redirect(page_link_to('news'));
break; break;
case 'delete': case 'delete':
$news->delete(); $news->delete();
engelsystem_log('News deleted: ' . $news->title); engelsystem_log('News deleted: ' . $news->title);
success(__('News entry deleted.')); success(__('News entry deleted.'));
redirect(page_link_to('news')); throw_redirect(page_link_to('news'));
break; break;
default: default:
redirect(page_link_to('news')); throw_redirect(page_link_to('news'));
} }
return $html . '</div>'; return $html . '</div>';
} }

View File

@ -122,7 +122,7 @@ function admin_questions()
. ' answered: ' . ' answered: '
. $answer . $answer
); );
redirect(page_link_to('admin_questions')); throw_redirect(page_link_to('admin_questions'));
} else { } else {
return error('Enter an answer!', true); return error('Enter an answer!', true);
} }
@ -145,7 +145,7 @@ function admin_questions()
if (!empty($question)) { if (!empty($question)) {
$question->delete(); $question->delete();
engelsystem_log('Question deleted: ' . $question['Question']); engelsystem_log('Question deleted: ' . $question['Question']);
redirect(page_link_to('admin_questions')); throw_redirect(page_link_to('admin_questions'));
} else { } else {
return error('No question found.', true); return error('No question found.', true);
} }

View File

@ -56,7 +56,7 @@ function admin_rooms()
if (test_request_int('id')) { if (test_request_int('id')) {
$room = Room($request->input('id')); $room = Room($request->input('id'));
if (empty($room)) { if (empty($room)) {
redirect(page_link_to('admin_rooms')); throw_redirect(page_link_to('admin_rooms'));
} }
$room_id = $request->input('id'); $room_id = $request->input('id');
@ -140,7 +140,7 @@ function admin_rooms()
. ' to: ' . join(', ', $needed_angeltype_info) . ' to: ' . join(', ', $needed_angeltype_info)
); );
success(__('Room saved.')); success(__('Room saved.'));
redirect(page_link_to('admin_rooms')); throw_redirect(page_link_to('admin_rooms'));
} }
} }
$angeltypes_count_form = []; $angeltypes_count_form = [];
@ -190,7 +190,7 @@ function admin_rooms()
Room_delete($room_id); Room_delete($room_id);
success(sprintf(__('Room %s deleted.'), $name)); success(sprintf(__('Room %s deleted.'), $name));
redirect(page_link_to('admin_rooms')); throw_redirect(page_link_to('admin_rooms'));
} }
return page_with_title(admin_rooms_title(), [ return page_with_title(admin_rooms_title(), [

View File

@ -345,7 +345,7 @@ function admin_shifts()
!is_array($session->get('admin_shifts_shifts')) !is_array($session->get('admin_shifts_shifts'))
|| !is_array($session->get('admin_shifts_types')) || !is_array($session->get('admin_shifts_types'))
) { ) {
redirect(page_link_to('admin_shifts')); throw_redirect(page_link_to('admin_shifts'));
} }
foreach ($session->get('admin_shifts_shifts', []) as $shift) { foreach ($session->get('admin_shifts_shifts', []) as $shift) {
@ -389,7 +389,7 @@ function admin_shifts()
} }
success('Schichten angelegt.'); success('Schichten angelegt.');
redirect(page_link_to('admin_shifts')); throw_redirect(page_link_to('admin_shifts'));
} else { } else {
$session->remove('admin_shifts_shifts'); $session->remove('admin_shifts_shifts');
$session->remove('admin_shifts_types'); $session->remove('admin_shifts_types');

View File

@ -22,7 +22,7 @@ function admin_user()
$html = ''; $html = '';
if (!$request->has('id')) { if (!$request->has('id')) {
redirect(users_link()); throw_redirect(users_link());
} }
$user_id = $request->input('id'); $user_id = $request->input('id');
@ -30,7 +30,7 @@ function admin_user()
$user_source = User::find($user_id); $user_source = User::find($user_id);
if (!$user_source) { if (!$user_source) {
error(__('This user does not exist.')); error(__('This user does not exist.'));
redirect(users_link()); throw_redirect(users_link());
} }
$html .= 'Hallo,<br />' $html .= 'Hallo,<br />'

View File

@ -239,7 +239,7 @@ function guest_register()
// User is already logged in - that means a supporter has registered an angel. Return to register page. // User is already logged in - that means a supporter has registered an angel. Return to register page.
if ($authUser) { if ($authUser) {
redirect(page_link_to('register')); throw_redirect(page_link_to('register'));
} }
// If a welcome message is present, display it on the next page // If a welcome message is present, display it on the next page
@ -247,7 +247,7 @@ function guest_register()
info((new Parsedown())->text($message)); info((new Parsedown())->text($message));
} }
redirect(page_link_to('/')); throw_redirect(page_link_to('/'));
} }
} }

View File

@ -141,7 +141,7 @@ function user_messages()
'UPDATE `Messages` SET `isRead`=\'Y\' WHERE `id`=? LIMIT 1', 'UPDATE `Messages` SET `isRead`=\'Y\' WHERE `id`=? LIMIT 1',
[$message_id] [$message_id]
); );
redirect(page_link_to('user_messages')); throw_redirect(page_link_to('user_messages'));
} else { } else {
return error(__('No Message found.'), true); return error(__('No Message found.'), true);
} }
@ -160,7 +160,7 @@ function user_messages()
); );
if (!empty($message) && $message['SUID'] == $user->id) { if (!empty($message) && $message['SUID'] == $user->id) {
DB::delete('DELETE FROM `Messages` WHERE `id`=? LIMIT 1', [$message_id]); DB::delete('DELETE FROM `Messages` WHERE `id`=? LIMIT 1', [$message_id]);
redirect(page_link_to('user_messages')); throw_redirect(page_link_to('user_messages'));
} else { } else {
return error(__('No Message found.'), true); return error(__('No Message found.'), true);
} }
@ -168,7 +168,7 @@ function user_messages()
case 'send': case 'send':
if (Message_send($request->input('to'), $request->input('text'))) { if (Message_send($request->input('to'), $request->input('text'))) {
redirect(page_link_to('user_messages')); throw_redirect(page_link_to('user_messages'));
} else { } else {
return error(__('Transmitting was terminated with an Error.'), true); return error(__('Transmitting was terminated with an Error.'), true);
} }

View File

@ -37,7 +37,7 @@ function user_myshifts()
if ($request->input('reset') == 'ack') { if ($request->input('reset') == 'ack') {
User_reset_api_key($user); User_reset_api_key($user);
success(__('Key changed.')); success(__('Key changed.'));
redirect(page_link_to('users', ['action' => 'view', 'user_id' => $shifts_user->id])); throw_redirect(page_link_to('users', ['action' => 'view', 'user_id' => $shifts_user->id]));
} }
return page_with_title(__('Reset API key'), [ return page_with_title(__('Reset API key'), [
error( error(
@ -109,7 +109,7 @@ function user_myshifts()
. '. Freeloaded: ' . ($freeloaded ? 'YES Comment: ' . $freeload_comment : 'NO') . '. Freeloaded: ' . ($freeloaded ? 'YES Comment: ' . $freeload_comment : 'NO')
); );
success(__('Shift saved.')); success(__('Shift saved.'));
redirect(page_link_to('users', ['action' => 'view', 'user_id' => $shifts_user->id])); throw_redirect(page_link_to('users', ['action' => 'view', 'user_id' => $shifts_user->id]));
} }
} }
@ -125,10 +125,10 @@ function user_myshifts()
auth()->can('user_shifts_admin') auth()->can('user_shifts_admin')
); );
} else { } else {
redirect(page_link_to('user_myshifts')); throw_redirect(page_link_to('user_myshifts'));
} }
} }
redirect(page_link_to('users', ['action' => 'view', 'user_id' => $shifts_user->id])); throw_redirect(page_link_to('users', ['action' => 'view', 'user_id' => $shifts_user->id]));
return ''; return '';
} }

View File

@ -197,7 +197,7 @@ function user_news()
engelsystem_log('Created news: ' . $news->title . ', is meeting: ' . ($news->is_meeting ? 'yes' : 'no')); engelsystem_log('Created news: ' . $news->title . ', is meeting: ' . ($news->is_meeting ? 'yes' : 'no'));
success(__('Entry saved.')); success(__('Entry saved.'));
redirect(page_link_to('news')); throw_redirect(page_link_to('news'));
} }
if (preg_match('/^\d{1,}$/', $request->input('page', 0))) { if (preg_match('/^\d{1,}$/', $request->input('page', 0))) {

View File

@ -38,7 +38,7 @@ function user_questions()
]); ]);
success(__('You question was saved.')); success(__('You question was saved.'));
redirect(page_link_to('user_questions')); throw_redirect(page_link_to('user_questions'));
} else { } else {
return page_with_title(questions_title(), [ return page_with_title(questions_title(), [
error(__('Please enter a question!'), true) error(__('Please enter a question!'), true)
@ -59,7 +59,7 @@ function user_questions()
$question = Question::find($question_id); $question = Question::find($question_id);
if (!empty($question) && $question->user_id == $user->id) { if (!empty($question) && $question->user_id == $user->id) {
$question->delete(); $question->delete();
redirect(page_link_to('user_questions')); throw_redirect(page_link_to('user_questions'));
} else { } else {
return page_with_title(questions_title(), [ return page_with_title(questions_title(), [
error(__('No question found.'), true) error(__('No question found.'), true)

View File

@ -91,7 +91,7 @@ function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes)
$user_source->settings->save(); $user_source->settings->save();
success(__('Settings saved.')); success(__('Settings saved.'));
redirect(page_link_to('user_settings')); throw_redirect(page_link_to('user_settings'));
} }
return $user_source; return $user_source;
@ -119,7 +119,7 @@ function user_settings_password($user_source)
$auth->setPassword($user_source, $request->postData('new_password')); $auth->setPassword($user_source, $request->postData('new_password'));
success(__('Password saved.')); success(__('Password saved.'));
} }
redirect(page_link_to('user_settings')); throw_redirect(page_link_to('user_settings'));
} }
/** /**
@ -144,7 +144,7 @@ function user_settings_theme($user_source, $themes)
$user_source->settings->save(); $user_source->settings->save();
success(__('Theme changed.')); success(__('Theme changed.'));
redirect(page_link_to('user_settings')); throw_redirect(page_link_to('user_settings'));
} }
return $user_source; return $user_source;
@ -174,7 +174,7 @@ function user_settings_locale($user_source, $locales)
$session->set('locale', $user_source->settings->language); $session->set('locale', $user_source->settings->language);
success('Language changed.'); success('Language changed.');
redirect(page_link_to('user_settings')); throw_redirect(page_link_to('user_settings'));
} }
return $user_source; return $user_source;

View File

@ -25,7 +25,7 @@ function user_shifts()
$request = request(); $request = request();
if (User_is_freeloader(auth()->user())) { if (User_is_freeloader(auth()->user())) {
redirect(page_link_to('user_myshifts')); throw_redirect(page_link_to('user_myshifts'));
} }
if ($request->has('edit_shift')) { if ($request->has('edit_shift')) {
@ -99,7 +99,7 @@ function load_rooms()
); );
if (empty($rooms)) { if (empty($rooms)) {
error(__('The administration has not configured any rooms yet.')); error(__('The administration has not configured any rooms yet.'));
redirect(page_link_to('/')); throw_redirect(page_link_to('/'));
} }
return $rooms; return $rooms;
} }
@ -120,7 +120,7 @@ function load_days()
error(__('The administration has not configured any shifts yet.')); error(__('The administration has not configured any shifts yet.'));
// Do not try to redirect to the current page // Do not try to redirect to the current page
if (config('home_site') != 'user_shifts') { if (config('home_site') != 'user_shifts') {
redirect(page_link_to('/')); throw_redirect(page_link_to('/'));
} }
} }
return $days; return $days;
@ -135,7 +135,7 @@ function load_types()
if (!count(DB::select('SELECT `id`, `name` FROM `AngelTypes`'))) { if (!count(DB::select('SELECT `id`, `name` FROM `AngelTypes`'))) {
error(__('The administration has not configured any angeltypes yet - or you are not subscribed to any angeltype.')); error(__('The administration has not configured any angeltypes yet - or you are not subscribed to any angeltype.'));
redirect(page_link_to('/')); throw_redirect(page_link_to('/'));
} }
$types = DB::select(' $types = DB::select('
SELECT SELECT

View File

@ -1,6 +1,7 @@
<?php <?php
use Carbon\Carbon; use Carbon\Carbon;
use Engelsystem\Http\Exceptions\HttpTemporaryRedirect;
use Engelsystem\ValidationResult; use Engelsystem\ValidationResult;
/** /**
@ -55,10 +56,9 @@ function parse_date($pattern, $value)
* *
* @param string $url * @param string $url
*/ */
function redirect($url) function throw_redirect($url)
{ {
header('Location: ' . $url, true, 302); throw new HttpTemporaryRedirect($url);
raw_output('');
} }
/** /**

View File

@ -219,7 +219,7 @@ class LegacyMiddleware implements MiddlewareInterface
return [$title, $content]; return [$title, $content];
} }
redirect(page_link_to('login')); throw_redirect(page_link_to('login'));
return []; return [];
} }