summaryrefslogtreecommitdiff
path: root/includes/controller
diff options
context:
space:
mode:
Diffstat (limited to 'includes/controller')
-rw-r--r--includes/controller/shift_entries_controller.php9
-rw-r--r--includes/controller/shifts_controller.php3
-rw-r--r--includes/controller/user_angeltypes_controller.php4
-rw-r--r--includes/controller/user_driver_licenses_controller.php3
-rw-r--r--includes/controller/user_worklog_controller.php12
-rw-r--r--includes/controller/users_controller.php26
6 files changed, 25 insertions, 32 deletions
diff --git a/includes/controller/shift_entries_controller.php b/includes/controller/shift_entries_controller.php
index bbf2e5b0..c5c1e181 100644
--- a/includes/controller/shift_entries_controller.php
+++ b/includes/controller/shift_entries_controller.php
@@ -11,7 +11,7 @@ use Engelsystem\ShiftSignupState;
function shift_entries_controller()
{
$user = auth()->user();
- if ($user) {
+ if (!$user) {
redirect(page_link_to('login'));
}
@@ -75,10 +75,9 @@ function shift_entry_create_controller()
*/
function shift_entry_create_controller_admin($shift, $angeltype)
{
- $user = auth()->user();
+ $signup_user = auth()->user();
$request = request();
- $signup_user = $user;
if ($request->has('user_id')) {
$signup_user = User::find($request->input('user_id'));
}
@@ -113,8 +112,8 @@ function shift_entry_create_controller_admin($shift, $angeltype)
$users = User::all();
$users_select = [];
- foreach ($users as $u) {
- $users_select[$u->id] = $u->name;
+ foreach ($users as $user) {
+ $users_select[$user->id] = $user->name;
}
$angeltypes_select = [];
diff --git a/includes/controller/shifts_controller.php b/includes/controller/shifts_controller.php
index 07e81957..ee6714d4 100644
--- a/includes/controller/shifts_controller.php
+++ b/includes/controller/shifts_controller.php
@@ -332,13 +332,12 @@ function shifts_controller()
function shift_next_controller()
{
global $privileges;
- $user = auth()->user();
if (!in_array('user_shifts', $privileges)) {
redirect(page_link_to('/'));
}
- $upcoming_shifts = ShiftEntries_upcoming_for_user($user->id);
+ $upcoming_shifts = ShiftEntries_upcoming_for_user(auth()->user()->id);
if (!empty($upcoming_shifts)) {
redirect(shift_link($upcoming_shifts[0]));
diff --git a/includes/controller/user_angeltypes_controller.php b/includes/controller/user_angeltypes_controller.php
index 6080d08b..4269313d 100644
--- a/includes/controller/user_angeltypes_controller.php
+++ b/includes/controller/user_angeltypes_controller.php
@@ -9,9 +9,7 @@ use Engelsystem\Models\User\User;
*/
function user_angeltypes_unconfirmed_hint()
{
- $user = auth()->user();
-
- $unconfirmed_user_angeltypes = User_unconfirmed_AngelTypes($user->id);
+ $unconfirmed_user_angeltypes = User_unconfirmed_AngelTypes(auth()->user()->id);
if (count($unconfirmed_user_angeltypes) == 0) {
return null;
}
diff --git a/includes/controller/user_driver_licenses_controller.php b/includes/controller/user_driver_licenses_controller.php
index f836c74d..9c44adb5 100644
--- a/includes/controller/user_driver_licenses_controller.php
+++ b/includes/controller/user_driver_licenses_controller.php
@@ -76,9 +76,8 @@ function user_driver_license_edit_link($user = null)
*/
function user_driver_license_load_user()
{
- $user = auth()->user();
$request = request();
- $user_source = $user;
+ $user_source = auth()->user();
if ($request->has('user_id')) {
$user_source = User::find($request->input('user_id'));
diff --git a/includes/controller/user_worklog_controller.php b/includes/controller/user_worklog_controller.php
index 51b70ba2..333fd76e 100644
--- a/includes/controller/user_worklog_controller.php
+++ b/includes/controller/user_worklog_controller.php
@@ -9,12 +9,10 @@ use Engelsystem\Models\User\User;
*/
function user_worklog_delete_controller()
{
- $user = auth()->user();
-
$request = request();
$userWorkLog = UserWorkLog($request->input('user_worklog_id'));
if (empty($userWorkLog)) {
- redirect(user_link($user->id));
+ redirect(user_link(auth()->user()->id));
}
$user_source = User::find($userWorkLog['user_id']);
@@ -38,12 +36,10 @@ function user_worklog_delete_controller()
*/
function user_worklog_edit_controller()
{
- $user = auth()->user();
-
$request = request();
$userWorkLog = UserWorkLog($request->input('user_worklog_id'));
if (empty($userWorkLog)) {
- redirect(user_link($user->id));
+ redirect(user_link(auth()->user()->id));
}
$user_source = User::find($userWorkLog['user_id']);
@@ -110,12 +106,10 @@ function user_worklog_from_request($userWorkLog)
*/
function user_worklog_add_controller()
{
- $user = auth()->user();
-
$request = request();
$user_source = User::find($request->input('user_id'));
if (!$user_source) {
- redirect(user_link($user->id));
+ redirect(user_link(auth()->user()->id));
}
$userWorkLog = UserWorkLog_new($user_source->id);
diff --git a/includes/controller/users_controller.php b/includes/controller/users_controller.php
index c8d8a4a9..b54bc967 100644
--- a/includes/controller/users_controller.php
+++ b/includes/controller/users_controller.php
@@ -167,7 +167,7 @@ function user_edit_vouchers_controller()
if ($valid) {
$user_source->state->got_voucher = $vouchers;
- $user->state->save();
+ $user_source->state->save();
success(__('Saved the number of vouchers.'));
engelsystem_log(User_Nick_render($user_source) . ': ' . sprintf('Got %s vouchers',
@@ -268,26 +268,30 @@ function users_list_controller()
redirect(page_link_to(''));
}
- $order_by = 'Nick';
+ $order_by = 'name';
if ($request->has('OrderBy') && in_array($request->input('OrderBy'), [
- 'Nick',
- 'Name',
- 'Vorname',
- 'DECT',
+ 'name',
+ 'last_name',
+ 'first_name',
+ 'dect',
'email',
- 'Size',
- 'Gekommen',
- 'Aktiv',
+ 'shirt_size',
+ 'arrived',
+ 'active',
'force_active',
- 'Tshirt',
- 'lastLogIn'
+ 'got_shirt',
+ 'last_login_at',
])) {
$order_by = $request->input('OrderBy');
}
/** @var User[] $users */
$users = User::query()
+ ->leftJoin('users_contact', 'users.id', '=', 'users_contact.user_id')
+ ->leftJoin('users_personal_data', 'users.id', '=', 'users_personal_data.user_id')
+ ->leftJoin('users_state', 'users.id', '=', 'users_state.user_id')
->orderBy($order_by)
+ ->orderBy('name')
->get();
foreach ($users as $user) {
$user->setAttribute('freeloads', count(ShiftEntries_freeloaded_by_user($user->id)));