summaryrefslogtreecommitdiff
path: root/includes/view
diff options
context:
space:
mode:
Diffstat (limited to 'includes/view')
-rw-r--r--includes/view/AngelTypes_view.php85
-rw-r--r--includes/view/EventConfig_view.php11
-rw-r--r--includes/view/PublicDashboard_view.php28
-rw-r--r--includes/view/Rooms_view.php38
-rw-r--r--includes/view/ShiftCalendarLane.php2
-rw-r--r--includes/view/ShiftCalendarRenderer.php16
-rw-r--r--includes/view/ShiftCalendarShiftRenderer.php44
-rw-r--r--includes/view/ShiftEntry_view.php153
-rw-r--r--includes/view/Shifts_view.php19
-rw-r--r--includes/view/UserAngelTypes_view.php18
-rw-r--r--includes/view/UserDriverLicenses_view.php6
-rw-r--r--includes/view/UserHintsRenderer.php4
-rw-r--r--includes/view/User_view.php110
13 files changed, 354 insertions, 180 deletions
diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php
index a5c10a38..6cefbb24 100644
--- a/includes/view/AngelTypes_view.php
+++ b/includes/view/AngelTypes_view.php
@@ -1,7 +1,8 @@
<?php
-use Engelsystem\ShiftsFilterRenderer;
use Engelsystem\ShiftCalendarRenderer;
+use Engelsystem\ShiftsFilterRenderer;
+
/**
* AngelTypes
*/
@@ -14,7 +15,9 @@ use Engelsystem\ShiftCalendarRenderer;
*/
function AngelType_name_render($angeltype)
{
- return '<a href="' . angeltype_link($angeltype['id']) . '">' . ($angeltype['restricted'] ? glyph('lock') : '') . $angeltype['name'] . '</a>';
+ return '<a href="' . angeltype_link($angeltype['id']) . '">'
+ . ($angeltype['restricted'] ? glyph('lock') : '') . $angeltype['name']
+ . '</a>';
}
/**
@@ -92,7 +95,10 @@ function AngelType_edit_view($angeltype, $supporter_mode)
? form_info(_('No Self Sign Up'), $angeltype['no_self_signup'] ? _('Yes') : _('No'))
: form_checkbox('no_self_signup', _('No Self Sign Up'), $angeltype['no_self_signup']),
$supporter_mode
- ? form_info(_('Requires driver license'), $angeltype['requires_driver_license'] ? _('Yes') : _('No'))
+ ? form_info(_('Requires driver license'),
+ $angeltype['requires_driver_license']
+ ? _('Yes')
+ : _('No'))
: form_checkbox(
'requires_driver_license',
_('Requires driver license'),
@@ -133,7 +139,10 @@ function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes,
];
if ($angeltype['requires_driver_license']) {
- $buttons[] = button(user_driver_license_edit_link($user), glyph('road') . _('my driving license'));
+ $buttons[] = button(
+ user_driver_license_edit_link($user),
+ glyph('road') . _('my driving license')
+ );
}
if ($user_angeltype == null) {
@@ -336,45 +345,45 @@ function AngelType_view(
AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user),
msg(),
tabs([
- _('Info') => AngelType_view_info(
+ _('Info') => AngelType_view_info(
$angeltype,
$members,
$admin_user_angeltypes,
$admin_angeltypes,
$supporter
- ),
+ ),
_('Shifts') => AngelType_view_shifts(
$angeltype,
$shiftsFilterRenderer,
$shiftCalendarRenderer
- )
- ], $tab)
+ )
+ ], $tab)
]);
}
/**
- * @param Angeltype $angeltype
- * @param ShiftsFilterRenderer $shiftsFilterRenderer
+ * @param array $angeltype
+ * @param ShiftsFilterRenderer $shiftsFilterRenderer
* @param ShiftCalendarRenderer $shiftCalendarRenderer
* @return string HTML
*/
function AngelType_view_shifts($angeltype, $shiftsFilterRenderer, $shiftCalendarRenderer)
{
- $shifts = $shiftsFilterRenderer->render(page_link_to('angeltypes', [
- 'action' => 'view',
+ $shifts = $shiftsFilterRenderer->render(page_link_to('angeltypes', [
+ 'action' => 'view',
'angeltype_id' => $angeltype['id']
]));
$shifts .= $shiftCalendarRenderer->render();
-
+
return div('first', $shifts);
}
/**
- * @param Angeltype $angeltype
+ * @param array $angeltype
* @param array $members
- * @param bool $admin_user_angeltypes
- * @param bool $admin_angeltypes
- * @param bool $supporter
+ * @param bool $admin_user_angeltypes
+ * @param bool $admin_angeltypes
+ * @param bool $supporter
* @return string HTML
*/
function AngelType_view_info(
@@ -385,29 +394,29 @@ function AngelType_view_info(
$supporter
) {
$info = [];
- if(AngelType_has_contact_info($angeltype)) {
+ if (AngelType_has_contact_info($angeltype)) {
$info[] = AngelTypes_render_contact_info($angeltype);
}
-
+
$info[] = '<h3>' . _('Description') . '</h3>';
$parsedown = new Parsedown();
if ($angeltype['description'] != '') {
$info[] = '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
}
-
+
list($supporters, $members_confirmed, $members_unconfirmed) = AngelType_view_members(
$angeltype,
$members,
$admin_user_angeltypes,
$admin_angeltypes
- );
+ );
$table_headers = AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes);
-
+
if (count($supporters) > 0) {
$info[] = '<h3>' . _('Supporters') . '</h3>';
$info[] = table($table_headers, $supporters);
}
-
+
if (count($members_confirmed) > 0) {
$members_confirmed[] = [
'Nick' => _('Sum'),
@@ -415,7 +424,7 @@ function AngelType_view_info(
'actions' => ''
];
}
-
+
if (count($members_unconfirmed) > 0) {
$members_unconfirmed[] = [
'Nick' => _('Sum'),
@@ -423,7 +432,7 @@ function AngelType_view_info(
'actions' => ''
];
}
-
+
$info[] = '<h3>' . _('Members') . '</h3>';
if ($admin_user_angeltypes) {
$info[] = buttons([
@@ -431,45 +440,45 @@ function AngelType_view_info(
page_link_to(
'user_angeltypes',
['action' => 'add', 'angeltype_id' => $angeltype['id']]
- ),
+ ),
_('Add'),
'add'
- )
+ )
]);
}
$info[] = table($table_headers, $members_confirmed);
-
+
if ($admin_user_angeltypes && $angeltype['restricted'] && count($members_unconfirmed) > 0) {
$info[] = '<h3>' . _('Unconfirmed') . '</h3>';
$info[] = buttons([
button(
page_link_to('user_angeltypes', ['action' => 'confirm_all', 'angeltype_id' => $angeltype['id']]),
glyph('ok') . _('confirm all')
- ),
+ ),
button(
page_link_to('user_angeltypes', ['action' => 'delete_all', 'angeltype_id' => $angeltype['id']]),
glyph('remove') . _('deny all')
- )
+ )
]);
$info[] = table($table_headers, $members_unconfirmed);
}
-
+
return join($info);
}
/**
* Renders the contact info
- *
- * @param Anteltype $angeltype
+ *
+ * @param array $angeltype
* @return string HTML
*/
function AngelTypes_render_contact_info($angeltype)
{
return heading(_('Contact'), 3) . description([
- _('Name') => $angeltype['contact_name'],
- _('DECT') => $angeltype['contact_dect'],
- _('E-Mail') => $angeltype['contact_email']
- ]);
+ _('Name') => $angeltype['contact_name'],
+ _('DECT') => $angeltype['contact_dect'],
+ _('E-Mail') => $angeltype['contact_email']
+ ]);
}
/**
@@ -511,7 +520,7 @@ function AngelTypes_about_view_angeltype($angeltype)
$html = '<h2>' . $angeltype['name'] . '</h2>';
- if(AngelType_has_contact_info($angeltype)) {
+ if (AngelType_has_contact_info($angeltype)) {
$html .= AngelTypes_render_contact_info($angeltype);
}
diff --git a/includes/view/EventConfig_view.php b/includes/view/EventConfig_view.php
index 2b092962..25c4b225 100644
--- a/includes/view/EventConfig_view.php
+++ b/includes/view/EventConfig_view.php
@@ -73,7 +73,11 @@ function EventConfig_info($event_config)
}
// Event name, start+end date are set
- if ($event_config['event_name'] != null && $event_config['event_start_date'] != null && $event_config['event_end_date'] != null) {
+ if (
+ $event_config['event_name'] != null
+ && $event_config['event_start_date'] != null
+ && $event_config['event_end_date'] != null
+ ) {
return sprintf(
_('%s, from %s to %s'),
$event_config['event_name'],
@@ -134,7 +138,10 @@ function EventConfig_edit_view(
form_text('event_name', _('Event Name'), $event_name),
form_info('', _('Event Name is shown on the start page.')),
form_textarea('event_welcome_msg', _('Event Welcome Message'), $event_welcome_msg),
- form_info('', _('Welcome message is shown after successful registration. You can use markdown.'))
+ form_info(
+ '',
+ _('Welcome message is shown after successful registration. You can use markdown.')
+ )
]),
div('col-md-3 col-xs-6', [
form_date('buildup_start_date', _('Buildup date'), $buildup_start_date),
diff --git a/includes/view/PublicDashboard_view.php b/includes/view/PublicDashboard_view.php
index 30f63d63..b4064294 100644
--- a/includes/view/PublicDashboard_view.php
+++ b/includes/view/PublicDashboard_view.php
@@ -2,6 +2,10 @@
/**
* Public dashboard (formerly known as angel news hub)
+ *
+ * @param array $stats
+ * @param array[] $free_shifts
+ * @return string
*/
function public_dashboard_view($stats, $free_shifts)
{
@@ -9,7 +13,7 @@ function public_dashboard_view($stats, $free_shifts)
if (count($free_shifts) > 0) {
$shift_panels = [];
foreach ($free_shifts as $shift) {
- $shift_panels[] = public_dashborad_shift_render($shift);
+ $shift_panels[] = public_dashboard_shift_render($shift);
}
$needed_angels = div('first', [
div('col-md-12', [
@@ -18,6 +22,7 @@ function public_dashboard_view($stats, $free_shifts)
join($shift_panels)
]);
}
+
return page([
div('public-dashboard', [
div('first', [
@@ -48,23 +53,29 @@ function public_dashboard_view($stats, $free_shifts)
/**
* Renders a single shift panel for a dashboard shift with needed angels
+ *
+ * @param array $shift
+ * @return string
*/
-function public_dashborad_shift_render($shift)
+function public_dashboard_shift_render($shift)
{
$panel_body = glyph('time') . $shift['start'] . ' - ' . $shift['end'];
$panel_body .= ' (' . $shift['duration'] . ' h)';
-
+
$panel_body .= '<br>' . glyph('tasks') . $shift['shifttype_name'];
- if (! empty($shift['title'])) {
+ if (!empty($shift['title'])) {
$panel_body .= ' (' . $shift['title'] . ')';
}
-
+
$panel_body .= '<br>' . glyph('map-marker') . $shift['room_name'];
-
+
foreach ($shift['needed_angels'] as $needed_angels) {
- $panel_body .= '<br>' . glyph('user') . '<span class="text-' . $shift['style'] . '">' . $needed_angels['need'] . ' &times; ' . $needed_angels['angeltype_name'] . '</span>';
+ $panel_body .= '<br>' . glyph('user')
+ . '<span class="text-' . $shift['style'] . '">'
+ . $needed_angels['need'] . ' &times; ' . $needed_angels['angeltype_name']
+ . '</span>';
}
-
+
return div('col-md-3', [
div('dashboard-panel panel panel-' . $shift['style'], [
div('panel-body', [
@@ -74,4 +85,3 @@ function public_dashborad_shift_render($shift)
])
]);
}
-?>
diff --git a/includes/view/Rooms_view.php b/includes/view/Rooms_view.php
index 1e8ae4d2..4cd4d8fe 100644
--- a/includes/view/Rooms_view.php
+++ b/includes/view/Rooms_view.php
@@ -1,49 +1,55 @@
<?php
+
use Engelsystem\ShiftCalendarRenderer;
use Engelsystem\ShiftsFilterRenderer;
/**
*
- * @param array $room
- * @param ShiftsFilterRenderer $shiftsFilterRenderer
- * @param ShiftCalendarRenderer $shiftCalendarRenderer
+ * @param array $room
+ * @param ShiftsFilterRenderer $shiftsFilterRenderer
+ * @param ShiftCalendarRenderer $shiftCalendarRenderer
* @return string
*/
function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer)
{
global $user;
-
+
$assignNotice = '';
- if (config('signup_requires_arrival') && ! $user['Gekommen']) {
+ if (config('signup_requires_arrival') && !$user['Gekommen']) {
$assignNotice = info(render_user_arrived_hint(), true);
}
-
+
$description = '';
- if (! empty($room['description'])) {
+ if (!empty($room['description'])) {
$description = '<h3>' . _('Description') . '</h3>';
$parsedown = new Parsedown();
$description .= '<div class="well">' . $parsedown->parse($room['description']) . '</div>';
}
-
+
$tabs = [];
- if (! empty($room['map_url'])) {
- $tabs[_('Map')] = '<div class="map"><iframe style="width: 100%; min-height: 400px; border: 0px none;" src="' . $room['map_url'] . '"></iframe></div>';
+ if (!empty($room['map_url'])) {
+ $tabs[_('Map')] = sprintf(
+ '<div class="map">'
+ . '<iframe style="width: 100%; min-height: 400px; border: 0 none;" src="%s"></iframe>'
+ . '</div>',
+ $room['map_url']
+ );
}
-
+
$tabs[_('Shifts')] = div('first', [
$shiftsFilterRenderer->render(page_link_to('rooms', [
- 'action' => 'view',
+ 'action' => 'view',
'room_id' => $room['RID']
])),
$shiftCalendarRenderer->render()
]);
-
+
$selected_tab = 0;
$request = request();
if ($request->has('shifts_filter_day')) {
$selected_tab = count($tabs) - 1;
}
-
+
return page_with_title(glyph('map-marker') . $room['Name'], [
$assignNotice,
$description,
@@ -53,14 +59,16 @@ function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalen
/**
*
- * @param array $room
+ * @param array $room
* @return string
*/
function Room_name_render($room)
{
global $privileges;
+
if (in_array('view_rooms', $privileges)) {
return '<a href="' . room_link($room) . '">' . glyph('map-marker') . $room['Name'] . '</a>';
}
+
return glyph('map-marker') . $room['Name'];
}
diff --git a/includes/view/ShiftCalendarLane.php b/includes/view/ShiftCalendarLane.php
index fd4c6f06..d28b85e7 100644
--- a/includes/view/ShiftCalendarLane.php
+++ b/includes/view/ShiftCalendarLane.php
@@ -48,6 +48,7 @@ class ShiftCalendarLane
$this->shifts[] = $shift;
return;
}
+
throw new Exception('Unable to add shift to shift calendar lane.');
}
@@ -65,6 +66,7 @@ class ShiftCalendarLane
return false;
}
}
+
return true;
}
diff --git a/includes/view/ShiftCalendarRenderer.php b/includes/view/ShiftCalendarRenderer.php
index 40642947..98f40d49 100644
--- a/includes/view/ShiftCalendarRenderer.php
+++ b/includes/view/ShiftCalendarRenderer.php
@@ -267,7 +267,10 @@ class ShiftCalendarRenderer
$start_time = $shift['start'];
}
}
- return ShiftCalendarRenderer::SECONDS_PER_ROW * floor(($start_time - ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW);
+ return ShiftCalendarRenderer::SECONDS_PER_ROW * floor(
+ ($start_time - ShiftCalendarRenderer::TIME_MARGIN)
+ / ShiftCalendarRenderer::SECONDS_PER_ROW
+ );
}
/**
@@ -282,7 +285,11 @@ class ShiftCalendarRenderer
$end_time = $shift['end'];
}
}
- return ShiftCalendarRenderer::SECONDS_PER_ROW * ceil(($end_time + ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW);
+
+ return ShiftCalendarRenderer::SECONDS_PER_ROW * ceil(
+ ($end_time + ShiftCalendarRenderer::TIME_MARGIN)
+ / ShiftCalendarRenderer::SECONDS_PER_ROW
+ );
}
/**
@@ -290,7 +297,10 @@ class ShiftCalendarRenderer
*/
private function calcBlocksPerSlot()
{
- return ceil(($this->getLastBlockEndTime() - $this->getFirstBlockStartTime()) / ShiftCalendarRenderer::SECONDS_PER_ROW);
+ return ceil(
+ ($this->getLastBlockEndTime() - $this->getFirstBlockStartTime())
+ / ShiftCalendarRenderer::SECONDS_PER_ROW
+ );
}
/**
diff --git a/includes/view/ShiftCalendarShiftRenderer.php b/includes/view/ShiftCalendarShiftRenderer.php
index 2940306d..8bfb18ea 100644
--- a/includes/view/ShiftCalendarShiftRenderer.php
+++ b/includes/view/ShiftCalendarShiftRenderer.php
@@ -33,10 +33,14 @@ class ShiftCalendarShiftRenderer
$blocks = ceil(($shift['end'] - $shift['start']) / ShiftCalendarRenderer::SECONDS_PER_ROW);
$blocks = max(1, $blocks);
+
return [
$blocks,
div(
- 'shift panel panel-' . $class . '" style="height: ' . ($blocks * ShiftCalendarRenderer::BLOCK_HEIGHT - ShiftCalendarRenderer::MARGIN) . 'px"',
+ 'shift panel panel-' . $class . '" '
+ . 'style="height: '
+ . ($blocks * ShiftCalendarRenderer::BLOCK_HEIGHT - ShiftCalendarRenderer::MARGIN)
+ . 'px"',
[
$this->renderShiftHead($shift),
div('panel-body', [
@@ -127,9 +131,9 @@ class ShiftCalendarShiftRenderer
if (in_array('user_shifts_admin', $privileges)) {
$html .= '<li class="list-group-item">';
$html .= button(shift_entry_create_link_admin($shift),
- glyph('plus') . _('Add more angels'),
- 'btn-xs'
- );
+ glyph('plus') . _('Add more angels'),
+ 'btn-xs'
+ );
$html .= '</li>';
}
if ($html != '') {
@@ -138,6 +142,7 @@ class ShiftCalendarShiftRenderer
'<ul class="list-group">' . $html . '</ul>'
];
}
+
return [
$shift_signup_state,
''
@@ -161,7 +166,15 @@ class ShiftCalendarShiftRenderer
$style = $entry['freeloaded'] ? ' text-decoration: line-through;' : '';
$entry_list[] = '<span style="' . $style . '">' . User_Nick_render($entry) . '</span>';
}
- $shift_signup_state = Shift_signup_allowed($user, $shift, $angeltype, null, null, $angeltype, $shift_entries);
+ $shift_signup_state = Shift_signup_allowed(
+ $user,
+ $shift,
+ $angeltype,
+ null,
+ null,
+ $angeltype,
+ $shift_entries
+ );
$inner_text = sprintf(
ngettext('%d helper needed', '%d helpers needed', $shift_signup_state->getFreeEntries()),
$shift_signup_state->getFreeEntries()
@@ -181,12 +194,12 @@ class ShiftCalendarShiftRenderer
_('Sign up'), 'btn-xs btn-primary'
);
break;
-
+
case ShiftSignupState::SHIFT_ENDED:
// No link and add a text hint, when the shift ended
$entry_list[] = $inner_text . ' (' . _('ended') . ')';
break;
-
+
case ShiftSignupState::NOT_ARRIVED:
// No link and add a text hint, when the shift ended
$entry_list[] = $inner_text . ' (' . _('please arrive for signup') . ')';
@@ -200,7 +213,10 @@ class ShiftCalendarShiftRenderer
// Add link to join the angeltype first
$entry_list[] = $inner_text . '<br />'
. button(
- page_link_to('user_angeltypes', ['action' => 'add', 'angeltype_id' => $angeltype['id']]),
+ page_link_to(
+ 'user_angeltypes',
+ ['action' => 'add', 'angeltype_id' => $angeltype['id']]
+ ),
sprintf(_('Become %s'), $angeltype['name']),
'btn-xs'
);
@@ -241,8 +257,16 @@ class ShiftCalendarShiftRenderer
$header_buttons = '';
if (in_array('admin_shifts', $privileges)) {
$header_buttons = '<div class="pull-right">' . table_buttons([
- button(page_link_to('user_shifts', ['edit_shift' => $shift['SID']]), glyph('edit'), 'btn-xs'),
- button(page_link_to('user_shifts', ['delete_shift' => $shift['SID']]), glyph('trash'), 'btn-xs')
+ button(
+ page_link_to('user_shifts', ['edit_shift' => $shift['SID']]),
+ glyph('edit'),
+ 'btn-xs'
+ ),
+ button(
+ page_link_to('user_shifts', ['delete_shift' => $shift['SID']]),
+ glyph('trash'),
+ 'btn-xs'
+ )
]) . '</div>';
}
$shift_heading = date('H:i', $shift['start']) . ' &dash; '
diff --git a/includes/view/ShiftEntry_view.php b/includes/view/ShiftEntry_view.php
index da99e9d8..1b646557 100644
--- a/includes/view/ShiftEntry_view.php
+++ b/includes/view/ShiftEntry_view.php
@@ -13,7 +13,14 @@
function ShiftEntry_delete_view_admin($shiftEntry, $shift, $angeltype, $signoff_user)
{
return page_with_title(ShiftEntry_delete_title(), [
- info(sprintf(_('Do you want to sign off %s from shift %s from %s to %s as %s?'), User_Nick_render($signoff_user), $shift['name'], date('Y-m-d H:i', $shift['start']), date('Y-m-d H:i', $shift['end']), $angeltype['name']), true),
+ info(sprintf(
+ _('Do you want to sign off %s from shift %s from %s to %s as %s?'),
+ User_Nick_render($signoff_user),
+ $shift['name'],
+ date('Y-m-d H:i', $shift['start']),
+ date('Y-m-d H:i', $shift['end']),
+ $angeltype['name']
+ ), true),
buttons([
button(user_link($signoff_user), glyph('remove') . _('cancel')),
button(shift_entry_delete_link($shiftEntry, [
@@ -26,17 +33,23 @@ function ShiftEntry_delete_view_admin($shiftEntry, $shift, $angeltype, $signoff_
/**
* Sign off from a shift, asking for ack.
*
- * @param array $shiftEntry
- * @param array $shift
- * @param array $angeltype
- * @param array $signoff_user
+ * @param array $shiftEntry
+ * @param array $shift
+ * @param array $angeltype
+ * @param array $signoff_user
*
* @return string HTML
*/
function ShiftEntry_delete_view($shiftEntry, $shift, $angeltype, $signoff_user)
{
return page_with_title(ShiftEntry_delete_title(), [
- info(sprintf(_('Do you want to sign off from your shift %s from %s to %s as %s?'), $shift['name'], date('Y-m-d H:i', $shift['start']), date('Y-m-d H:i', $shift['end']), $angeltype['name']), true),
+ info(sprintf(
+ _('Do you want to sign off from your shift %s from %s to %s as %s?'),
+ $shift['name'],
+ date('Y-m-d H:i', $shift['start']),
+ date('Y-m-d H:i', $shift['end']),
+ $angeltype['name']
+ ), true),
buttons([
button(user_link($signoff_user), glyph('remove') . _('cancel')),
button(shift_entry_delete_link($shiftEntry, [
@@ -57,65 +70,76 @@ function ShiftEntry_delete_title()
/**
* Admin puts user into shift.
*
- * @param array $shift
- * @param array $room
- * @param array $angeltype
- * @param array $angeltypes_select
- * @param array $signup_user
- * @param array $users_select
+ * @param array $shift
+ * @param array $room
+ * @param array $angeltype
+ * @param array $angeltypes_select
+ * @param array $signup_user
+ * @param array $users_select
+ * @return string
*/
function ShiftEntry_create_view_admin($shift, $room, $angeltype, $angeltypes_select, $signup_user, $users_select)
{
- return page_with_title(ShiftEntry_create_title() . ': ' . $shift['name'] . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>', [
- Shift_view_header($shift, $room),
- info(_('Do you want to sign up the following user for this shift?'), true),
- form([
- form_select('angeltype_id', _('Angeltype'), $angeltypes_select, $angeltype['id']),
- form_select('user_id', _('User'), $users_select, $signup_user['UID']),
- form_submit('submit', glyph('ok') . _('Save'))
- ])
- ]);
+ return page_with_title(
+ ShiftEntry_create_title() . ': ' . $shift['name']
+ . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>',
+ [
+ Shift_view_header($shift, $room),
+ info(_('Do you want to sign up the following user for this shift?'), true),
+ form([
+ form_select('angeltype_id', _('Angeltype'), $angeltypes_select, $angeltype['id']),
+ form_select('user_id', _('User'), $users_select, $signup_user['UID']),
+ form_submit('submit', glyph('ok') . _('Save'))
+ ])
+ ]);
}
/**
* Supporter puts user into shift.
*
- * @param array $shift
- * @param array $room
- * @param array $angeltype
- * @param array $signup_user
- * @param array $users_select
+ * @param array $shift
+ * @param array $room
+ * @param array $angeltype
+ * @param array $signup_user
+ * @param array $users_select
+ * @return string
*/
function ShiftEntry_create_view_supporter($shift, $room, $angeltype, $signup_user, $users_select)
{
- return page_with_title(ShiftEntry_create_title() . ': ' . $shift['name'] . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>', [
- Shift_view_header($shift, $room),
- 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_submit('submit', glyph('ok') . _('Save'))
- ])
- ]);
+ return page_with_title(ShiftEntry_create_title() . ': ' . $shift['name']
+ . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>',
+ [
+ Shift_view_header($shift, $room),
+ 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_submit('submit', glyph('ok') . _('Save'))
+ ])
+ ]);
}
/**
* User joining a shift.
- *
- * @param array $shift
- * @param array $room
- * @param array $angeltype
+ *
+ * @param array $shift
+ * @param array $room
+ * @param array $angeltype
* @param string $comment
+ * @return string
*/
function ShiftEntry_create_view_user($shift, $room, $angeltype, $comment)
{
- return page_with_title(ShiftEntry_create_title() . ': ' . $shift['name'] . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>', [
- Shift_view_header($shift, $room),
- info(sprintf(_('Do you want to sign up for this shift as %s?'), AngelType_name_render($angeltype)), true),
- form([
- form_textarea('comment', _('Comment (for your eyes only):'), $comment),
- form_submit('submit', glyph('ok') . _('Save'))
- ])
- ]);
+ return page_with_title(ShiftEntry_create_title() . ': ' . $shift['name']
+ . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>',
+ [
+ Shift_view_header($shift, $room),
+ info(sprintf(_('Do you want to sign up for this shift as %s?'), AngelType_name_render($angeltype)), true),
+ form([
+ form_textarea('comment', _('Comment (for your eyes only):'), $comment),
+ form_submit('submit', glyph('ok') . _('Save'))
+ ])
+ ]);
}
/**
@@ -129,24 +153,37 @@ function ShiftEntry_create_title()
/**
* Display form for adding/editing a shift entry.
*
- * @param string $angel
- * @param string $date
- * @param string $location
- * @param string $title
- * @param string $type
- * @param string $comment
- * @param bool $freeloaded
- * @param string $freeload_comment
- * @param bool $user_admin_shifts
+ * @param string $angel
+ * @param string $date
+ * @param string $location
+ * @param string $title
+ * @param string $type
+ * @param string $comment
+ * @param bool $freeloaded
+ * @param string $freeload_comment
+ * @param bool $user_admin_shifts
* @return string
*/
-function ShiftEntry_edit_view($angel, $date, $location, $title, $type, $comment, $freeloaded, $freeload_comment, $user_admin_shifts = false)
-{
+function ShiftEntry_edit_view(
+ $angel,
+ $date,
+ $location,
+ $title,
+ $type,
+ $comment,
+ $freeloaded,
+ $freeload_comment,
+ $user_admin_shifts = false
+) {
$freeload_form = [];
if ($user_admin_shifts) {
$freeload_form = [
form_checkbox('freeloaded', _('Freeloaded'), $freeloaded),
- form_textarea('freeload_comment', _('Freeload comment (Only for shift coordination):'), $freeload_comment)
+ form_textarea(
+ 'freeload_comment',
+ _('Freeload comment (Only for shift coordination):'),
+ $freeload_comment
+ )
];
}
return page_with_title(_('Edit shift entry'), [
diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php
index 0b71b77b..7fc56d1d 100644
--- a/includes/view/Shifts_view.php
+++ b/includes/view/Shifts_view.php
@@ -4,17 +4,21 @@ use Engelsystem\ShiftSignupState;
/**
* Renders the basic shift view header.
- *
+ *
* @param array $shift
* @param array $room
- *
* @return string HTML
*/
-function Shift_view_header($shift, $room) {
+function Shift_view_header($shift, $room)
+{
return div('row', [
div('col-sm-3 col-xs-6', [
'<h4>' . _('Title') . '</h4>',
- '<p class="lead">' . ($shift['URL'] != '' ? '<a href="' . $shift['URL'] . '">' . $shift['title'] . '</a>' : $shift['title']) . '</p>'
+ '<p class="lead">'
+ . ($shift['URL'] != ''
+ ? '<a href="' . $shift['URL'] . '">' . $shift['title'] . '</a>'
+ : $shift['title'])
+ . '</p>'
]),
div('col-sm-3 col-xs-6', [
'<h4>' . _('Start') . '</h4>',
@@ -237,6 +241,11 @@ function Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angelty
function shift_length($shift)
{
$length = floor(($shift['end'] - $shift['start']) / (60 * 60)) . ':';
- $length .= str_pad((($shift['end'] - $shift['start']) % (60 * 60)) / 60, 2, '0', STR_PAD_LEFT) . 'h';
+ $length .= str_pad(
+ (($shift['end'] - $shift['start']) % (60 * 60)) / 60,
+ 2,
+ '0',
+ STR_PAD_LEFT
+ ) . 'h';
return $length;
}
diff --git a/includes/view/UserAngelTypes_view.php b/includes/view/UserAngelTypes_view.php
index c46c1ee1..1f802de4 100644
--- a/includes/view/UserAngelTypes_view.php
+++ b/includes/view/UserAngelTypes_view.php
@@ -97,7 +97,11 @@ function UserAngelType_confirm_view($user_angeltype, $user, $angeltype)
{
return page_with_title(_('Confirm angeltype for user'), [
msg(),
- info(sprintf(_('Do you really want to confirm %s for %s?'), User_Nick_render($user), $angeltype['name']), true),
+ info(sprintf(
+ _('Do you really want to confirm %s for %s?'),
+ User_Nick_render($user),
+ $angeltype['name']
+ ), true),
buttons([
button(angeltype_link($angeltype['id']), glyph('remove') . _('cancel')),
button(
@@ -122,7 +126,11 @@ function UserAngelType_delete_view($user_angeltype, $user, $angeltype)
{
return page_with_title(_('Remove angeltype'), [
msg(),
- info(sprintf(_('Do you really want to delete %s from %s?'), User_Nick_render($user), $angeltype['name']), true),
+ info(sprintf(
+ _('Do you really want to delete %s from %s?'),
+ User_Nick_render($user),
+ $angeltype['name']
+ ), true),
buttons([
button(angeltype_link($angeltype['id']), glyph('remove') . _('cancel')),
button(
@@ -174,7 +182,11 @@ function UserAngelType_join_view($user, $angeltype)
{
return page_with_title(sprintf(_('Become a %s'), $angeltype['name']), [
msg(),
- info(sprintf(_('Do you really want to add %s to %s?'), User_Nick_render($user), $angeltype['name']), true),
+ info(sprintf(
+ _('Do you really want to add %s to %s?'),
+ User_Nick_render($user),
+ $angeltype['name']
+ ), true),
buttons([
button(angeltype_link($angeltype['id']), glyph('remove') . _('cancel')),
button(
diff --git a/includes/view/UserDriverLicenses_view.php b/includes/view/UserDriverLicenses_view.php
index 5eacf456..b92f5f07 100644
--- a/includes/view/UserDriverLicenses_view.php
+++ b/includes/view/UserDriverLicenses_view.php
@@ -42,7 +42,11 @@ function UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver
_('Truck 12,5t'),
$user_driver_license['has_license_12_5t_truck']
),
- form_checkbox('has_license_forklift', _('Forklift'), $user_driver_license['has_license_forklift'])
+ form_checkbox(
+ 'has_license_forklift',
+ _('Forklift'),
+ $user_driver_license['has_license_forklift']
+ )
])
], 'driving_license'),
form_submit('submit', _('Save'))
diff --git a/includes/view/UserHintsRenderer.php b/includes/view/UserHintsRenderer.php
index aac8ecfd..a2bc62f9 100644
--- a/includes/view/UserHintsRenderer.php
+++ b/includes/view/UserHintsRenderer.php
@@ -20,7 +20,9 @@ class UserHintsRenderer
$hint_class = $this->important ? 'danger' : 'info';
$glyphicon = $this->important ? 'warning-sign' : 'info-sign';
- return toolbar_popover($glyphicon . ' text-' . $hint_class, '', $this->hints, 'bg-' . $hint_class);
+ return toolbar_popover(
+ $glyphicon . ' text-' . $hint_class, '', $this->hints, 'bg-' . $hint_class
+ );
}
return '';
diff --git a/includes/view/User_view.php b/includes/view/User_view.php
index 5aec1962..c9530307 100644
--- a/includes/view/User_view.php
+++ b/includes/view/User_view.php
@@ -105,6 +105,7 @@ function User_registration_success_view($event_welcome_message)
{
$parsedown = new Parsedown();
$event_welcome_message = $parsedown->text($event_welcome_message);
+
return page_with_title(_('Registration successful'), [
msg(),
div('row', [
@@ -171,7 +172,10 @@ function User_edit_vouchers_view($user)
buttons([
button(user_link($user), glyph('chevron-left') . _('back'))
]),
- info(sprintf(_('Angel should receive at least %d vouchers.'), User_get_eligable_voucher_count($user)), true),
+ info(sprintf(
+ _('Angel should receive at least %d vouchers.'),
+ User_get_eligable_voucher_count($user)
+ ), true),
form(
[
form_spinner('vouchers', _('Number of vouchers given out'), $user['got_voucher']),
@@ -269,10 +273,10 @@ function Users_table_header_link($column, $label, $order_by)
*/
function User_shift_state_render($user)
{
- if(!$user['Gekommen']) {
+ if (!$user['Gekommen']) {
return '';
}
-
+
$upcoming_shifts = ShiftEntries_upcoming_for_user($user);
if (empty($upcoming_shifts)) {
@@ -283,16 +287,25 @@ function User_shift_state_render($user)
if ($nextShift['start'] > time()) {
if ($nextShift['start'] - time() > 3600) {
- return '<span class="text-success moment-countdown" data-timestamp="' . $nextShift['start'] . '">' . _('Next shift %c') . '</span>';
+ return '<span class="text-success moment-countdown" data-timestamp="' . $nextShift['start'] . '">'
+ . _('Next shift %c')
+ . '</span>';
}
- return '<span class="text-warning moment-countdown" data-timestamp="' . $nextShift['start'] . '">' . _('Next shift %c') . '</span>';
+ return '<span class="text-warning moment-countdown" data-timestamp="' . $nextShift['start'] . '">'
+ . _('Next shift %c')
+ . '</span>';
}
$halfway = ($nextShift['start'] + $nextShift['end']) / 2;
if (time() < $halfway) {
- return '<span class="text-danger moment-countdown" data-timestamp="' . $nextShift['start'] . '">' . _('Shift starts %c') . '</span>';
+ return '<span class="text-danger moment-countdown" data-timestamp="' . $nextShift['start'] . '">'
+ . _('Shift starts %c')
+ . '</span>';
}
- return '<span class="text-danger moment-countdown" data-timestamp="' . $nextShift['end'] . '">' . _('Shift ends %c') . '</span>';
+
+ return '<span class="text-danger moment-countdown" data-timestamp="' . $nextShift['end'] . '">'
+ . _('Shift ends %c')
+ . '</span>';
}
/**
@@ -344,14 +357,15 @@ function User_view_myshift($shift, $user_source, $its_me)
'shift_info' => $shift_info,
'comment' => ''
];
-
- if($its_me) {
+
+ if ($its_me) {
$myshift['comment'] = $shift['Comment'];
}
if ($shift['freeloaded']) {
if (in_array('user_shifts_admin', $privileges)) {
- $myshift['comment'] .= '<br /><p class="error">' . _('Freeloaded') . ': ' . $shift['freeload_comment'] . '</p>';
+ $myshift['comment'] .= '<br />'
+ . '<p class="error">' . _('Freeloaded') . ': ' . $shift['freeload_comment'] . '</p>';
} else {
$myshift['comment'] .= '<br /><p class="error">' . _('Freeloaded') . '</p>';
}
@@ -432,7 +446,9 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
$myshifts_table = User_view_myshifts($shifts, $user_source, $its_me);
return page_with_title(
- '<span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . ' <small>' . $user_name . '</small>',
+ '<span class="icon-icon_angel"></span> '
+ . htmlspecialchars($user_source['Nick'])
+ . ' <small>' . $user_name . '</small>',
[
msg(),
div('row space-top', [
@@ -451,10 +467,16 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
_('arrived')
) : '',
$admin_user_privilege ? button(
- page_link_to('users', ['action' => 'edit_vouchers', 'user_id' => $user_source['UID']]),
+ page_link_to(
+ 'users',
+ ['action' => 'edit_vouchers', 'user_id' => $user_source['UID']]
+ ),
glyph('cutlery') . _('Edit vouchers')
) : '',
- $its_me ? button(page_link_to('user_settings'), glyph('list-alt') . _('Settings')) : '',
+ $its_me ? button(
+ page_link_to('user_settings'),
+ glyph('list-alt') . _('Settings')
+ ) : '',
$its_me ? button(
page_link_to('ical', ['key' => $user_source['api_key']]),
glyph('calendar') . _('iCal Export')
@@ -487,7 +509,10 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
'comment' => _('Comment'),
'actions' => _('Action')
], $myshifts_table) : '',
- $its_me ? info(glyph('info-sign') . _('Your night shifts between 2 and 8 am count twice.'), true) : '',
+ $its_me ? info(
+ glyph('info-sign') . _('Your night shifts between 2 and 8 am count twice.'),
+ true
+ ) : '',
$its_me && count($shifts) == 0
? error(sprintf(
_('Go to the <a href="%s">shifts table</a> to sign yourself up for some shifts.'),
@@ -499,10 +524,16 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
}
/**
- * Render the state section of user view.
+ * Render the state section of user view
+ *
+ * @param bool $admin_user_privilege
+ * @param bool $freeloader
+ * @param array $user_source
+ * @return string
*/
-function User_view_state($admin_user_privilege, $freeloader, $user_source) {
- if($admin_user_privilege) {
+function User_view_state($admin_user_privilege, $freeloader, $user_source)
+{
+ if ($admin_user_privilege) {
$state = User_view_state_admin($freeloader, $user_source);
} else {
$state = User_view_state_user($user_source);
@@ -516,45 +547,54 @@ function User_view_state($admin_user_privilege, $freeloader, $user_source) {
/**
* Render the state section of user view for users.
+ *
+ * @param array $user_source
+ * @return array
*/
-function User_view_state_user($user_source) {
+function User_view_state_user($user_source)
+{
$state = [
User_shift_state_render($user_source)
];
-
- if($user_source['Gekommen']) {
+
+ if ($user_source['Gekommen']) {
$state[] = '<span class="text-success">' . glyph('home') . _('Arrived') . '</span>';
} else {
$state[] = '<span class="text-danger">' . _('Not arrived') . '</span>';
}
-
+
return $state;
}
/**
* Render the state section of user view for admins.
+ *
+ * @param bool $freeloader
+ * @param array $user_source
+ * @return array
*/
-function User_view_state_admin($freeloader, $user_source) {
+function User_view_state_admin($freeloader, $user_source)
+{
$state = [];
-
- if($freeloader) {
+
+ if ($freeloader) {
$state[] = '<span class="text-danger">' . glyph('exclamation-sign') . _('Freeloader') . '</span>';
}
-
+
$state[] = User_shift_state_render($user_source);
-
- if($user_source['Gekommen']) {
+
+ if ($user_source['Gekommen']) {
$state[] = '<span class="text-success">' . glyph('home')
. sprintf(_('Arrived at %s'), date('Y-m-d', $user_source['arrival_date']))
. '</span>';
- if($user_source['force_active']) {
+ if ($user_source['force_active']) {
$state[] = '<span class="text-success">' . _('Active (forced)') . '</span>';
- } elseif($user_source['Aktiv']) {
+ } elseif ($user_source['Aktiv']) {
$state[] = '<span class="text-success">' . _('Active') . '</span>';
}
- if($user_source['Tshirt']) {
+ if ($user_source['Tshirt']) {
$state[] = '<span class="text-success">' . _('T-Shirt') . '</span>';
}
} else {
@@ -562,15 +602,15 @@ function User_view_state_admin($freeloader, $user_source) {
. sprintf(_('Not arrived (Planned: %s)'), date('Y-m-d', $user_source['planned_arrival_date']))
. '</span>';
}
-
- if($user_source['got_voucher'] > 0) {
+
+ if ($user_source['got_voucher'] > 0) {
$state[] = '<span class="text-success">'
. glyph('cutlery')
. sprintf(
ngettext('Got %s voucher', 'Got %s vouchers', $user_source['got_voucher']),
$user_source['got_voucher']
- )
- . '</span>';
+ )
+ . '</span>';
} else {
$state[] = '<span class="text-danger">' . _('Got no vouchers') . '</span>';
}
@@ -731,7 +771,7 @@ function render_user_arrived_hint()
if ($user['Gekommen'] == 0) {
$event_config = EventConfig();
- if(!is_null($event_config)
+ if (!is_null($event_config)
&& !is_null($event_config['buildup_start_date'])
&& time() > $event_config['buildup_start_date']) {
return _('You are not marked as arrived. Please go to heaven\'s desk, get your angel badge and/or tell them that you arrived already.');