summaryrefslogtreecommitdiff
path: root/includes/view/User_view.php
diff options
context:
space:
mode:
authorBot <bot@myigel.name>2017-12-25 23:12:52 +0100
committerIgor Scheller <igor.scheller@igorshp.de>2017-12-25 23:51:15 +0100
commit952c7892f3ac7bfadf8419062e44ff1af66ecc57 (patch)
tree69a85e8e4719801a064b8fa2d521fe000f959cd5 /includes/view/User_view.php
parent879918864a9c6da0fe9be1aca6c443ec8df0afc3 (diff)
Formatting & Docstrings
Diffstat (limited to 'includes/view/User_view.php')
-rw-r--r--includes/view/User_view.php110
1 files changed, 75 insertions, 35 deletions
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.');