summaryrefslogtreecommitdiff
path: root/includes/model/Shifts_model.php
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-10-10 03:10:28 +0200
committermsquare <msquare@notrademark.de>2018-10-31 13:43:23 +0100
commit7c6afc2bfe3263b91ecabf5530da57fe1162ea0b (patch)
treea251a646b6399a65842e3bfaefe44954f5ac1770 /includes/model/Shifts_model.php
parent89e62c95a7ffd71a8e860f59378ecd13d6cbb196 (diff)
Removed `User($id)` function :tada:
Diffstat (limited to 'includes/model/Shifts_model.php')
-rw-r--r--includes/model/Shifts_model.php32
1 files changed, 17 insertions, 15 deletions
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 @@
<?php
use Engelsystem\Database\DB;
+use Engelsystem\Models\User\User;
use Engelsystem\ShiftsFilter;
use Engelsystem\ShiftSignupState;
@@ -301,7 +302,7 @@ function Shift_free_entries($needed_angeltype, $shift_entries)
/**
* Check if shift signup is allowed from the end users point of view (no admin like privileges)
*
- * @param array $user
+ * @param User $user
* @param array $shift The shift
* @param array $angeltype The angeltype to which the user wants to sign up
* @param array|null $user_angeltype
@@ -321,12 +322,12 @@ function Shift_signup_allowed_angel(
) {
$free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
- if (config('signup_requires_arrival') && !$user['Gekommen']) {
+ if (config('signup_requires_arrival') && !$user->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)