summaryrefslogtreecommitdiff
path: root/includes/view
diff options
context:
space:
mode:
Diffstat (limited to 'includes/view')
-rw-r--r--includes/view/AngelTypes_view.php5
-rw-r--r--includes/view/ShiftCalendarRenderer.php4
-rw-r--r--includes/view/ShiftCalendarShiftRenderer.php8
-rw-r--r--includes/view/ShiftEntry_view.php16
-rw-r--r--includes/view/Shifts_view.php11
-rw-r--r--includes/view/UserDriverLicenses_view.php6
-rw-r--r--includes/view/UserWorkLog_view.php10
-rw-r--r--includes/view/User_view.php86
8 files changed, 79 insertions, 67 deletions
diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php
index c64297c2..be79cbb9 100644
--- a/includes/view/AngelTypes_view.php
+++ b/includes/view/AngelTypes_view.php
@@ -1,5 +1,6 @@
<?php
+use Engelsystem\Models\User\User;
use Engelsystem\ShiftCalendarRenderer;
use Engelsystem\ShiftsFilterRenderer;
@@ -129,7 +130,7 @@ function AngelType_edit_view($angeltype, $supporter_mode)
* @param bool $admin_angeltypes
* @param bool $supporter
* @param array|null $user_driver_license
- * @param array|null $user
+ * @param User|null $user
* @return string
*/
function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user)
@@ -322,7 +323,7 @@ function AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes)
* @param bool $admin_angeltypes
* @param bool $supporter
* @param array $user_driver_license
- * @param array $user
+ * @param User $user
* @param ShiftsFilterRenderer $shiftsFilterRenderer
* @param ShiftCalendarRenderer $shiftCalendarRenderer
* @param int $tab The selected tab
diff --git a/includes/view/ShiftCalendarRenderer.php b/includes/view/ShiftCalendarRenderer.php
index fc099d7d..dfc55d54 100644
--- a/includes/view/ShiftCalendarRenderer.php
+++ b/includes/view/ShiftCalendarRenderer.php
@@ -176,8 +176,6 @@ class ShiftCalendarRenderer
*/
private function renderLane(ShiftCalendarLane $lane)
{
- global $user;
-
$shift_renderer = new ShiftCalendarShiftRenderer();
$html = '';
$rendered_until = $this->getFirstBlockStartTime();
@@ -192,7 +190,7 @@ class ShiftCalendarRenderer
$shift,
$this->needed_angeltypes[$shift['SID']],
$this->shift_entries[$shift['SID']],
- $user
+ auth()->user()
);
$html .= $shift_html;
$rendered_until += $shift_height * ShiftCalendarRenderer::SECONDS_PER_ROW;
diff --git a/includes/view/ShiftCalendarShiftRenderer.php b/includes/view/ShiftCalendarShiftRenderer.php
index 80cea241..f1847698 100644
--- a/includes/view/ShiftCalendarShiftRenderer.php
+++ b/includes/view/ShiftCalendarShiftRenderer.php
@@ -2,6 +2,8 @@
namespace Engelsystem;
+use Engelsystem\Models\User\User;
+
/**
* Renders a single shift for the shift calendar
*/
@@ -13,7 +15,7 @@ class ShiftCalendarShiftRenderer
* @param array $shift The shift to render
* @param array $needed_angeltypes
* @param array $shift_entries
- * @param array $user The user who is viewing the shift calendar
+ * @param User $user The user who is viewing the shift calendar
* @return array
*/
public function render($shift, $needed_angeltypes, $shift_entries, $user)
@@ -90,7 +92,7 @@ class ShiftCalendarShiftRenderer
* @param array $shift
* @param array[] $needed_angeltypes
* @param array[] $shift_entries
- * @param array $user
+ * @param User $user
* @return array
*/
private function renderShiftNeededAngeltypes($shift, $needed_angeltypes, $shift_entries, $user)
@@ -156,7 +158,7 @@ class ShiftCalendarShiftRenderer
* @param array[] $shift_entries
* @param array[] $angeltype The angeltype, containing information about needed angeltypes
* and already signed up angels
- * @param array $user The user who is viewing the shift calendar
+ * @param User $user The user who is viewing the shift calendar
* @return array
*/
private function renderShiftNeededAngeltype($shift, $shift_entries, $angeltype, $user)
diff --git a/includes/view/ShiftEntry_view.php b/includes/view/ShiftEntry_view.php
index 1d6ba3a3..51f02cce 100644
--- a/includes/view/ShiftEntry_view.php
+++ b/includes/view/ShiftEntry_view.php
@@ -1,12 +1,14 @@
<?php
+use Engelsystem\Models\User\User;
+
/**
* Sign off from an user from a shift with admin permissions, asking for ack.
*
* @param array $shiftEntry
* @param array $shift
* @param array $angeltype
- * @param array $signoff_user
+ * @param User $signoff_user
*
* @return string HTML
*/
@@ -22,7 +24,7 @@ function ShiftEntry_delete_view_admin($shiftEntry, $shift, $angeltype, $signoff_
$angeltype['name']
), true),
buttons([
- button(user_link($signoff_user['UID']), glyph('remove') . __('cancel')),
+ button(user_link($signoff_user->id), glyph('remove') . __('cancel')),
button(shift_entry_delete_link($shiftEntry, [
'continue' => 1
]), glyph('ok') . __('delete'), 'btn-danger')
@@ -36,11 +38,11 @@ function ShiftEntry_delete_view_admin($shiftEntry, $shift, $angeltype, $signoff_
* @param array $shiftEntry
* @param array $shift
* @param array $angeltype
- * @param array $signoff_user
+ * @param int $signoff_user_id
*
* @return string HTML
*/
-function ShiftEntry_delete_view($shiftEntry, $shift, $angeltype, $signoff_user)
+function ShiftEntry_delete_view($shiftEntry, $shift, $angeltype, $signoff_user_id)
{
return page_with_title(ShiftEntry_delete_title(), [
info(sprintf(
@@ -51,7 +53,7 @@ function ShiftEntry_delete_view($shiftEntry, $shift, $angeltype, $signoff_user)
$angeltype['name']
), true),
buttons([
- button(user_link($signoff_user['UID']), glyph('remove') . __('cancel')),
+ button(user_link($signoff_user_id), glyph('remove') . __('cancel')),
button(shift_entry_delete_link($shiftEntry, [
'continue' => 1
]), glyph('ok') . __('delete'), 'btn-danger')
@@ -100,7 +102,7 @@ function ShiftEntry_create_view_admin($shift, $room, $angeltype, $angeltypes_sel
* @param array $shift
* @param array $room
* @param array $angeltype
- * @param array $signup_user
+ * @param User $signup_user
* @param array $users_select
* @return string
*/
@@ -113,7 +115,7 @@ function ShiftEntry_create_view_supporter($shift, $room, $angeltype, $signup_use
info(sprintf(__('Do you want to sign up the following user for this shift as %s?'),
AngelType_name_render($angeltype)), true),
form([
- form_select('user_id', __('User'), $users_select, $signup_user['UID']),
+ form_select('user_id', __('User'), $users_select, $signup_user->id),
form_submit('submit', glyph('ok') . __('Save'))
])
]);
diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php
index bd13a390..2485ec67 100644
--- a/includes/view/Shifts_view.php
+++ b/includes/view/Shifts_view.php
@@ -1,5 +1,6 @@
<?php
+use Engelsystem\Models\User\User;
use Engelsystem\ShiftSignupState;
/**
@@ -54,14 +55,14 @@ function Shift_editor_info_render($shift)
$info[] = sprintf(
glyph('plus') . __('created at %s by %s'),
date('Y-m-d H:i', $shift['created_at_timestamp']),
- User_Nick_render(User($shift['created_by_user_id']))
+ User_Nick_render(User::find($shift['created_by_user_id']))
);
}
if (!empty($shift['edited_by_user_id'])) {
$info[] = sprintf(
glyph('pencil') . __('edited at %s by %s'),
date('Y-m-d H:i', $shift['edited_at_timestamp']),
- User_Nick_render(User($shift['edited_by_user_id']))
+ User_Nick_render(User::find($shift['edited_by_user_id']))
);
}
return join('<br />', $info);
@@ -176,10 +177,8 @@ function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupSt
*/
function Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shift, $user_shift_admin)
{
- global $user;
-
$angeltype = $angeltypes[$needed_angeltype['TID']];
- $angeltype_supporter = User_is_AngelType_supporter($user, $angeltype);
+ $angeltype_supporter = User_is_AngelType_supporter(auth()->user(), $angeltype);
$needed_angels = '';
@@ -226,7 +225,7 @@ function Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shi
*/
function Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angeltype_supporter)
{
- $entry = User_Nick_render(User($shift_entry['UID']));
+ $entry = User_Nick_render(User::find($shift_entry['UID']));
if ($shift_entry['freeloaded']) {
$entry = '<del>' . $entry . '</del>';
}
diff --git a/includes/view/UserDriverLicenses_view.php b/includes/view/UserDriverLicenses_view.php
index 664a5d58..32977d31 100644
--- a/includes/view/UserDriverLicenses_view.php
+++ b/includes/view/UserDriverLicenses_view.php
@@ -1,9 +1,11 @@
<?php
+use Engelsystem\Models\User\User;
+
/**
* Edit a user's driving license information.
*
- * @param array $user_source The user
+ * @param User $user_source The user
* @param bool $wants_to_drive true, if the user wants to drive
* @param array $user_driver_license The user driver license
* @return string
@@ -12,7 +14,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)), [
buttons([
- button(user_link($user_source['UID']), __('Back to profile'), 'back')
+ button(user_link($user_source->id), __('Back to profile'), 'back')
]),
msg(),
form([
diff --git a/includes/view/UserWorkLog_view.php b/includes/view/UserWorkLog_view.php
index e930e9e5..ee35350b 100644
--- a/includes/view/UserWorkLog_view.php
+++ b/includes/view/UserWorkLog_view.php
@@ -36,7 +36,7 @@ function UserWorkLog_delete_title()
/**
* Render edit table.
*
- * @param array $user_source
+ * @param User $user_source
* @param array $userWorkLog
* @return string
*/
@@ -54,7 +54,7 @@ function UserWorkLog_edit_form($user_source, $userWorkLog)
/**
* Form for edit a user work log entry.
*
- * @param array $user_source
+ * @param User $user_source
* @param array $userWorkLog
* @return string
*/
@@ -62,7 +62,7 @@ function UserWorkLog_edit_view($user_source, $userWorkLog)
{
return page_with_title(UserWorkLog_edit_title(), [
buttons([
- button(user_link($user_source['UID']), __('back'))
+ button(user_link($user_source->id), __('back'))
]),
msg(),
UserWorkLog_edit_form($user_source, $userWorkLog)
@@ -72,7 +72,7 @@ function UserWorkLog_edit_view($user_source, $userWorkLog)
/**
* Form for adding a user work log entry.
*
- * @param array $user_source
+ * @param User $user_source
* @param array $userWorkLog
* @return string
*/
@@ -80,7 +80,7 @@ function UserWorkLog_add_view($user_source, $userWorkLog)
{
return page_with_title(UserWorkLog_add_title(), [
buttons([
- button(user_link($user_source['UID']), __('back'))
+ button(user_link($user_source->id), __('back'))
]),
msg(),
UserWorkLog_edit_form($user_source, $userWorkLog)
diff --git a/includes/view/User_view.php b/includes/view/User_view.php
index 6243d26e..1c1aa30a 100644
--- a/includes/view/User_view.php
+++ b/includes/view/User_view.php
@@ -169,7 +169,7 @@ function User_delete_view($user)
/**
* View for editing the number of given vouchers
*
- * @param array $user
+ * @param User $user
* @return string
*/
function User_edit_vouchers_view($user)
@@ -177,7 +177,7 @@ function User_edit_vouchers_view($user)
return page_with_title(sprintf(__('%s\'s vouchers'), User_Nick_render($user)), [
msg(),
buttons([
- button(user_link($user['UID']), glyph('chevron-left') . __('back'))
+ button(user_link($user->id), glyph('chevron-left') . __('back'))
]),
info(sprintf(
__('Angel should receive at least %d vouchers.'),
@@ -185,10 +185,10 @@ function User_edit_vouchers_view($user)
), true),
form(
[
- form_spinner('vouchers', __('Number of vouchers given out'), $user['got_voucher']),
+ form_spinner('vouchers', __('Number of vouchers given out'), $user->state->got_voucher),
form_submit('submit', __('Save'))
],
- page_link_to('users', ['action' => 'edit_vouchers', 'user_id' => $user['UID']])
+ page_link_to('users', ['action' => 'edit_vouchers', 'user_id' => $user->id])
)
]);
}
@@ -275,7 +275,7 @@ function Users_table_header_link($column, $label, $order_by)
}
/**
- * @param array $user
+ * @param User|array $user
* @return string|false
*/
function User_shift_state_render($user)
@@ -349,7 +349,7 @@ function User_view_shiftentries($needed_angel_type)
* Helper that renders a shift line for user view
*
* @param array $shift
- * @param array $user_source
+ * @param User $user_source
* @param bool $its_me
* @return array
*/
@@ -398,12 +398,12 @@ function User_view_myshift($shift, $user_source, $its_me)
];
if ($its_me || in_array('user_shifts_admin', $privileges)) {
$myshift['actions'][] = button(
- page_link_to('user_myshifts', ['edit' => $shift['id'], 'id' => $user_source['UID']]),
+ page_link_to('user_myshifts', ['edit' => $shift['id'], 'id' => $user_source->id]),
glyph('edit') . __('edit'),
'btn-xs'
);
}
- if (Shift_signout_allowed($shift, ['id' => $shift['TID']], $user_source)) {
+ if (Shift_signout_allowed($shift, ['id' => $shift['TID']], $user_source->id)) {
$myshift['actions'][] = button(
shift_entry_delete_link($shift),
glyph('trash') . __('sign off'),
@@ -419,7 +419,7 @@ function User_view_myshift($shift, $user_source, $its_me)
* Helper that prepares the shift table for user view
*
* @param array[] $shifts
- * @param array $user_source
+ * @param User $user_source
* @param bool $its_me
* @param int $tshirt_score
* @param bool $tshirt_admin
@@ -510,7 +510,7 @@ function User_view_worklog($worklog, $admin_user_worklog_privilege)
'comment' => $worklog['comment'] . '<br>'
. sprintf(
__('Added by %s at %s'),
- User_Nick_render(User($worklog['created_user_id'])),
+ User_Nick_render(User::find($worklog['created_user_id'])),
date('Y-m-d H:i', $worklog['created_timestamp'])
),
'actions' => $actions
@@ -520,7 +520,7 @@ function User_view_worklog($worklog, $admin_user_worklog_privilege)
/**
* Renders view for a single user
*
- * @param array $user_source
+ * @param User $user_source
* @param bool $admin_user_privilege
* @param bool $freeloader
* @param array[] $user_angeltypes
@@ -547,7 +547,9 @@ function User_view(
$user_worklogs
) {
$nightShiftsConfig = config('night_shifts');
- $user_name = htmlspecialchars($user_source['Vorname']) . ' ' . htmlspecialchars($user_source['Name']);
+ $user_name = htmlspecialchars(
+ $user_source->personalData->first_name) . ' ' . htmlspecialchars($user_source->personalData->last_name
+ );
$myshifts_table = '';
if ($its_me || $admin_user_privilege) {
$my_shifts = User_view_myshifts(
@@ -568,14 +570,14 @@ function User_view(
'comment' => __('Comment'),
'actions' => __('Action')
], $my_shifts);
- } elseif ($user_source['force_active']) {
+ } elseif ($user_source->state->force_active) {
$myshifts_table = success(__('You have done enough to get a t-shirt.'), true);
}
}
return page_with_title(
'<span class="icon-icon_angel"></span> '
- . htmlspecialchars($user_source['Nick'])
+ . htmlspecialchars($user_source->name)
. ' <small>' . $user_name . '</small>',
[
msg(),
@@ -583,21 +585,21 @@ function User_view(
div('col-md-12', [
buttons([
$admin_user_privilege ? button(
- page_link_to('admin_user', ['id' => $user_source['UID']]),
+ page_link_to('admin_user', ['id' => $user_source->id]),
glyph('edit') . __('edit')
) : '',
$admin_user_privilege ? button(
user_driver_license_edit_link($user_source),
glyph('road') . __('driving license')
) : '',
- ($admin_user_privilege && !$user_source['Gekommen']) ? button(
- page_link_to('admin_arrive', ['arrived' => $user_source['UID']]),
+ ($admin_user_privilege && !$user_source->state->arrived) ? button(
+ page_link_to('admin_arrive', ['arrived' => $user_source->id]),
__('arrived')
) : '',
$admin_user_privilege ? button(
page_link_to(
'users',
- ['action' => 'edit_vouchers', 'user_id' => $user_source['UID']]
+ ['action' => 'edit_vouchers', 'user_id' => $user_source->id]
),
glyph('cutlery') . __('Edit vouchers')
) : '',
@@ -610,11 +612,11 @@ function User_view(
glyph('list-alt') . __('Settings')
) : '',
$its_me ? button(
- page_link_to('ical', ['key' => $user_source['api_key']]),
+ page_link_to('ical', ['key' => $user_source->api_key]),
glyph('calendar') . __('iCal Export')
) : '',
$its_me ? button(
- page_link_to('shifts_json_export', ['key' => $user_source['api_key']]),
+ page_link_to('shifts_json_export', ['key' => $user_source->api_key]),
glyph('export') . __('JSON Export')
) : '',
$its_me ? button(
@@ -626,7 +628,7 @@ function User_view(
]),
div('row', [
div('col-md-3', [
- heading(glyph('phone') . $user_source['DECT'], 1)
+ heading(glyph('phone') . $user_source->contact->dect, 1)
]),
User_view_state($admin_user_privilege, $freeloader, $user_source),
User_angeltypes_render($user_angeltypes),
@@ -656,9 +658,9 @@ function User_view(
/**
* Render the state section of user view
*
- * @param bool $admin_user_privilege
- * @param bool $freeloader
- * @param array $user_source
+ * @param bool $admin_user_privilege
+ * @param bool $freeloader
+ * @param User $user_source
* @return string
*/
function User_view_state($admin_user_privilege, $freeloader, $user_source)
@@ -678,7 +680,7 @@ function User_view_state($admin_user_privilege, $freeloader, $user_source)
/**
* Render the state section of user view for users.
*
- * @param array $user_source
+ * @param User $user_source
* @return array
*/
function User_view_state_user($user_source)
@@ -687,7 +689,7 @@ function User_view_state_user($user_source)
User_shift_state_render($user_source)
];
- if ($user_source['Gekommen']) {
+ if ($user_source->state->arrived) {
$state[] = '<span class="text-success">' . glyph('home') . __('Arrived') . '</span>';
} else {
$state[] = '<span class="text-danger">' . __('Not arrived') . '</span>';
@@ -700,8 +702,8 @@ function User_view_state_user($user_source)
/**
* Render the state section of user view for admins.
*
- * @param bool $freeloader
- * @param array $user_source
+ * @param bool $freeloader
+ * @param User $user_source
* @return array
*/
function User_view_state_admin($freeloader, $user_source)
@@ -714,29 +716,37 @@ function User_view_state_admin($freeloader, $user_source)
$state[] = User_shift_state_render($user_source);
- if ($user_source['Gekommen']) {
+ if ($user_source->state->arrived) {
$state[] = '<span class="text-success">' . glyph('home')
- . sprintf(__('Arrived at %s'), date('Y-m-d', $user_source['arrival_date']))
+ . sprintf(
+ __('Arrived at %s'),
+ $user_source->personalData->arrival_date ? $user_source->personalData->arrival_date->format('Y-m-d') : ''
+ )
. '</span>';
- if ($user_source['force_active']) {
+ if ($user_source->state->force_active) {
$state[] = '<span class="text-success">' . __('Active (forced)') . '</span>';
- } elseif ($user_source['Aktiv']) {
+ } elseif ($user_source->state->active) {
$state[] = '<span class="text-success">' . __('Active') . '</span>';
}
- if ($user_source['Tshirt']) {
+ if ($user_source->personalData->shirt_size) {
$state[] = '<span class="text-success">' . __('T-Shirt') . '</span>';
}
} else {
+ $arrivalDate = $user_source->personalData->planned_arrival_date;
$state[] = '<span class="text-danger">'
- . sprintf(__('Not arrived (Planned: %s)'), date('Y-m-d', $user_source['planned_arrival_date']))
+ . sprintf(
+ __('Not arrived (Planned: %s)'),
+ $arrivalDate ? $arrivalDate->format('Y-m-d') : ''
+ )
. '</span>';
}
- if ($user_source['got_voucher'] > 0) {
+ if ($user_source->state->got_voucher > 0) {
+ $voucherCount = $user_source->state->got_voucher;
$state[] = '<span class="text-success">'
. glyph('cutlery')
- . _e('Got %s voucher', 'Got %s vouchers', $user_source['got_voucher'], [$user_source['got_voucher']])
+ . _e('Got %s voucher', 'Got %s vouchers', $voucherCount, [$voucherCount])
. '</span>';
} else {
$state[] = '<span class="text-danger">' . __('Got no vouchers') . '</span>';
@@ -884,9 +894,7 @@ function render_user_departure_date_hint()
*/
function render_user_freeloader_hint()
{
- global $user;
-
- if (User_is_freeloader($user)) {
+ if (User_is_freeloader(auth()->user())) {
return sprintf(
__('You freeloaded at least %s shifts. Shift signup is locked. Please go to heavens desk to be unlocked again.'),
config('max_freeloadable_shifts')