From 7c6afc2bfe3263b91ecabf5530da57fe1162ea0b Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Wed, 10 Oct 2018 03:10:28 +0200 Subject: Removed `User($id)` function :tada: --- includes/model/Shifts_model.php | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'includes/model/Shifts_model.php') diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index e03ca0bf..9e803efd 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -1,6 +1,7 @@ state->arrived) { return new ShiftSignupState(ShiftSignupState::NOT_ARRIVED, $free_entries); } if (empty($user_shifts)) { - $user_shifts = Shifts_by_user($user['UID']); + $user_shifts = Shifts_by_user($user->id); } $signed_up = false; @@ -352,7 +353,7 @@ function Shift_signup_allowed_angel( } if (empty($user_angeltype)) { - $user_angeltype = UserAngelType_by_User_and_AngelType($user['UID'], $angeltype); + $user_angeltype = UserAngelType_by_User_and_AngelType($user->id, $angeltype); } if ( @@ -415,14 +416,15 @@ function Shift_signup_allowed_admin($needed_angeltype, $shift_entries) /** * Check if an angel can signout from a shift. * - * @param array $shift The shift - * @param array $angeltype The angeltype - * @param array $signout_user The user that was signed up for the shift + * @param array $shift The shift + * @param array $angeltype The angeltype + * @param int $signout_user_id The user that was signed up for the shift * @return bool */ -function Shift_signout_allowed($shift, $angeltype, $signout_user) +function Shift_signout_allowed($shift, $angeltype, $signout_user_id) { - global $user, $privileges; + global $privileges; + $user = auth()->user(); // user shifts admin can sign out any user at any time if (in_array('user_shifts_admin', $privileges)) { @@ -437,7 +439,7 @@ function Shift_signout_allowed($shift, $angeltype, $signout_user) return true; } - if ($signout_user['UID'] == $user['UID'] && $shift['start'] > time() + config('last_unsubscribe') * 3600) { + if ($signout_user_id == $user->id && $shift['start'] > time() + config('last_unsubscribe') * 3600) { return true; } @@ -447,7 +449,7 @@ function Shift_signout_allowed($shift, $angeltype, $signout_user) /** * Check if an angel can sign up for given shift. * - * @param array $signup_user + * @param User $signup_user * @param array $shift The shift * @param array $angeltype The angeltype to which the user wants to sign up * @param array|null $user_angeltype @@ -465,7 +467,7 @@ function Shift_signup_allowed( $needed_angeltype, $shift_entries ) { - global $user, $privileges; + global $privileges; if (in_array('user_shifts_admin', $privileges)) { return Shift_signup_allowed_admin($needed_angeltype, $shift_entries); @@ -473,7 +475,7 @@ function Shift_signup_allowed( if ( in_array('shiftentry_edit_angeltype_supporter', $privileges) - && User_is_AngelType_supporter($user, $angeltype) + && User_is_AngelType_supporter(auth()->user(), $angeltype) ) { return Shift_signup_allowed_angeltype_supporter($needed_angeltype, $shift_entries); } @@ -613,8 +615,8 @@ function Shift_create($shift) /** * Return users shifts. * - * @param int $userId - * @param bool $include_freeload_comments + * @param int $userId + * @param bool $include_freeload_comments * @return array[] */ function Shifts_by_user($userId, $include_freeload_comments = false) -- cgit v1.2.3-54-g00ecf