@ -105,6 +105,7 @@ function User_registration_success_view($event_welcome_message)
{
{
$parsedown = new Parsedown();
$parsedown = new Parsedown();
$event_welcome_message = $parsedown->text($event_welcome_message);
$event_welcome_message = $parsedown->text($event_welcome_message);
return page_with_title(_('Registration successful'), [
return page_with_title(_('Registration successful'), [
msg(),
msg(),
div('row', [
div('row', [
@ -171,7 +172,10 @@ function User_edit_vouchers_view($user)
buttons([
buttons([
button(user_link($user), glyph('chevron-left') . _('back'))
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(
[
[
form_spinner('vouchers', _('Number of vouchers given out'), $user['got_voucher']),
form_spinner('vouchers', _('Number of vouchers given out'), $user['got_voucher']),
@ -269,7 +273,7 @@ function Users_table_header_link($column, $label, $order_by)
*/
*/
function User_shift_state_render($user)
function User_shift_state_render($user)
{
{
if(!$user['Gekommen']) {
if (!$user['Gekommen']) {
return '';
return '';
}
}
@ -283,16 +287,25 @@ function User_shift_state_render($user)
if ($nextShift['start'] > time()) {
if ($nextShift['start'] > time()) {
if ($nextShift['start'] - time() > 3600) {
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;
$halfway = ($nextShift['start'] + $nextShift['end']) / 2;
if (time() < $halfway) {
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 > ';
}
}
/**
/**
@ -345,13 +358,14 @@ function User_view_myshift($shift, $user_source, $its_me)
'comment' => ''
'comment' => ''
];
];
if($its_me) {
if ($its_me) {
$myshift['comment'] = $shift['Comment'];
$myshift['comment'] = $shift['Comment'];
}
}
if ($shift['freeloaded']) {
if ($shift['freeloaded']) {
if (in_array('user_shifts_admin', $privileges)) {
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 {
} else {
$myshift['comment'] .= '< br / > < p class = "error" > ' . _('Freeloaded') . '< / p > ';
$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);
$myshifts_table = User_view_myshifts($shifts, $user_source, $its_me);
return page_with_title(
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(),
msg(),
div('row space-top', [
div('row space-top', [
@ -451,10 +467,16 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
_('arrived')
_('arrived')
) : '',
) : '',
$admin_user_privilege ? button(
$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')
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(
$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')
glyph('calendar') . _('iCal Export')
@ -487,7 +509,10 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
'comment' => _('Comment'),
'comment' => _('Comment'),
'actions' => _('Action')
'actions' => _('Action')
], $myshifts_table) : '',
], $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
$its_me & & count($shifts) == 0
? error(sprintf(
? error(sprintf(
_('Go to the < a href = "%s" > shifts table< / a > to sign yourself up for some shifts.'),
_('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) {
function User_view_state($admin_user_privilege, $freeloader, $user_source)
if($admin_user_privilege) {
{
if ($admin_user_privilege) {
$state = User_view_state_admin($freeloader, $user_source);
$state = User_view_state_admin($freeloader, $user_source);
} else {
} else {
$state = User_view_state_user($user_source);
$state = User_view_state_user($user_source);
@ -516,13 +547,17 @@ function User_view_state($admin_user_privilege, $freeloader, $user_source) {
/**
/**
* Render the state section of user view for users.
* 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 = [
$state = [
User_shift_state_render($user_source)
User_shift_state_render($user_source)
];
];
if($user_source['Gekommen']) {
if ($user_source['Gekommen']) {
$state[] = '< span class = "text-success" > ' . glyph('home') . _('Arrived') . '< / span > ';
$state[] = '< span class = "text-success" > ' . glyph('home') . _('Arrived') . '< / span > ';
} else {
} else {
$state[] = '< span class = "text-danger" > ' . _('Not arrived') . '< / span > ';
$state[] = '< span class = "text-danger" > ' . _('Not arrived') . '< / span > ';
@ -534,27 +569,32 @@ function User_view_state_user($user_source) {
/**
/**
* Render the state section of user view for admins.
* 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 = [];
$state = [];
if($freeloader) {
if ($freeloader) {
$state[] = '< span class = "text-danger" > ' . glyph('exclamation-sign') . _('Freeloader') . '< / span > ';
$state[] = '< span class = "text-danger" > ' . glyph('exclamation-sign') . _('Freeloader') . '< / span > ';
}
}
$state[] = User_shift_state_render($user_source);
$state[] = User_shift_state_render($user_source);
if($user_source['Gekommen']) {
if ($user_source['Gekommen']) {
$state[] = '< span class = "text-success" > ' . glyph('home')
$state[] = '< span class = "text-success" > ' . glyph('home')
. sprintf(_('Arrived at %s'), date('Y-m-d', $user_source['arrival_date']))
. sprintf(_('Arrived at %s'), date('Y-m-d', $user_source['arrival_date']))
. '< / span > ';
. '< / span > ';
if($user_source['force_active']) {
if ($user_source['force_active']) {
$state[] = '< span class = "text-success" > ' . _('Active (forced)') . '< / span > ';
$state[] = '< span class = "text-success" > ' . _('Active (forced)') . '< / span > ';
} elseif($user_source['Aktiv']) {
} elseif ($user_source['Aktiv']) {
$state[] = '< span class = "text-success" > ' . _('Active') . '< / span > ';
$state[] = '< span class = "text-success" > ' . _('Active') . '< / span > ';
}
}
if($user_source['Tshirt']) {
if ($user_source['Tshirt']) {
$state[] = '< span class = "text-success" > ' . _('T-Shirt') . '< / span > ';
$state[] = '< span class = "text-success" > ' . _('T-Shirt') . '< / span > ';
}
}
} else {
} else {
@ -563,7 +603,7 @@ function User_view_state_admin($freeloader, $user_source) {
. '< / span > ';
. '< / span > ';
}
}
if($user_source['got_voucher'] > 0) {
if ($user_source['got_voucher'] > 0) {
$state[] = '< span class = "text-success" > '
$state[] = '< span class = "text-success" > '
. glyph('cutlery')
. glyph('cutlery')
. sprintf(
. sprintf(
@ -731,7 +771,7 @@ function render_user_arrived_hint()
if ($user['Gekommen'] == 0) {
if ($user['Gekommen'] == 0) {
$event_config = EventConfig();
$event_config = EventConfig();
if(!is_null($event_config)
if (!is_null($event_config)
& & !is_null($event_config['buildup_start_date'])
& & !is_null($event_config['buildup_start_date'])
& & time() > $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.');
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.');