summaryrefslogtreecommitdiff
path: root/includes/view
diff options
context:
space:
mode:
Diffstat (limited to 'includes/view')
-rw-r--r--includes/view/AngelTypes_view.php692
-rw-r--r--includes/view/EventConfig_view.php250
-rw-r--r--includes/view/Questions_view.php81
-rw-r--r--includes/view/Rooms_view.php47
-rw-r--r--includes/view/ShiftCalendarLane.php125
-rw-r--r--includes/view/ShiftCalendarRenderer.php530
-rw-r--r--includes/view/ShiftCalendarShiftRenderer.php414
-rw-r--r--includes/view/ShiftEntry_view.php59
-rw-r--r--includes/view/ShiftTypes_view.php205
-rw-r--r--includes/view/ShiftsFilterRenderer.php131
-rw-r--r--includes/view/Shifts_view.php356
-rw-r--r--includes/view/UserAngelTypes_view.php263
-rw-r--r--includes/view/UserDriverLicenses_view.php87
-rw-r--r--includes/view/UserHintsRenderer.php105
-rw-r--r--includes/view/User_view.php1029
15 files changed, 2623 insertions, 1751 deletions
diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php
index 592f8d6b..baf0e04a 100644
--- a/includes/view/AngelTypes_view.php
+++ b/includes/view/AngelTypes_view.php
@@ -7,323 +7,501 @@
/**
* Renders the angeltypes name as link.
*
- * @param AngelType $angeltype
+ * @param array $angeltype
+ * @return string
*/
-function AngelType_name_render($angeltype) {
- return '<a href="' . angeltype_link($angeltype['id']) . '">' . ($angeltype['restricted'] ? glyph('lock') : '') . $angeltype['name'] . '</a>';
+function AngelType_name_render($angeltype)
+{
+ return '<a href="' . angeltype_link($angeltype['id']) . '">' . ($angeltype['restricted'] ? glyph('lock') : '') . $angeltype['name'] . '</a>';
}
/**
* Render angeltype membership state
*
- * @param UserAngelType $user_angeltype
- * UserAngelType and AngelType
+ * @param array $user_angeltype UserAngelType and AngelType
* @return string
*/
-function AngelType_render_membership($user_angeltype) {
- if ($user_angeltype['user_angeltype_id'] != null) {
- if ($user_angeltype['restricted']) {
- if ($user_angeltype['confirm_user_id'] == null) {
- return glyph('lock') . _("Unconfirmed");
- } elseif ($user_angeltype['supporter']) {
- return glyph_bool(true) . _("supporter");
- }
- return glyph_bool(true) . _("Member");
- } elseif ($user_angeltype['supporter']) {
- return glyph_bool(true) . _("supporter");
+function AngelType_render_membership($user_angeltype)
+{
+ if ($user_angeltype['user_angeltype_id'] != null) {
+ if ($user_angeltype['restricted']) {
+ if ($user_angeltype['confirm_user_id'] == null) {
+ return glyph('lock') . _('Unconfirmed');
+ } elseif ($user_angeltype['supporter']) {
+ return glyph_bool(true) . _('supporter');
+ }
+ return glyph_bool(true) . _('Member');
+ } elseif ($user_angeltype['supporter']) {
+ return glyph_bool(true) . _('supporter');
+ }
+ return glyph_bool(true) . _('Member');
}
- return glyph_bool(true) . _("Member");
- }
- return glyph_bool(false);
+ return glyph_bool(false);
}
-function AngelType_delete_view($angeltype) {
- return page_with_title(sprintf(_("Delete angeltype %s"), $angeltype['name']), [
- info(sprintf(_("Do you want to delete angeltype %s?"), $angeltype['name']), true),
- buttons([
- button(page_link_to('angeltypes'), _("cancel"), 'cancel'),
- button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'] . '&confirmed', _("delete"), 'ok')
- ])
- ]);
+/**
+ * @param array $angeltype
+ * @return string
+ */
+function AngelType_delete_view($angeltype)
+{
+ return page_with_title(sprintf(_('Delete angeltype %s'), $angeltype['name']), [
+ info(sprintf(_('Do you want to delete angeltype %s?'), $angeltype['name']), true),
+ buttons([
+ button(page_link_to('angeltypes'), _('cancel'), 'cancel'),
+ button(
+ page_link_to(
+ 'angeltypes',
+ ['action' => 'delete', 'angeltype_id' => $angeltype['id'], 'confirmed' => 1]
+ ),
+ _('delete'),
+ 'ok'
+ )
+ ])
+ ]);
}
/**
* Render angeltype edit form.
*
- * @param Angeltype $angeltype
- * The angeltype to edit
- * @param boolean $supporter_mode
- * Is the user a supporter of this angeltype?
+ * @param array $angeltype The angeltype to edit
+ * @param boolean $supporter_mode Is the user a supporter of this angeltype?
+ * @return string
*/
-function AngelType_edit_view($angeltype, $supporter_mode) {
- $contact_info = AngelType_contact_info($angeltype);
- return page_with_title(sprintf(_("Edit %s"), $angeltype['name']), [
- buttons([
- button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
- ]),
- msg(),
- form([
- $supporter_mode ? form_info(_("Name"), $angeltype['name']) : form_text('name', _("Name"), $angeltype['name']),
- $supporter_mode ? form_info(_("Restricted"), $angeltype['restricted'] ? _("Yes") : _("No")) : form_checkbox('restricted', _("Restricted"), $angeltype['restricted']),
- $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_checkbox('requires_driver_license', _("Requires driver license"), $angeltype['requires_driver_license']),
- //form_text('contact_name', _("Name"), $angeltype['contact_name']),
- //form_text('contact_dect', _("DECT"), $angeltype['contact_dect']),
- //form_text('contact_email', _("E-Mail"), $angeltype['contact_email']),
- form_info("", _("Restricted angel types can only be used by an angel if enabled by a supporter (double opt-in).")),
- form_textarea('description', _("Description"), $angeltype['description']),
- form_info("", _("Please use markdown for the description.")),
- form_submit('submit', _("Save"))
- ])
- ]);
+function AngelType_edit_view($angeltype, $supporter_mode)
+{
+ return page_with_title(sprintf(_('Edit %s'), $angeltype['name']), [
+ buttons([
+ button(page_link_to('angeltypes'), _('Angeltypes'), 'back')
+ ]),
+ msg(),
+ form([
+ $supporter_mode
+ ? form_info(_('Name'), $angeltype['name'])
+ : form_text('name', _('Name'), $angeltype['name']),
+ $supporter_mode
+ ? form_info(_('Restricted'), $angeltype['restricted'] ? _('Yes') : _('No'))
+ : form_checkbox('restricted', _('Restricted'), $angeltype['restricted']),
+ $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_checkbox(
+ 'requires_driver_license',
+ _('Requires driver license'),
+ $angeltype['requires_driver_license']
+ ),
+ //form_text('contact_name', _('Name'), $angeltype['contact_name']),
+ //form_text('contact_dect', _('DECT'), $angeltype['contact_dect']),
+ //form_text('contact_email', _('E-Mail'), $angeltype['contact_email']),
+ form_info(
+ '',
+ _('Restricted angel types can only be used by an angel if enabled by a supporter (double opt-in).')
+ ),
+ form_textarea('description', _('Description'), $angeltype['description']),
+ form_info('', _('Please use markdown for the description.')),
+ form_submit('submit', _('Save'))
+ ])
+ ]);
}
/**
* Renders the buttons for the angeltype view.
+ *
+ * @param array $angeltype
+ * @param array|null $user_angeltype
+ * @param bool $admin_angeltypes
+ * @param bool $supporter
+ * @param array|null $user_driver_license
+ * @param array|null $user
+ * @return string
*/
-function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user) {
- $buttons = [
- button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
- ];
-
- if ($angeltype['requires_driver_license']) {
- $buttons[] = button(user_driver_license_edit_link($user), glyph("road") . _("my driving license"));
- }
-
- if ($user_angeltype == null) {
- $buttons[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), 'add');
- } else {
- if ($angeltype['requires_driver_license'] && $user_driver_license == null) {
- error(_("This angeltype requires a driver license. Please enter your driver license information!"));
+function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user)
+{
+ $buttons = [
+ button(page_link_to('angeltypes'), _('Angeltypes'), 'back')
+ ];
+
+ if ($angeltype['requires_driver_license']) {
+ $buttons[] = button(user_driver_license_edit_link($user), glyph('road') . _('my driving license'));
+ }
+
+ if ($user_angeltype == null) {
+ $buttons[] = button(
+ page_link_to('user_angeltypes', ['action' => 'add', 'angeltype_id' => $angeltype['id']]),
+ _('join'),
+ 'add'
+ );
+ } else {
+ if ($angeltype['requires_driver_license'] && $user_driver_license == null) {
+ error(_('This angeltype requires a driver license. Please enter your driver license information!'));
+ }
+
+ if ($angeltype['restricted'] && $user_angeltype['confirm_user_id'] == null) {
+ error(sprintf(
+ _('You are unconfirmed for this angeltype. Please go to the introduction for %s to get confirmed.'),
+ $angeltype['name']
+ ));
+ }
+ $buttons[] = button(
+ page_link_to('user_angeltypes', ['action' => 'delete', 'user_angeltype_id' => $user_angeltype['id']]),
+ _('leave'), 'cancel'
+ );
+ }
+
+ if ($admin_angeltypes || $supporter) {
+ $buttons[] = button(
+ page_link_to('angeltypes', ['action' => 'edit', 'angeltype_id' => $angeltype['id']]),
+ _('edit'),
+ 'edit'
+ );
}
-
- if ($angeltype['restricted'] && $user_angeltype['confirm_user_id'] == null) {
- error(sprintf(_("You are unconfirmed for this angeltype. Please go to the introduction for %s to get confirmed."), $angeltype['name']));
+ if ($admin_angeltypes) {
+ $buttons[] = button(
+ page_link_to('angeltypes', ['action' => 'delete', 'angeltype_id' => $angeltype['id']]),
+ _('delete'),
+ 'delete'
+ );
}
- $buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'], _("leave"), 'cancel');
- }
-
- if ($admin_angeltypes || $supporter) {
- $buttons[] = button(page_link_to('angeltypes') . '&action=edit&angeltype_id=' . $angeltype['id'], _("edit"), 'edit');
- }
- if ($admin_angeltypes) {
- $buttons[] = button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'], _("delete"), 'delete');
- }
-
- return buttons($buttons);
+
+ return buttons($buttons);
}
/**
* Renders and sorts the members of an angeltype into supporters, members and unconfirmed members.
*
- * @return [supporters, members, unconfirmed members]
+ * @param array $angeltype
+ * @param array $members
+ * @param bool $admin_user_angeltypes
+ * @param bool $admin_angeltypes
+ * @return array [supporters, members, unconfirmed members]
*/
-function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $admin_angeltypes) {
- $supporters = [];
- $members_confirmed = [];
- $members_unconfirmed = [];
- foreach ($members as $member) {
- $member['Nick'] = User_Nick_render($member);
+function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $admin_angeltypes)
+{
+ $supporters = [];
+ $members_confirmed = [];
+ $members_unconfirmed = [];
+ foreach ($members as $member) {
+ $member['Nick'] = User_Nick_render($member);
+ if ($angeltype['requires_driver_license']) {
+ $member['wants_to_drive'] = glyph_bool($member['wants_to_drive']);
+ $member['has_car'] = glyph_bool($member['has_car']);
+ $member['has_license_car'] = glyph_bool($member['has_license_car']);
+ $member['has_license_3_5t_transporter'] = glyph_bool($member['has_license_3_5t_transporter']);
+ $member['has_license_7_5t_truck'] = glyph_bool($member['has_license_7_5t_truck']);
+ $member['has_license_12_5t_truck'] = glyph_bool($member['has_license_12_5t_truck']);
+ $member['has_license_forklift'] = glyph_bool($member['has_license_forklift']);
+ }
- if ($angeltype['requires_driver_license']) {
- $member['wants_to_drive'] = glyph_bool($member['wants_to_drive']);
- $member['has_car'] = glyph_bool($member['has_car']);
- $member['has_license_car'] = glyph_bool($member['has_license_car']);
- $member['has_license_3_5t_transporter'] = glyph_bool($member['has_license_3_5t_transporter']);
- $member['has_license_7_5t_truck'] = glyph_bool($member['has_license_7_5t_truck']);
- $member['has_license_12_5t_truck'] = glyph_bool($member['has_license_12_5t_truck']);
- $member['has_license_forklift'] = glyph_bool($member['has_license_forklift']);
+ if ($angeltype['restricted'] && $member['confirm_user_id'] == null) {
+ $member['actions'] = table_buttons([
+ button(
+ page_link_to(
+ 'user_angeltypes',
+ ['action' => 'confirm', 'user_angeltype_id' => $member['user_angeltype_id']]
+ ),
+ _('confirm'),
+ 'btn-xs'
+ ),
+ button(
+ page_link_to(
+ 'user_angeltypes',
+ ['action' => 'delete', 'user_angeltype_id' => $member['user_angeltype_id']]
+ ),
+ _('deny'),
+ 'btn-xs'
+ )
+ ]);
+ $members_unconfirmed[] = $member;
+ } elseif ($member['supporter']) {
+ if ($admin_angeltypes) {
+ $member['actions'] = table_buttons([
+ button(
+ page_link_to('user_angeltypes', [
+ 'action' => 'update',
+ 'user_angeltype_id' => $member['user_angeltype_id'],
+ 'supporter' => 0
+ ]),
+ _('Remove supporter rights'),
+ 'btn-xs'
+ )
+ ]);
+ } else {
+ $member['actions'] = '';
+ }
+ $supporters[] = $member;
+ } else {
+ if ($admin_user_angeltypes) {
+ $member['actions'] = table_buttons([
+ $admin_angeltypes
+ ? button(page_link_to('user_angeltypes', [
+ 'action' => 'update',
+ 'user_angeltype_id' => $member['user_angeltype_id'],
+ 'supporter' => 1
+ ]),
+ _('Add supporter rights'), 'btn-xs')
+ : '',
+ button(
+ page_link_to('user_angeltypes', [
+ 'action' => 'delete',
+ 'user_angeltype_id' => $member['user_angeltype_id']
+ ]),
+ _('remove'),
+ 'btn-xs'
+ )
+ ]);
+ }
+ $members_confirmed[] = $member;
+ }
}
-
- if ($angeltype['restricted'] && $member['confirm_user_id'] == null) {
- $member['actions'] = table_buttons([
- button(page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $member['user_angeltype_id'], _("confirm"), 'btn-xs'),
- button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'], _("deny"), 'btn-xs')
- ]);
- $members_unconfirmed[] = $member;
- } elseif ($member['supporter']) {
- if ($admin_angeltypes) {
- $member['actions'] = table_buttons([
- button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&supporter=0', _("Remove supporter rights"), 'btn-xs')
- ]);
- } else {
- $member['actions'] = '';
- }
- $supporters[] = $member;
- } else {
- if ($admin_user_angeltypes) {
- $member['actions'] = table_buttons([
- $admin_angeltypes ? button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&supporter=1', _("Add supporter rights"), 'btn-xs') : '',
- button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'], _("remove"), 'btn-xs')
- ]);
- }
- $members_confirmed[] = $member;
- }
- }
-
- return [
- $supporters,
- $members_confirmed,
- $members_unconfirmed
- ];
+
+ return [
+ $supporters,
+ $members_confirmed,
+ $members_unconfirmed
+ ];
}
/**
* Creates the needed member table headers according to given rights and settings from the angeltype.
+ *
+ * @param array $angeltype
+ * @param bool $supporter
+ * @param bool $admin_angeltypes
+ * @return array
*/
-function AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes) {
- if ($angeltype['requires_driver_license'] && ($supporter || $admin_angeltypes)) {
+function AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes)
+{
+ if ($angeltype['requires_driver_license'] && ($supporter || $admin_angeltypes)) {
+ return [
+ 'Nick' => _('Nick'),
+ 'DECT' => _('DECT'),
+ 'wants_to_drive' => _('Driver'),
+ 'has_car' => _('Has car'),
+ 'has_license_car' => _('Car'),
+ 'has_license_3_5t_transporter' => _('3,5t Transporter'),
+ 'has_license_7_5t_truck' => _('7,5t Truck'),
+ 'has_license_12_5t_truck' => _('12,5t Truck'),
+ 'has_license_forklift' => _('Forklift'),
+ 'actions' => ''
+ ];
+ }
return [
- 'Nick' => _("Nick"),
- 'DECT' => _("DECT"),
- 'wants_to_drive' => _("Driver"),
- 'has_car' => _("Has car"),
- 'has_license_car' => _("Car"),
- 'has_license_3_5t_transporter' => _("3,5t Transporter"),
- 'has_license_7_5t_truck' => _("7,5t Truck"),
- 'has_license_12_5t_truck' => _("12,5t Truck"),
- 'has_license_forklift' => _("Forklift"),
- 'actions' => ''
+ 'Nick' => _('Nick'),
+ 'DECT' => _('DECT'),
+ 'actions' => ''
];
- }
- return [
- 'Nick' => _("Nick"),
- 'DECT' => _("DECT"),
- 'actions' => ''
- ];
}
/**
* Render an angeltype page containing the member lists.
+ *
+ * @param array $angeltype
+ * @param array[] $members
+ * @param array $user_angeltype
+ * @param bool $admin_user_angeltypes
+ * @param bool $admin_angeltypes
+ * @param bool $supporter
+ * @param array $user_driver_license
+ * @param array $user
+ * @return string
*/
-function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angeltypes, $admin_angeltypes, $supporter, $user_driver_license, $user) {
- $page = [
- AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user),
- msg()
- ];
-
- $page[] = '<h3>' . _("Description") . '</h3>';
- $parsedown = new Parsedown();
- if ($angeltype['description'] != "") {
- $page[] = '<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) {
- $page[] = '<h3>' . _("supporters") . '</h3>';
- $page[] = table($table_headers, $supporters);
- }
-
- if (count($members_confirmed) > 0) {
- $members_confirmed[] = [
- 'Nick' => _('Sum'),
- 'DECT' => count($members_confirmed),
- 'actions' => ''
- ];
- }
-
- if (count($members_unconfirmed) > 0) {
- $members_unconfirmed[] = [
- 'Nick' => _('Sum'),
- 'DECT' => count($members_unconfirmed),
- 'actions' => ''
+function AngelType_view(
+ $angeltype,
+ $members,
+ $user_angeltype,
+ $admin_user_angeltypes,
+ $admin_angeltypes,
+ $supporter,
+ $user_driver_license,
+ $user
+) {
+ $page = [
+ AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user),
+ msg()
];
- }
-
- $page[] = '<h3>' . _("Members") . '</h3>';
- if ($admin_user_angeltypes) {
- $page[] = buttons([
- button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("Add"), 'add')
- ]);
- }
- $page[] = table($table_headers, $members_confirmed);
-
- if ($admin_user_angeltypes && $angeltype['restricted'] && count($members_unconfirmed) > 0) {
- $page[] = '<h3>' . _("Unconfirmed") . '</h3>';
- $page[] = buttons([
- button(page_link_to('user_angeltypes') . '&action=confirm_all&angeltype_id=' . $angeltype['id'], _("confirm all"), 'ok'),
- button(page_link_to('user_angeltypes') . '&action=delete_all&angeltype_id=' . $angeltype['id'], _("deny all"), 'cancel')
- ]);
- $page[] = table($table_headers, $members_unconfirmed);
- }
-
- return page_with_title(sprintf(_("Team %s"), $angeltype['name']), $page);
+
+ $page[] = '<h3>' . _('Description') . '</h3>';
+ $parsedown = new Parsedown();
+ if ($angeltype['description'] != '') {
+ $page[] = '<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) {
+ $page[] = '<h3>' . _('supporters') . '</h3>';
+ $page[] = table($table_headers, $supporters);
+ }
+
+ if (count($members_confirmed) > 0) {
+ $members_confirmed[] = [
+ 'Nick' => _('Sum'),
+ 'DECT' => count($members_confirmed),
+ 'actions' => ''
+ ];
+ }
+
+ if (count($members_unconfirmed) > 0) {
+ $members_unconfirmed[] = [
+ 'Nick' => _('Sum'),
+ 'DECT' => count($members_unconfirmed),
+ 'actions' => ''
+ ];
+ }
+
+ $page[] = '<h3>' . _('Members') . '</h3>';
+ if ($admin_user_angeltypes) {
+ $page[] = buttons([
+ button(
+ page_link_to(
+ 'user_angeltypes',
+ ['action' => 'add', 'angeltype_id' => $angeltype['id']]
+ ),
+ _('Add'),
+ 'add'
+ )
+ ]);
+ }
+ $page[] = table($table_headers, $members_confirmed);
+
+ if ($admin_user_angeltypes && $angeltype['restricted'] && count($members_unconfirmed) > 0) {
+ $page[] = '<h3>' . _('Unconfirmed') . '</h3>';
+ $page[] = buttons([
+ button(
+ page_link_to('user_angeltypes', ['action' => 'confirm_all', 'angeltype_id' => $angeltype['id']]),
+ _('confirm all'),
+ 'ok'
+ ),
+ button(
+ page_link_to('user_angeltypes', ['action' => 'delete_all', 'angeltype_id' => $angeltype['id']]),
+ _('deny all'),
+ 'cancel'
+ )
+ ]);
+ $page[] = table($table_headers, $members_unconfirmed);
+ }
+
+ return page_with_title(sprintf(_('Team %s'), $angeltype['name']), $page);
}
/**
* Display the list of angeltypes.
*
- * @param array $angeltypes
+ * @param array $angeltypes
+ * @param bool $admin_angeltypes
+ * @return string
*/
-function AngelTypes_list_view($angeltypes, $admin_angeltypes) {
- return page_with_title(angeltypes_title(), [
- msg(),
- buttons([
- $admin_angeltypes ? button(page_link_to('angeltypes') . '&action=edit', _("New angeltype"), 'add') : '',
- button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description"))
- ]),
- table([
- 'name' => _("Name"),
- 'restricted' => glyph('lock') . _("Restricted"),
- 'no_self_signup' => glyph('share') . _("Self Sign Up Allowed"),
- 'membership' => _("Membership"),
- 'actions' => ""
- ], $angeltypes)
- ]);
+function AngelTypes_list_view($angeltypes, $admin_angeltypes)
+{
+ return page_with_title(angeltypes_title(), [
+ msg(),
+ buttons([
+ $admin_angeltypes
+ ? button(page_link_to('angeltypes', ['action' => 'edit']), _('New angeltype'), 'add')
+ : '',
+ button(page_link_to('angeltypes', ['action' => 'about']), _('Teams/Job description'))
+ ]),
+ table([
+ 'name' => _('Name'),
+ 'restricted' => glyph('lock') . _('Restricted'),
+ 'no_self_signup' => glyph('share') . _('Self Sign Up Allowed'),
+ 'membership' => _('Membership'),
+ 'actions' => ''
+ ], $angeltypes)
+ ]);
}
/**
* Renders the about info for an angeltype.
+ *
+ * @param array $angeltype
+ * @return string
*/
-function AngelTypes_about_view_angeltype($angeltype) {
- $parsedown = new Parsedown();
-
- $html = '<h2>' . $angeltype['name'] . '</h2>';
-
- if (isset($angeltype['user_angeltype_id'])) {
- $buttons = [];
- if ($angeltype['user_angeltype_id'] != null) {
- $buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $angeltype['user_angeltype_id'], _("leave"), 'cancel');
- } else {
- $buttons[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), 'add');
+function AngelTypes_about_view_angeltype($angeltype)
+{
+ $parsedown = new Parsedown();
+
+ $html = '<h2>' . $angeltype['name'] . '</h2>';
+
+ if (isset($angeltype['user_angeltype_id'])) {
+ $buttons = [];
+ if ($angeltype['user_angeltype_id'] != null) {
+ $buttons[] = button(
+ page_link_to(
+ 'user_angeltypes',
+ ['action' => 'delete', 'user_angeltype_id' => $angeltype['user_angeltype_id']]
+ ),
+ _('leave'),
+ 'cancel'
+ );
+ } else {
+ $buttons[] = button(
+ page_link_to('user_angeltypes', ['action' => 'add', 'angeltype_id' => $angeltype['id']]),
+ _('join'),
+ 'add'
+ );
+ }
+ $html .= buttons($buttons);
}
- $html .= buttons($buttons);
- }
-
- if ($angeltype['restricted']) {
- $html .= info(_("This angeltype is restricted by double-opt-in by a team supporter. Please show up at the according introduction meetings."), true);
- }
- if ($angeltype['description'] != "") {
- $html .= '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
- }
- $html .= '<hr />';
-
- return $html;
+
+ if ($angeltype['restricted']) {
+ $html .= info(
+ _('This angeltype is restricted by double-opt-in by a team supporter. Please show up at the according introduction meetings.'),
+ true
+ );
+ }
+ if ($angeltype['description'] != '') {
+ $html .= '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
+ }
+ $html .= '<hr />';
+
+ return $html;
}
/**
* Renders a site that contains every angeltype and its description, basically as an overview of the needed help types.
+ *
+ * @param array[] $angeltypes
+ * @param bool $user_logged_in
+ * @return string
*/
-function AngelTypes_about_view($angeltypes, $user_logged_in) {
- global $faq_url;
-
- $content = [
- buttons([
- ! $user_logged_in ? button(page_link_to('register'), register_title()) : '',
- ! $user_logged_in ? button(page_link_to('login'), login_title()) : '',
- $user_logged_in ? button(page_link_to('angeltypes'), angeltypes_title(), 'back') : '',
- button($faq_url, _("FAQ"), "btn-primary")
- ]),
- '<p>' . _("Here is the list of teams and their tasks. If you have questions, read the FAQ.") . '</p>',
- '<hr />'
- ];
- foreach ($angeltypes as $angeltype) {
- $content[] = AngelTypes_about_view_angeltype($angeltype);
- }
-
- return page_with_title(_("Teams/Job description"), $content);
-}
+function AngelTypes_about_view($angeltypes, $user_logged_in)
+{
+ global $privileges;
-?>
+ $buttons = [];
+
+ if ($user_logged_in) {
+ $buttons[] = button(page_link_to('angeltypes'), angeltypes_title(), 'back');
+ } else {
+ if (in_array('register', $privileges) && config('registration_enabled')) {
+ $buttons[] = button(page_link_to('register'), register_title());
+ }
+
+ $buttons[] = button(page_link_to('login'), login_title());
+ }
+
+ $faqUrl = config('faq_url');
+ if (!empty($faqUrl)) {
+ $buttons[] = button($faqUrl, _('FAQ'), 'btn-primary');
+ }
+
+ $content = [
+ buttons($buttons),
+ '<p>' . _('Here is the list of teams and their tasks. If you have questions, read the FAQ.') . '</p>',
+ '<hr />'
+ ];
+ foreach ($angeltypes as $angeltype) {
+ $content[] = AngelTypes_about_view_angeltype($angeltype);
+ }
+
+ return page_with_title(_('Teams/Job description'), $content);
+}
diff --git a/includes/view/EventConfig_view.php b/includes/view/EventConfig_view.php
index 37a19839..2b092962 100644
--- a/includes/view/EventConfig_view.php
+++ b/includes/view/EventConfig_view.php
@@ -2,128 +2,154 @@
/**
* Shows basic event infos and countdowns.
- * @param EventConfig $event_config The event configuration
+ *
+ * @param array $event_config The event configuration
+ * @return string
*/
-function EventConfig_countdown_page($event_config) {
- if ($event_config == null) {
- return div('col-md-12 text-center', [
- heading(sprintf(_("Welcome to the %s!"), '<span class="icon-icon_angel"></span> ENGELSYSTEM'), 2)
- ]);
- }
-
- $elements = [];
-
- if ($event_config['event_name'] != null) {
- $elements[] = div('col-sm-12 text-center', [
- heading(sprintf(_("Welcome to the %s!"), $event_config['event_name'] . ' <span class="icon-icon_angel"></span> ENGELSYSTEM'), 2)
- ]);
- }
-
- if ($event_config['buildup_start_date'] != null && time() < $event_config['buildup_start_date']) {
- $elements[] = div('col-sm-3 text-center hidden-xs', [
- heading(_("Buildup starts"), 4),
- '<span class="moment-countdown text-big" data-timestamp="' . $event_config['buildup_start_date'] . '">%c</span>',
- '<small>' . date(_("Y-m-d"), $event_config['buildup_start_date']) . '</small>'
- ]);
- }
-
- if ($event_config['event_start_date'] != null && time() < $event_config['event_start_date']) {
- $elements[] = div('col-sm-3 text-center hidden-xs', [
- heading(_("Event starts"), 4),
- '<span class="moment-countdown text-big" data-timestamp="' . $event_config['event_start_date'] . '">%c</span>',
- '<small>' . date(_("Y-m-d"), $event_config['event_start_date']) . '</small>'
- ]);
- }
-
- if ($event_config['event_end_date'] != null && time() < $event_config['event_end_date']) {
- $elements[] = div('col-sm-3 text-center hidden-xs', [
- heading(_("Event ends"), 4),
- '<span class="moment-countdown text-big" data-timestamp="' . $event_config['event_end_date'] . '">%c</span>',
- '<small>' . date(_("Y-m-d"), $event_config['event_end_date']) . '</small>'
- ]);
- }
-
- if ($event_config['teardown_end_date'] != null && time() < $event_config['teardown_end_date']) {
- $elements[] = div('col-sm-3 text-center hidden-xs', [
- heading(_("Teardown ends"), 4),
- '<span class="moment-countdown text-big" data-timestamp="' . $event_config['teardown_end_date'] . '">%c</span>',
- '<small>' . date(_("Y-m-d"), $event_config['teardown_end_date']) . '</small>'
- ]);
- }
-
- return join("", $elements);
+function EventConfig_countdown_page($event_config)
+{
+ if ($event_config == null) {
+ return div('col-md-12 text-center', [
+ heading(sprintf(_('Welcome to the %s!'), '<span class="icon-icon_angel"></span> ENGELSYSTEM'), 2)
+ ]);
+ }
+
+ $elements = [];
+
+ if ($event_config['event_name'] != null) {
+ $elements[] = div('col-sm-12 text-center', [
+ heading(sprintf(
+ _('Welcome to the %s!'),
+ $event_config['event_name'] . ' <span class="icon-icon_angel"></span> ENGELSYSTEM'
+ ), 2)
+ ]);
+ }
+
+ if ($event_config['buildup_start_date'] != null && time() < $event_config['buildup_start_date']) {
+ $elements[] = div('col-sm-3 text-center hidden-xs', [
+ heading(_('Buildup starts'), 4),
+ '<span class="moment-countdown text-big" data-timestamp="' . $event_config['buildup_start_date'] . '">%c</span>',
+ '<small>' . date(_('Y-m-d'), $event_config['buildup_start_date']) . '</small>'
+ ]);
+ }
+
+ if ($event_config['event_start_date'] != null && time() < $event_config['event_start_date']) {
+ $elements[] = div('col-sm-3 text-center hidden-xs', [
+ heading(_('Event starts'), 4),
+ '<span class="moment-countdown text-big" data-timestamp="' . $event_config['event_start_date'] . '">%c</span>',
+ '<small>' . date(_('Y-m-d'), $event_config['event_start_date']) . '</small>'
+ ]);
+ }
+
+ if ($event_config['event_end_date'] != null && time() < $event_config['event_end_date']) {
+ $elements[] = div('col-sm-3 text-center hidden-xs', [
+ heading(_('Event ends'), 4),
+ '<span class="moment-countdown text-big" data-timestamp="' . $event_config['event_end_date'] . '">%c</span>',
+ '<small>' . date(_('Y-m-d'), $event_config['event_end_date']) . '</small>'
+ ]);
+ }
+
+ if ($event_config['teardown_end_date'] != null && time() < $event_config['teardown_end_date']) {
+ $elements[] = div('col-sm-3 text-center hidden-xs', [
+ heading(_('Teardown ends'), 4),
+ '<span class="moment-countdown text-big" data-timestamp="' . $event_config['teardown_end_date'] . '">%c</span>',
+ '<small>' . date(_('Y-m-d'), $event_config['teardown_end_date']) . '</small>'
+ ]);
+ }
+
+ return join('', $elements);
}
/**
* Converts event name and start+end date into a line of text.
+ *
+ * @param array $event_config
+ * @return string
*/
-function EventConfig_info($event_config) {
- if ($event_config == null) {
- return "";
- }
-
- // 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) {
- return sprintf(_("%s, from %s to %s"), $event_config['event_name'], date(_("Y-m-d"), $event_config['event_start_date']), date(_("Y-m-d"), $event_config['event_end_date']));
- }
-
- // Event name, start date are set
- if ($event_config['event_name'] != null && $event_config['event_start_date'] != null) {
- return sprintf(_("%s, starting %s"), $event_config['event_name'], date(_("Y-m-d"), $event_config['event_start_date']));
- }
-
- // Event start+end date are set
- if ($event_config['event_start_date'] != null && $event_config['event_end_date'] != null) {
- return sprintf(_("Event from %s to %s"), date(_("Y-m-d"), $event_config['event_start_date']), date(_("Y-m-d"), $event_config['event_end_date']));
- }
-
- // Only event name is set
- if ($event_config['event_name'] != null) {
- return sprintf($event_config['event_name']);
- }
-
- return "";
+function EventConfig_info($event_config)
+{
+ if ($event_config == null) {
+ return '';
+ }
+
+ // 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) {
+ return sprintf(
+ _('%s, from %s to %s'),
+ $event_config['event_name'],
+ date(_('Y-m-d'), $event_config['event_start_date']),
+ date(_('Y-m-d'), $event_config['event_end_date'])
+ );
+ }
+
+ // Event name, start date are set
+ if ($event_config['event_name'] != null && $event_config['event_start_date'] != null) {
+ return sprintf(
+ _('%s, starting %s'), $event_config['event_name'],
+ date(_('Y-m-d'), $event_config['event_start_date'])
+ );
+ }
+
+ // Event start+end date are set
+ if ($event_config['event_start_date'] != null && $event_config['event_end_date'] != null) {
+ return sprintf(
+ _('Event from %s to %s'),
+ date(_('Y-m-d'), $event_config['event_start_date']),
+ date(_('Y-m-d'), $event_config['event_end_date'])
+ );
+ }
+
+ // Only event name is set
+ if ($event_config['event_name'] != null) {
+ return sprintf($event_config['event_name']);
+ }
+
+ return '';
}
/**
* Render edit page for event config.
*
- * @param string $event_name
- * The event name
- * @param string $event_welcome_msg
- * The welcome message
- * @param date $buildup_start_date
- * @param date $event_start_date
- * @param date $event_end_date
- * @param date $teardown_end_date
+ * @param string $event_name The event name
+ * @param string $event_welcome_msg The welcome message
+ * @param int $buildup_start_date unix time stamp
+ * @param int $event_start_date unix time stamp
+ * @param int $event_end_date unix time stamp
+ * @param int $teardown_end_date unix time stamp
+ * @return string
*/
-function EventConfig_edit_view($event_name, $event_welcome_msg, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date) {
- return page_with_title(event_config_title(), [
- msg(),
- form([
- div('row', [
- div('col-md-6', [
- 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."))
- ]),
- div('col-md-3 col-xs-6', [
- form_date('buildup_start_date', _("Buildup date"), $buildup_start_date),
- form_date('event_start_date', _("Event start date"), $event_start_date)
- ]),
- div('col-md-3 col-xs-6', [
- form_date('teardown_end_date', _("Teardown end date"), $teardown_end_date),
- form_date('event_end_date', _("Event end date"), $event_end_date)
- ])
- ]),
- div('row', [
- div('col-md-6', [
- form_submit('submit', _("Save"))
- ])
- ])
- ])
- ]);
+function EventConfig_edit_view(
+ $event_name,
+ $event_welcome_msg,
+ $buildup_start_date,
+ $event_start_date,
+ $event_end_date,
+ $teardown_end_date
+) {
+ return page_with_title(event_config_title(), [
+ msg(),
+ form([
+ div('row', [
+ div('col-md-6', [
+ 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.'))
+ ]),
+ div('col-md-3 col-xs-6', [
+ form_date('buildup_start_date', _('Buildup date'), $buildup_start_date),
+ form_date('event_start_date', _('Event start date'), $event_start_date)
+ ]),
+ div('col-md-3 col-xs-6', [
+ form_date('teardown_end_date', _('Teardown end date'), $teardown_end_date),
+ form_date('event_end_date', _('Event end date'), $event_end_date)
+ ])
+ ]),
+ div('row', [
+ div('col-md-6', [
+ form_submit('submit', _('Save'))
+ ])
+ ])
+ ])
+ ]);
}
-
-?> \ No newline at end of file
diff --git a/includes/view/Questions_view.php b/includes/view/Questions_view.php
index a44a29d1..a44a099d 100644
--- a/includes/view/Questions_view.php
+++ b/includes/view/Questions_view.php
@@ -1,37 +1,50 @@
<?php
-function Questions_view($open_questions, $answered_questions, $ask_action) {
- foreach ($open_questions as &$question) {
- $question['actions'] = '<a href="' . page_link_to("user_questions") . '&action=delete&id=' . $question['QID'] . '">' . _("delete") . '</a>';
- $question['Question'] = str_replace("\n", '<br />', $question['Question']);
- }
-
- foreach ($answered_questions as &$question) {
- $question['Question'] = str_replace("\n", '<br />', $question['Question']);
- $question['Answer'] = str_replace("\n", '<br />', $question['Answer']);
- $question['actions'] = '<a href="' . page_link_to("user_questions") . '&action=delete&id=' . $question['QID'] . '">' . _("delete") . '</a>';
- }
-
- return page_with_title(questions_title(), [
- msg(),
- heading(_("Open questions"), 2),
- table([
- 'Question' => _("Question"),
- 'actions' => ""
- ], $open_questions),
- heading(_("Answered questions"), 2),
- table([
- 'Question' => _("Question"),
- 'answer_user' => _("Answered by"),
- 'Answer' => _("Answer"),
- 'actions' => ""
- ], $answered_questions),
- heading(_("Ask the Heaven"), 2),
- form([
- form_textarea('question', _("Your Question:"), ""),
- form_submit('submit', _("Save"))
- ], $ask_action)
- ]);
-}
+/**
+ * @param array[] $open_questions
+ * @param array[] $answered_questions
+ * @param string $ask_action
+ * @return string
+ */
+function Questions_view($open_questions, $answered_questions, $ask_action)
+{
+ foreach ($open_questions as &$question) {
+ $question['actions'] = '<a href="'
+ . page_link_to('user_questions', ['action' => 'delete', 'id' => $question['QID']])
+ . '">'
+ . _('delete')
+ . '</a>';
+ $question['Question'] = str_replace("\n", '<br />', $question['Question']);
+ }
+
+ foreach ($answered_questions as &$question) {
+ $question['Question'] = str_replace("\n", '<br />', $question['Question']);
+ $question['Answer'] = str_replace("\n", '<br />', $question['Answer']);
+ $question['actions'] = '<a href="'
+ . page_link_to('user_questions', ['action' => 'delete', 'id' => $question['QID']])
+ . '">'
+ . _('delete')
+ . '</a>';
+ }
-?> \ No newline at end of file
+ return page_with_title(questions_title(), [
+ msg(),
+ heading(_('Open questions'), 2),
+ table([
+ 'Question' => _('Question'),
+ 'actions' => ''
+ ], $open_questions),
+ heading(_('Answered questions'), 2),
+ table([
+ 'Question' => _('Question'),
+ 'answer_user' => _('Answered by'),
+ 'Answer' => _('Answer'),
+ 'actions' => ''
+ ], $answered_questions),
+ heading(_('Ask the Heaven'), 2),
+ form([
+ form_textarea('question', _('Your Question:'), ''),
+ form_submit('submit', _('Save'))
+ ], $ask_action)
+ ]);
+}
diff --git a/includes/view/Rooms_view.php b/includes/view/Rooms_view.php
index 7afdc67b..adb58a9a 100644
--- a/includes/view/Rooms_view.php
+++ b/includes/view/Rooms_view.php
@@ -1,20 +1,39 @@
<?php
-use Engelsystem\ShiftsFilterRenderer;
+
use Engelsystem\ShiftCalendarRenderer;
+use Engelsystem\ShiftsFilterRenderer;
-function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer) {
- return page_with_title(glyph('map-marker') . $room['Name'], [
- $shiftsFilterRenderer->render(room_link($room)) ,
- $shiftCalendarRenderer->render()
- ]);
-}
+/**
+ * @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']) {
+ $assignNotice = info(render_user_arrived_hint(), true);
+ }
-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'];
+ return page_with_title(glyph('map-marker') . $room['Name'], [
+ $shiftsFilterRenderer->render($room),
+ $assignNotice,
+ $shiftCalendarRenderer->render()
+ ]);
}
-?> \ No newline at end of file
+/**
+ * @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 33fccec3..fd4c6f06 100644
--- a/includes/view/ShiftCalendarLane.php
+++ b/includes/view/ShiftCalendarLane.php
@@ -2,62 +2,85 @@
namespace Engelsystem;
+use Exception;
+
/**
* Represents a single lane in a shifts calendar.
*/
-class ShiftCalendarLane {
-
- private $firstBlockStartTime;
-
- private $blockCount;
-
- private $header;
-
- private $shifts = [];
-
- public function __construct($header, $firstBlockStartTime, $blockCount) {
- $this->header = $header;
- $this->firstBlockStartTime = $firstBlockStartTime;
- $this->blockCount = $blockCount;
- }
-
- /**
- * Adds a shift to the lane, but only if it fits.
- * Returns true on success.
- *
- * @param Shift $shift
- * The shift to add
- * @return boolean true on success
- */
- public function addShift($shift) {
- if ($this->shiftFits($shift)) {
- $this->shifts[] = $shift;
- return true;
+class ShiftCalendarLane
+{
+ /** @var int */
+ private $firstBlockStartTime;
+
+ /** @var int */
+ private $blockCount;
+
+ /** @var string */
+ private $header;
+
+ /** @var array[] */
+ private $shifts = [];
+
+ /**
+ * ShiftCalendarLane constructor.
+ *
+ * @param string $header
+ * @param int $firstBlockStartTime Unix timestamp
+ * @param int $blockCount
+ */
+ public function __construct($header, $firstBlockStartTime, $blockCount)
+ {
+ $this->header = $header;
+ $this->firstBlockStartTime = $firstBlockStartTime;
+ $this->blockCount = $blockCount;
}
- return false;
- }
-
- /**
- * Returns true if given shift fits into this lane.
- *
- * @param Shift $shift
- * The shift to fit into this lane
- */
- public function shiftFits($newShift) {
- foreach ($this->shifts as $laneShift) {
- if (! ($newShift['start'] >= $laneShift['end'] || $newShift['end'] <= $laneShift['start'])) {
- return false;
- }
+
+ /**
+ * Adds a shift to the lane, but only if it fits.
+ * Returns true on success.
+ *
+ * @param array $shift The shift to add
+ * @throws Exception if the shift doesn't fit into the lane.
+ */
+ public function addShift($shift)
+ {
+ if ($this->shiftFits($shift)) {
+ $this->shifts[] = $shift;
+ return;
+ }
+ throw new Exception('Unable to add shift to shift calendar lane.');
}
- return true;
- }
- public function getHeader() {
- return $this->header;
- }
+ /**
+ * Returns true if given shift fits into this lane.
+ *
+ * @param array $newShift
+ * @return bool
+ * @internal param array $shift The shift to fit into this lane
+ */
+ public function shiftFits($newShift)
+ {
+ foreach ($this->shifts as $laneShift) {
+ if (!($newShift['start'] >= $laneShift['end'] || $newShift['end'] <= $laneShift['start'])) {
+ return false;
+ }
+ }
+ return true;
+ }
- public function getShifts() {
- return $this->shifts;
- }
+ /**
+ * @return string
+ */
+ public function getHeader()
+ {
+ return $this->header;
+ }
+
+ /**
+ * @return array[]
+ */
+ public function getShifts()
+ {
+ return $this->shifts;
+ }
}
-?> \ No newline at end of file
diff --git a/includes/view/ShiftCalendarRenderer.php b/includes/view/ShiftCalendarRenderer.php
index 8c8e72a4..d2becb58 100644
--- a/includes/view/ShiftCalendarRenderer.php
+++ b/includes/view/ShiftCalendarRenderer.php
@@ -2,256 +2,310 @@
namespace Engelsystem;
-class ShiftCalendarRenderer {
-
- /**
- * 15m * 60s/m = 900s
- */
- const SECONDS_PER_ROW = 900;
-
- /**
- * Height of a block in pixel.
- * Do not change - corresponds with theme/css
- */
- const BLOCK_HEIGHT = 30;
-
- /**
- * Distance between two shifts in pixels
- */
- const MARGIN = 5;
-
- /**
- * Seconds added to the start and end time
- */
- const TIME_MARGIN = 1800;
-
- private $lanes;
-
- private $shiftsFilter;
-
- private $firstBlockStartTime = null;
-
- private $lastBlockEndTime = null;
-
- private $blocksPerSlot = null;
-
- private $needed_angeltypes = null;
-
- private $shift_entries = null;
-
- public function __construct($shifts, $needed_angeltypes, $shift_entries, ShiftsFilter $shiftsFilter) {
- $this->shiftsFilter = $shiftsFilter;
- $this->firstBlockStartTime = $this->calcFirstBlockStartTime($shifts);
- $this->lastBlockEndTime = $this->calcLastBlockEndTime($shifts);
- $this->lanes = $this->assignShiftsToLanes($shifts);
- $this->needed_angeltypes = $needed_angeltypes;
- $this->shift_entries = $shift_entries;
- }
-
- /**
- * Assigns the shifts to different lanes per room if they collide
- *
- * @param Shift[] $shifts
- * The shifts to assign
- *
- * @return Returns an array that assigns a room_id to an array of ShiftCalendarLane containing the shifts
- */
- private function assignShiftsToLanes($shifts) {
- // array that assigns a room id to a list of lanes (per room)
- $lanes = [];
-
- foreach ($shifts as $shift) {
- $room_id = $shift['RID'];
- $header = Room_name_render([
- 'RID' => $room_id,
- 'Name' => $shift['room_name']
- ]);
- if (! isset($lanes[$room_id])) {
- // initialize room with one lane
- $lanes[$room_id] = [
- new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot())
- ];
- }
- // Try to add the shift to the existing lanes for this room
- $shift_added = false;
- foreach ($lanes[$room_id] as $lane) {
- $shift_added = $lane->addShift($shift);
- if ($shift_added == true) {
- break;
- }
- }
- // If all lanes for this room are busy, create a new lane and add shift to it
- if ($shift_added == false) {
- $newLane = new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot());
- if (! $newLane->addShift($shift)) {
- engelsystem_error("Unable to add shift to new lane.");
+class ShiftCalendarRenderer
+{
+ /**
+ * 15m * 60s/m = 900s
+ */
+ const SECONDS_PER_ROW = 900;
+
+ /**
+ * Height of a block in pixel.
+ * Do not change - corresponds with theme/css
+ */
+ const BLOCK_HEIGHT = 30;
+
+ /**
+ * Distance between two shifts in pixels
+ */
+ const MARGIN = 5;
+
+ /**
+ * Seconds added to the start and end time
+ */
+ const TIME_MARGIN = 1800;
+
+ /** @var array */
+ private $lanes;
+
+ /** @var ShiftsFilter */
+ private $shiftsFilter;
+
+ /** @var int */
+ private $firstBlockStartTime = 0;
+
+ /** @var int */
+ private $lastBlockEndTime = 0;
+
+ /** @var int */
+ private $blocksPerSlot = null;
+
+ /** @var array[] */
+ private $needed_angeltypes = [];
+
+ /** @var array[] */
+ private $shift_entries = [];
+
+ /**
+ * ShiftCalendarRenderer constructor.
+ *
+ * @param array[] $shifts
+ * @param array[] $needed_angeltypes
+ * @param array[] $shift_entries
+ * @param ShiftsFilter $shiftsFilter
+ */
+ public function __construct($shifts, $needed_angeltypes, $shift_entries, ShiftsFilter $shiftsFilter)
+ {
+ $this->shiftsFilter = $shiftsFilter;
+ $this->firstBlockStartTime = $this->calcFirstBlockStartTime($shifts);
+ $this->lastBlockEndTime = $this->calcLastBlockEndTime($shifts);
+ $this->lanes = $this->assignShiftsToLanes($shifts);
+ $this->needed_angeltypes = $needed_angeltypes;
+ $this->shift_entries = $shift_entries;
+ }
+
+ /**
+ * Assigns the shifts to different lanes per room if they collide
+ *
+ * @param array[] $shifts The shifts to assign
+ * @return array Returns an array that assigns a room_id to an array of ShiftCalendarLane containing the shifts
+ */
+ private function assignShiftsToLanes($shifts)
+ {
+ // array that assigns a room id to a list of lanes (per room)
+ $lanes = [];
+
+ foreach ($shifts as $shift) {
+ $room_id = $shift['RID'];
+ $header = Room_name_render([
+ 'RID' => $room_id,
+ 'Name' => $shift['room_name']
+ ]);
+ if (!isset($lanes[$room_id])) {
+ // initialize room with one lane
+ $lanes[$room_id] = [
+ new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot())
+ ];
+ }
+ // Try to add the shift to the existing lanes for this room
+ $shift_added = false;
+ foreach ($lanes[$room_id] as $lane) {
+ /** @var ShiftCalendarLane $lane */
+ if ($lane->shiftFits($shift)) {
+ $lane->addShift($shift);
+ $shift_added = true;
+ break;
+ }
+ }
+ // If all lanes for this room are busy, create a new lane and add shift to it
+ if ($shift_added == false) {
+ $newLane = new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot());
+ $newLane->addShift($shift);
+ $lanes[$room_id][] = $newLane;
+ }
}
- $lanes[$room_id][] = $newLane;
- }
+
+ return $lanes;
}
-
- return $lanes;
- }
- public function getFirstBlockStartTime() {
- return $this->firstBlockStartTime;
- }
+ /**
+ * @return int
+ */
+ public function getFirstBlockStartTime()
+ {
+ return $this->firstBlockStartTime;
+ }
- public function getLastBlockEndTime() {
- return $this->lastBlockEndTime;
- }
+ /**
+ * @return int
+ */
+ public function getLastBlockEndTime()
+ {
+ return $this->lastBlockEndTime;
+ }
- public function getBlocksPerSlot() {
- if ($this->blocksPerSlot == null) {
- $this->blocksPerSlot = $this->calcBlocksPerSlot();
+ /**
+ * @return float
+ */
+ public function getBlocksPerSlot()
+ {
+ if ($this->blocksPerSlot == null) {
+ $this->blocksPerSlot = $this->calcBlocksPerSlot();
+ }
+ return $this->blocksPerSlot;
+ }
+
+ /**
+ * Renders the whole calendar
+ *
+ * @return string the generated html
+ */
+ public function render()
+ {
+ if (count($this->lanes) == 0) {
+ return '';
+ }
+ return div('shift-calendar', [
+ $this->renderTimeLane(),
+ $this->renderShiftLanes()
+ ]) . $this->renderLegend();
}
- return $this->blocksPerSlot;
- }
-
- /**
- * Renders the whole calendar
- *
- * @return the generated html
- */
- public function render() {
- if (count($this->lanes) == 0) {
- return '';
+
+ /**
+ * Renders the lanes containing the shifts
+ *
+ * @return string
+ */
+ private function renderShiftLanes()
+ {
+ $html = '';
+ foreach ($this->lanes as $room_lanes) {
+ foreach ($room_lanes as $lane) {
+ $html .= $this->renderLane($lane);
+ }
+ }
+
+ return $html;
}
- return div('shift-calendar', [
- $this->renderTimeLane(),
- $this->renderShiftLanes()
- ]) . $this->renderLegend();
- }
-
- /**
- * Renders the lanes containing the shifts
- */
- private function renderShiftLanes() {
- $html = "";
- foreach ($this->lanes as $room_lanes) {
- foreach ($room_lanes as $lane) {
- $html .= $this->renderLane($lane);
- }
+
+ /**
+ * Renders a single lane
+ *
+ * @param ShiftCalendarLane $lane The lane to render
+ * @return string
+ */
+ private function renderLane(ShiftCalendarLane $lane)
+ {
+ global $user;
+
+ $shift_renderer = new ShiftCalendarShiftRenderer();
+ $html = '';
+ $rendered_until = $this->getFirstBlockStartTime();
+
+ foreach ($lane->getShifts() as $shift) {
+ while ($rendered_until + ShiftCalendarRenderer::SECONDS_PER_ROW <= $shift['start']) {
+ $html .= $this->renderTick($rendered_until);
+ $rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW;
+ }
+
+ list ($shift_height, $shift_html) = $shift_renderer->render(
+ $shift,
+ $this->needed_angeltypes[$shift['SID']],
+ $this->shift_entries[$shift['SID']],
+ $user
+ );
+ $html .= $shift_html;
+ $rendered_until += $shift_height * ShiftCalendarRenderer::SECONDS_PER_ROW;
+ }
+
+ while ($rendered_until < $this->getLastBlockEndTime()) {
+ $html .= $this->renderTick($rendered_until);
+ $rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW;
+ }
+
+ return div('lane', [
+ div('header', $lane->getHeader()),
+ $html
+ ]);
}
-
- return $html;
- }
-
- /**
- * Renders a single lane
- *
- * @param ShiftCalendarLane $lane
- * The lane to render
- */
- private function renderLane(ShiftCalendarLane $lane) {
- global $user;
-
- $shift_renderer = new ShiftCalendarShiftRenderer();
- $html = "";
- $rendered_until = $this->getFirstBlockStartTime();
-
- foreach ($lane->getShifts() as $shift) {
- while ($rendered_until + ShiftCalendarRenderer::SECONDS_PER_ROW <= $shift['start']) {
- $html .= $this->renderTick($rendered_until);
- $rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW;
- }
-
- list($shift_height, $shift_html) = $shift_renderer->render($shift, $this->needed_angeltypes[$shift['SID']], $this->shift_entries[$shift['SID']], $user);
- $html .= $shift_html;
- $rendered_until += $shift_height * ShiftCalendarRenderer::SECONDS_PER_ROW;
+
+ /**
+ * Renders a tick/block for given time
+ *
+ * @param int $time unix timestamp
+ * @param boolean $label Should time labels be generated?
+ * @return string rendered tick html
+ */
+ private function renderTick($time, $label = false)
+ {
+ if ($time % (24 * 60 * 60) == 23 * 60 * 60) {
+ if (!$label) {
+ return div('tick day');
+ }
+ return div('tick day', [
+ date('m-d<b\r />H:i', $time)
+ ]);
+ } elseif ($time % (60 * 60) == 0) {
+ if (!$label) {
+ return div('tick hour');
+ }
+ return div('tick hour', [
+ date('m-d<b\r />H:i', $time)
+ ]);
+ }
+ return div('tick');
}
-
- while ($rendered_until < $this->getLastBlockEndTime()) {
- $html .= $this->renderTick($rendered_until);
- $rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW;
+
+ /**
+ * Renders the left time lane including hour/day ticks
+ *
+ * @return string
+ */
+ private function renderTimeLane()
+ {
+ $time_slot = [
+ div('header', [
+ _('Time')
+ ])
+ ];
+ for ($block = 0; $block < $this->getBlocksPerSlot(); $block++) {
+ $thistime = $this->getFirstBlockStartTime() + ($block * ShiftCalendarRenderer::SECONDS_PER_ROW);
+ $time_slot[] = $this->renderTick($thistime, true);
+ }
+ return div('lane time', $time_slot);
}
-
- return div('lane', [
- div('header', $lane->getHeader()),
- $html
- ]);
- }
-
- /**
- * Renders a tick/block for given time
- *
- * @param int $time
- * unix timestamp
- * @param boolean $label
- * Should time labels be generated?
- * @return rendered tick html
- */
- private function renderTick($time, $label = false) {
- if ($time % (24 * 60 * 60) == 23 * 60 * 60) {
- if (! $label) {
- return div('tick day');
- }
- return div('tick day', [
- date('m-d<b\r />H:i', $time)
- ]);
- } elseif ($time % (60 * 60) == 0) {
- if (! $label) {
- return div('tick hour');
- }
- return div('tick hour', [
- date('m-d<b\r />H:i', $time)
- ]);
+
+ /**
+ * @param array[] $shifts
+ * @return int
+ */
+ private function calcFirstBlockStartTime($shifts)
+ {
+ $start_time = $this->shiftsFilter->getEndTime();
+ foreach ($shifts as $shift) {
+ if ($shift['start'] < $start_time) {
+ $start_time = $shift['start'];
+ }
+ }
+ return ShiftCalendarRenderer::SECONDS_PER_ROW * floor(($start_time - ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW);
}
- return div('tick');
- }
-
- /**
- * Renders the left time lane including hour/day ticks
- */
- private function renderTimeLane() {
- $time_slot = [
- div('header', [
- _("Time")
- ])
- ];
- for ($block = 0; $block < $this->getBlocksPerSlot(); $block ++) {
- $thistime = $this->getFirstBlockStartTime() + ($block * ShiftCalendarRenderer::SECONDS_PER_ROW);
- $time_slot[] = $this->renderTick($thistime, true);
+
+ /**
+ * @param array[] $shifts
+ * @return int
+ */
+ private function calcLastBlockEndTime($shifts)
+ {
+ $end_time = $this->shiftsFilter->getStartTime();
+ foreach ($shifts as $shift) {
+ if ($shift['end'] > $end_time) {
+ $end_time = $shift['end'];
+ }
+ }
+ return ShiftCalendarRenderer::SECONDS_PER_ROW * ceil(($end_time + ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW);
}
- return div('lane time', $time_slot);
- }
-
- private function calcFirstBlockStartTime($shifts) {
- $start_time = $this->shiftsFilter->getEndTime();
- foreach ($shifts as $shift) {
- if ($shift['start'] < $start_time) {
- $start_time = $shift['start'];
- }
+
+ /**
+ * @return int
+ */
+ private function calcBlocksPerSlot()
+ {
+ return ceil(($this->getLastBlockEndTime() - $this->getFirstBlockStartTime()) / ShiftCalendarRenderer::SECONDS_PER_ROW);
}
- return ShiftCalendarRenderer::SECONDS_PER_ROW * floor(($start_time - ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW);
- }
-
- private function calcLastBlockEndTime($shifts) {
- $end_time = $this->shiftsFilter->getStartTime();
- foreach ($shifts as $shift) {
- if ($shift['end'] > $end_time) {
- $end_time = $shift['end'];
- }
+
+ /**
+ * Renders a legend explaining the shift coloring
+ *
+ * @return string
+ */
+ private function renderLegend()
+ {
+ return div('legend', [
+ label(_('Your shift'), 'primary'),
+ label(_('Help needed'), 'danger'),
+ label(_('Other angeltype needed / collides with my shifts'), 'warning'),
+ label(_('Shift is full'), 'success'),
+ label(_('Shift running/ended'), 'default')
+ ]);
}
- return ShiftCalendarRenderer::SECONDS_PER_ROW * ceil(($end_time + ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW);
- }
-
- private function calcBlocksPerSlot() {
- return ceil(($this->getLastBlockEndTime() - $this->getFirstBlockStartTime()) / ShiftCalendarRenderer::SECONDS_PER_ROW);
- }
-
- /**
- * Renders a legend explaining the shift coloring
- */
- private function renderLegend() {
- return div('legend', [
- label(_('Your shift'), 'primary'),
- label(_('Help needed'), 'danger'),
- label(_('Other angeltype needed / collides with my shifts'), 'warning'),
- label(_('Shift is full'), 'success'),
- label(_('Shift running/ended'), 'default')
- ]);
- }
}
-
-?> \ No newline at end of file
diff --git a/includes/view/ShiftCalendarShiftRenderer.php b/includes/view/ShiftCalendarShiftRenderer.php
index fdfefcc2..3e59d61a 100644
--- a/includes/view/ShiftCalendarShiftRenderer.php
+++ b/includes/view/ShiftCalendarShiftRenderer.php
@@ -5,191 +5,247 @@ namespace Engelsystem;
/**
* Renders a single shift for the shift calendar
*/
-class ShiftCalendarShiftRenderer {
-
- /**
- * Renders a shift
- *
- * @param Shift $shift
- * The shift to render
- * @param User $user
- * The user who is viewing the shift calendar
- */
- public function render($shift, $needed_angeltypes, $shift_entries, $user) {
- $info_text = "";
- if ($shift['title'] != '') {
- $info_text = glyph('info-sign') . $shift['title'] . '<br>';
- }
- list($shift_signup_state, $shifts_row) = $this->renderShiftNeededAngeltypes($shift, $needed_angeltypes, $shift_entries, $user);
-
- $class = $this->classForSignupState($shift_signup_state);
-
- $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"', [
- $this->renderShiftHead($shift),
- div('panel-body', [
- $info_text,
- Room_name_render([
- 'RID' => $shift['RID'],
- 'Name' => $shift['room_name']
- ])
- ]),
- $shifts_row,
- div('shift-spacer')
- ])
- ];
- }
-
- private function classForSignupState(ShiftSignupState $shiftSignupState) {
- switch ($shiftSignupState->getState()) {
- case ShiftSignupState::ADMIN:
- case ShiftSignupState::OCCUPIED:
- return 'success';
-
- case ShiftSignupState::SIGNED_UP:
- return 'primary';
-
- case ShiftSignupState::SHIFT_ENDED:
- return 'default';
-
- case ShiftSignupState::ANGELTYPE:
- case ShiftSignupState::COLLIDES:
- return 'warning';
-
- case ShiftSignupState::FREE:
- return 'danger';
- }
- }
-
- private function renderShiftNeededAngeltypes($shift, $needed_angeltypes, $shift_entries, $user) {
- global $privileges;
-
- $shift_entries_filtered = [];
- foreach ($needed_angeltypes as $needed_angeltype) {
- $shift_entries_filtered[$needed_angeltype['id']] = [];
+class ShiftCalendarShiftRenderer
+{
+ /**
+ * Renders a shift
+ *
+ * @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
+ * @return array
+ */
+ public function render($shift, $needed_angeltypes, $shift_entries, $user)
+ {
+ $info_text = '';
+ if ($shift['title'] != '') {
+ $info_text = glyph('info-sign') . $shift['title'] . '<br>';
+ }
+ list($shift_signup_state, $shifts_row) = $this->renderShiftNeededAngeltypes(
+ $shift,
+ $needed_angeltypes,
+ $shift_entries,
+ $user
+ );
+
+ $class = $this->classForSignupState($shift_signup_state);
+
+ $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"',
+ [
+ $this->renderShiftHead($shift),
+ div('panel-body', [
+ $info_text,
+ Room_name_render([
+ 'RID' => $shift['RID'],
+ 'Name' => $shift['room_name']
+ ])
+ ]),
+ $shifts_row,
+ div('shift-spacer')
+ ]
+ )
+ ];
}
- foreach ($shift_entries as $shift_entry) {
- $shift_entries_filtered[$shift_entry['TID']][] = $shift_entry;
+
+ /**
+ * @param ShiftSignupState $shiftSignupState
+ * @return string
+ */
+ private function classForSignupState(ShiftSignupState $shiftSignupState)
+ {
+ switch ($shiftSignupState->getState()) {
+ case ShiftSignupState::ADMIN:
+ case ShiftSignupState::OCCUPIED:
+ return 'success';
+
+ case ShiftSignupState::SIGNED_UP:
+ return 'primary';
+
+ case ShiftSignupState::SHIFT_ENDED:
+ return 'default';
+
+ case ShiftSignupState::ANGELTYPE:
+ case ShiftSignupState::COLLIDES:
+ return 'warning';
+
+ case ShiftSignupState::FREE:
+ return 'danger';
+ default:
+ return '';
+ }
}
-
- $html = "";
- $shift_signup_state = null;
- foreach ($needed_angeltypes as $angeltype) {
- if ($angeltype['count'] > 0 || count($shift_entries_filtered[$angeltype['id']]) > 0) {
- list($angeltype_signup_state, $angeltype_html) = $this->renderShiftNeededAngeltype($shift, $shift_entries_filtered[$angeltype['id']], $angeltype, $user);
+
+ /**
+ * @param array $shift
+ * @param array[] $needed_angeltypes
+ * @param array[] $shift_entries
+ * @param array $user
+ * @return array
+ */
+ private function renderShiftNeededAngeltypes($shift, $needed_angeltypes, $shift_entries, $user)
+ {
+ global $privileges;
+
+ $shift_entries_filtered = [];
+ foreach ($needed_angeltypes as $needed_angeltype) {
+ $shift_entries_filtered[$needed_angeltype['id']] = [];
+ }
+ foreach ($shift_entries as $shift_entry) {
+ $shift_entries_filtered[$shift_entry['TID']][] = $shift_entry;
+ }
+
+ $html = '';
+ /** @var ShiftSignupState $shift_signup_state */
+ $shift_signup_state = null;
+ foreach ($needed_angeltypes as $angeltype) {
+ if ($angeltype['count'] > 0 || count($shift_entries_filtered[$angeltype['id']]) > 0) {
+ list($angeltype_signup_state, $angeltype_html) = $this->renderShiftNeededAngeltype(
+ $shift,
+ $shift_entries_filtered[$angeltype['id']],
+ $angeltype,
+ $user
+ );
+ if ($shift_signup_state == null) {
+ $shift_signup_state = $angeltype_signup_state;
+ } else {
+ $shift_signup_state->combineWith($angeltype_signup_state);
+ }
+ $html .= $angeltype_html;
+ }
+ }
if ($shift_signup_state == null) {
- $shift_signup_state = $angeltype_signup_state;
- } else {
- $shift_signup_state->combineWith($angeltype_signup_state);
+ $shift_signup_state = new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, 0);
}
- $html .= $angeltype_html;
- }
- }
- if ($shift_signup_state == null) {
- $shift_signup_state = new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, 0);
- }
-
- if (in_array('user_shifts_admin', $privileges)) {
- $html .= '<li class="list-group-item">' . button(page_link_to('user_shifts') . '&amp;shift_id=' . $shift['SID'], _("Add more angels"), 'btn-xs') . '</li>';
- }
- if ($html != '') {
- return [
- $shift_signup_state,
- '<ul class="list-group">' . $html . '</ul>'
- ];
- }
- return [
- $shift_signup_state,
- ""
- ];
- }
-
- /**
- * Renders a list entry containing the needed angels for an angeltype
- *
- * @param Shift $shift
- * The shift which is rendered
- * @param Angeltype $angeltype
- * The angeltype, containing informations about needed angeltypes and already signed up angels
- * @param User $user
- * The user who is viewing the shift calendar
- */
- private function renderShiftNeededAngeltype($shift, $shift_entries, $angeltype, $user) {
- $entry_list = [];
- foreach ($shift_entries as $entry) {
- $style = $entry['freeloaded'] ? " text-decoration: line-through;" : '';
- $entry_list[] = "<span style=\"$style\">" . User_Nick_render($entry) . "</span>";
+
+ if (in_array('user_shifts_admin', $privileges)) {
+ $html .= '<li class="list-group-item">';
+ $html .= button(
+ page_link_to('user_shifts', ['shift_id' => $shift['SID']]),
+ glyph('plus') . _('Add more angels'),
+ 'btn-xs'
+ );
+ $html .= '</li>';
+ }
+ if ($html != '') {
+ return [
+ $shift_signup_state,
+ '<ul class="list-group">' . $html . '</ul>'
+ ];
+ }
+ return [
+ $shift_signup_state,
+ ''
+ ];
}
- $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());
- switch ($shift_signup_state->getState()) {
- case ShiftSignupState::ADMIN:
- case ShiftSignupState::FREE:
- // When admin or free display a link + button for sign up
- $entry_list[] = '<a href="' . page_link_to('user_shifts') . '&amp;shift_id=' . $shift['SID'] . '&amp;type_id=' . $angeltype['id'] . '">' . $inner_text . '</a> ' . button(page_link_to('user_shifts') . '&amp;shift_id=' . $shift['SID'] . '&amp;type_id=' . $angeltype['id'], _('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::ANGELTYPE:
- if ($angeltype['restricted'] == 1) {
- // User has to be confirmed on the angeltype first
- $entry_list[] = $inner_text . glyph('lock');
- } else {
- // Add link to join the angeltype first
- $entry_list[] = $inner_text . '<br />' . button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], sprintf(_('Become %s'), $angeltype['name']), 'btn-xs');
+
+ /**
+ * Renders a list entry containing the needed angels for an angeltype
+ *
+ * @param array $shift The shift which is rendered
+ * @param array[] $shift_entries
+ * @param array[] $angeltype The angeltype, containing informations about needed angeltypes
+ * and already signed up angels
+ * @param array $user The user who is viewing the shift calendar
+ * @return array
+ */
+ private function renderShiftNeededAngeltype($shift, $shift_entries, $angeltype, $user)
+ {
+ $entry_list = [];
+ foreach ($shift_entries as $entry) {
+ $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);
+ $inner_text = sprintf(
+ ngettext('%d helper needed', '%d helpers needed', $shift_signup_state->getFreeEntries()),
+ $shift_signup_state->getFreeEntries()
+ );
+
+ switch ($shift_signup_state->getState()) {
+ case ShiftSignupState::ADMIN:
+ case ShiftSignupState::FREE:
+ // When admin or free display a link + button for sign up
+ $entry_list[] = '<a href="'
+ . page_link_to('user_shifts', ['shift_id' => $shift['SID'], 'type_id' => $angeltype['id']])
+ . '">'
+ . $inner_text
+ . '</a> '
+ . button(
+ page_link_to('user_shifts', ['shift_id' => $shift['SID'], 'type_id' => $angeltype['id']]),
+ _('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::ANGELTYPE:
+ if ($angeltype['restricted'] == 1) {
+ // User has to be confirmed on the angeltype first
+ $entry_list[] = $inner_text . glyph('lock');
+ } else {
+ // Add link to join the angeltype first
+ $entry_list[] = $inner_text . '<br />'
+ . button(
+ page_link_to('user_angeltypes', ['action' => 'add', 'angeltype_id' => $angeltype['id']]),
+ sprintf(_('Become %s'), $angeltype['name']),
+ 'btn-xs'
+ );
+ }
+ break;
+
+ case ShiftSignupState::COLLIDES:
+ case ShiftSignupState::SIGNED_UP:
+ // Shift collides or user is already signed up: No signup allowed
+ $entry_list[] = $inner_text;
+ break;
+
+ case ShiftSignupState::OCCUPIED:
+ // Shift is full
+ break;
}
- break;
-
- case ShiftSignupState::COLLIDES:
- case ShiftSignupState::SIGNED_UP:
- // Shift collides or user is already signed up: No signup allowed
- $entry_list[] = $inner_text;
- break;
-
- case ShiftSignupState::OCCUPIED:
- // Shift is full
- break;
+
+ $shifts_row = '<li class="list-group-item">';
+ $shifts_row .= '<strong>' . AngelType_name_render($angeltype) . ':</strong> ';
+ $shifts_row .= join(', ', $entry_list);
+ $shifts_row .= '</li>';
+ return [
+ $shift_signup_state,
+ $shifts_row
+ ];
}
-
- $shifts_row = '<li class="list-group-item">';
- $shifts_row .= '<strong>' . AngelType_name_render($angeltype) . ':</strong> ';
- $shifts_row .= join(", ", $entry_list);
- $shifts_row .= '</li>';
- return [
- $shift_signup_state,
- $shifts_row
- ];
- }
-
- /**
- * Renders the shift header
- *
- * @param Shift $shift
- * The shift
- */
- private function renderShiftHead($shift) {
- global $privileges;
-
- $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')
- ]) . '</div>';
+
+ /**
+ * Renders the shift header
+ *
+ * @param array $shift The shift
+ * @return string
+ */
+ private function renderShiftHead($shift)
+ {
+ global $privileges;
+
+ $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')
+ ]) . '</div>';
+ }
+ $shift_heading = date('H:i', $shift['start']) . ' &dash; '
+ . date('H:i', $shift['end']) . ' &mdash; '
+ . $shift['name'];
+ return div('panel-heading', [
+ '<a href="' . shift_link($shift) . '">' . $shift_heading . '</a>',
+ $header_buttons
+ ]);
}
- $shift_heading = date('H:i', $shift['start']) . ' &dash; ' . date('H:i', $shift['end']) . ' &mdash; ' . $shift['name'];
- return div('panel-heading', [
- '<a href="' . shift_link($shift) . '">' . $shift_heading . '</a>',
- $header_buttons
- ]);
- }
}
-
-?> \ No newline at end of file
diff --git a/includes/view/ShiftEntry_view.php b/includes/view/ShiftEntry_view.php
index 5bf10a91..2e638df6 100644
--- a/includes/view/ShiftEntry_view.php
+++ b/includes/view/ShiftEntry_view.php
@@ -2,36 +2,47 @@
/**
* 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
* @return string
*/
-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)
- ];
- }
- return page_with_title(_("Edit shift entry"), [
- msg(),
- form([
- form_info(_("Angel:"), $angel),
- form_info(_("Date, Duration:"), $date),
- form_info(_("Location:"), $location),
- form_info(_("Title:"), $title),
- form_info(_("Type:"), $type),
- form_textarea('comment', _("Comment (for your eyes only):"), $comment),
- join("", $freeload_form),
- form_submit('submit', _("Save"))
- ])
- ]);
+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)
+ ];
+ }
+ return page_with_title(_('Edit shift entry'), [
+ msg(),
+ form([
+ form_info(_('Angel:'), $angel),
+ form_info(_('Date, Duration:'), $date),
+ form_info(_('Location:'), $location),
+ form_info(_('Title:'), $title),
+ form_info(_('Type:'), $type),
+ form_textarea('comment', _('Comment (for your eyes only):'), $comment),
+ join('', $freeload_form),
+ form_submit('submit', _('Save'))
+ ])
+ ]);
}
-
-?> \ No newline at end of file
diff --git a/includes/view/ShiftTypes_view.php b/includes/view/ShiftTypes_view.php
index 3e4cccc6..74e0d7c0 100644
--- a/includes/view/ShiftTypes_view.php
+++ b/includes/view/ShiftTypes_view.php
@@ -1,84 +1,145 @@
<?php
-function ShiftType_name_render($shifttype) {
- global $privileges;
- if (in_array('shifttypes', $privileges)) {
- return '<a href="' . shifttype_link($shifttype) . '">' . $shifttype['name'] . '</a>';
- }
- return $shifttype['name'];
+/**
+ * @param array $shifttype
+ * @return string
+ */
+function ShiftType_name_render($shifttype)
+{
+ global $privileges;
+ if (in_array('shifttypes', $privileges)) {
+ return '<a href="' . shifttype_link($shifttype) . '">' . $shifttype['name'] . '</a>';
+ }
+ return $shifttype['name'];
}
-function ShiftType_delete_view($shifttype) {
- return page_with_title(sprintf(_("Delete shifttype %s"), $shifttype['name']), [
- info(sprintf(_("Do you want to delete shifttype %s?"), $shifttype['name']), true),
- buttons([
- button(page_link_to('shifttypes'), _("cancel"), 'cancel'),
- button(page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'] . '&confirmed', _("delete"), 'ok')
- ])
- ]);
+/**
+ * @param array $shifttype
+ * @return string
+ */
+function ShiftType_delete_view($shifttype)
+{
+ return page_with_title(sprintf(_('Delete shifttype %s'), $shifttype['name']), [
+ info(sprintf(_('Do you want to delete shifttype %s?'), $shifttype['name']), true),
+ buttons([
+ button(page_link_to('shifttypes'), _('cancel'), 'cancel'),
+ button(
+ page_link_to(
+ 'shifttypes',
+ ['action' => 'delete', 'shifttype_id' => $shifttype['id'], 'confirmed' => 1]
+ ),
+ _('delete'),
+ 'ok btn-danger'
+ )
+ ])
+ ]);
}
-function ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id) {
- $angeltypes_select = [
- '' => _('All')
- ];
- foreach ($angeltypes as $angeltype) {
- $angeltypes_select[$angeltype['id']] = $angeltype['name'];
- }
-
- return page_with_title($shifttype_id ? _('Edit shifttype') : _('Create shifttype'), [
- msg(),
- buttons([
- button(page_link_to('shifttypes'), shifttypes_title(), 'back')
- ]),
- form([
- form_text('name', _('Name'), $name),
- form_select('angeltype_id', _('Angeltype'), $angeltypes_select, $angeltype_id),
- form_textarea('description', _('Description'), $description),
- form_info('', _('Please use markdown for the description.')),
- form_submit('submit', _('Save'))
- ])
- ]);
-}
+/**
+ * @param string $name
+ * @param int $angeltype_id
+ * @param array[] $angeltypes
+ * @param string $description
+ * @param int|bool $shifttype_id
+ * @return string
+ */
+function ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id)
+{
+ $angeltypes_select = [
+ '' => _('All')
+ ];
+ foreach ($angeltypes as $angeltype) {
+ $angeltypes_select[$angeltype['id']] = $angeltype['name'];
+ }
-function ShiftType_view($shifttype, $angeltype) {
- $parsedown = new Parsedown();
- $title = $shifttype['name'];
- if ($angeltype) {
- $title .= ' <small>' . sprintf(_('for team %s'), $angeltype['name']) . '</small>';
- }
- return page_with_title($title, [
- msg(),
- buttons([
- button(page_link_to('shifttypes'), shifttypes_title(), 'back'),
- $angeltype ? button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], $angeltype['name']) : '',
- button(page_link_to('shifttypes') . '&action=edit&shifttype_id=' . $shifttype['id'], _('edit'), 'edit'),
- button(page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'], _('delete'), 'delete')
- ]),
- heading(_("Description"), 2),
- $parsedown->parse($shifttype['description'])
- ]);
+ return page_with_title($shifttype_id ? _('Edit shifttype') : _('Create shifttype'), [
+ msg(),
+ buttons([
+ button(page_link_to('shifttypes'), shifttypes_title(), 'back')
+ ]),
+ form([
+ form_text('name', _('Name'), $name),
+ form_select('angeltype_id', _('Angeltype'), $angeltypes_select, $angeltype_id),
+ form_textarea('description', _('Description'), $description),
+ form_info('', _('Please use markdown for the description.')),
+ form_submit('submit', _('Save'))
+ ])
+ ]);
}
-function ShiftTypes_list_view($shifttypes) {
- foreach ($shifttypes as &$shifttype) {
- $shifttype['name'] = '<a href="' . page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype['id'] . '">' . $shifttype['name'] . '</a>';
- $shifttype['actions'] = table_buttons([
- button(page_link_to('shifttypes') . '&action=edit&shifttype_id=' . $shifttype['id'], _('edit'), 'btn-xs'),
- button(page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'], _('delete'), 'btn-xs')
+/**
+ * @param array $shifttype
+ * @param array $angeltype
+ * @return string
+ */
+function ShiftType_view($shifttype, $angeltype)
+{
+ $parsedown = new Parsedown();
+ $title = $shifttype['name'];
+ if ($angeltype) {
+ $title .= ' <small>' . sprintf(_('for team %s'), $angeltype['name']) . '</small>';
+ }
+ return page_with_title($title, [
+ msg(),
+ buttons([
+ button(page_link_to('shifttypes'), shifttypes_title(), 'back'),
+ $angeltype ? button(
+ page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
+ $angeltype['name']
+ ) : '',
+ button(
+ page_link_to('shifttypes', ['action' => 'edit', 'shifttype_id' => $shifttype['id']]),
+ _('edit'),
+ 'edit'
+ ),
+ button(
+ page_link_to('shifttypes', ['action' => 'delete', 'shifttype_id' => $shifttype['id']]),
+ _('delete'),
+ 'delete'
+ )
+ ]),
+ heading(_('Description'), 2),
+ $parsedown->parse($shifttype['description'])
]);
- }
-
- return page_with_title(shifttypes_title(), [
- msg(),
- buttons([
- button(page_link_to('shifttypes') . '&action=edit', _('New shifttype'), 'add')
- ]),
- table([
- 'name' => _('Name'),
- 'actions' => ''
- ], $shifttypes)
- ]);
}
-?> \ No newline at end of file
+/**
+ * @param array[] $shifttypes
+ * @return string
+ */
+function ShiftTypes_list_view($shifttypes)
+{
+ foreach ($shifttypes as &$shifttype) {
+ $shifttype['name'] = '<a href="'
+ . page_link_to('shifttypes', ['action' => 'view', 'shifttype_id' => $shifttype['id']])
+ . '">'
+ . $shifttype['name']
+ . '</a>';
+ $shifttype['actions'] = table_buttons([
+ button(
+ page_link_to(
+ 'shifttypes',
+ ['action' => 'edit', 'shifttype_id' => $shifttype['id']]
+ ),
+ _('edit'),
+ 'btn-xs'
+ ),
+ button(
+ page_link_to('shifttypes', ['action' => 'delete', 'shifttype_id' => $shifttype['id']]),
+ _('delete'),
+ 'btn-xs'
+ )
+ ]);
+ }
+
+ return page_with_title(shifttypes_title(), [
+ msg(),
+ buttons([
+ button(page_link_to('shifttypes', ['action' => 'edit']), _('New shifttype'), 'add')
+ ]),
+ table([
+ 'name' => _('Name'),
+ 'actions' => ''
+ ], $shifttypes)
+ ]);
+}
diff --git a/includes/view/ShiftsFilterRenderer.php b/includes/view/ShiftsFilterRenderer.php
index 301f31a2..c3e0ccf1 100644
--- a/includes/view/ShiftsFilterRenderer.php
+++ b/includes/view/ShiftsFilterRenderer.php
@@ -2,68 +2,85 @@
namespace Engelsystem;
-class ShiftsFilterRenderer {
+class ShiftsFilterRenderer
+{
+ /**
+ * The shiftFilter to render.
+ *
+ * @var ShiftsFilter
+ */
+ private $shiftsFilter;
- /**
- * The shiftFilter to render.
- *
- * @var ShiftsFilter
- */
- private $shiftsFilter;
+ /**
+ * Should the filter display a day selection.
+ *
+ * @var boolean
+ */
+ private $daySelectionEnabled = false;
- /**
- * Should the filter display a day selection.
- *
- * @var boolean
- */
- private $daySelectionEnabled = false;
+ /**
+ * Days that can be selected.
+ * Format Y-m-d
+ *
+ * @var string[]
+ */
+ private $days = [];
- /**
- * Days that can be selected.
- * Format Y-m-d
- *
- * @var string[]
- */
- private $days = [];
-
- public function __construct(ShiftsFilter $shiftsFilter) {
- $this->shiftsFilter = $shiftsFilter;
- }
+ /**
+ * ShiftsFilterRenderer constructor.
+ *
+ * @param ShiftsFilter $shiftsFilter
+ */
+ public function __construct(ShiftsFilter $shiftsFilter)
+ {
+ $this->shiftsFilter = $shiftsFilter;
+ }
- /**
- * Renders the filter.
- *
- * @return Generated HTML
- */
- public function render($link_base) {
- $toolbar = [];
- if ($this->daySelectionEnabled && ! empty($this->days)) {
- $selected_day = date("Y-m-d", $this->shiftsFilter->getStartTime());
- $day_dropdown_items = [];
- foreach ($this->days as $day) {
- $day_dropdown_items[] = toolbar_item_link($link_base . '&shifts_filter_day=' . $day, '', $day);
- }
- $toolbar[] = toolbar_dropdown('', $selected_day, $day_dropdown_items, 'active');
+ /**
+ * Renders the filter.
+ *
+ * @param array $room
+ * @return string Generated HTML
+ */
+ public function render($room)
+ {
+ $toolbar = [];
+ if ($this->daySelectionEnabled && !empty($this->days)) {
+ $selected_day = date('Y-m-d', $this->shiftsFilter->getStartTime());
+ $day_dropdown_items = [];
+ foreach ($this->days as $day) {
+ $link = page_link_to('rooms', [
+ 'action' => 'view',
+ 'room_id' => $room['RID'],
+ 'shifts_filter_day' => $day,
+ ]);
+ $day_dropdown_items[] = toolbar_item_link($link, '', $day);
+ }
+ $toolbar[] = toolbar_dropdown('', $selected_day, $day_dropdown_items, 'active');
+ }
+ return div('form-group', [
+ toolbar_pills($toolbar)
+ ]);
}
- return div('form-group', [
- toolbar_pills($toolbar)
- ]);
- }
- /**
- * Should the filter display a day selection.
- */
- public function enableDaySelection($days) {
- $this->daySelectionEnabled = true;
- $this->days = $days;
- }
+ /**
+ * Should the filter display a day selection.
+ *
+ * @param string[] $days
+ */
+ public function enableDaySelection($days)
+ {
+ $this->daySelectionEnabled = true;
+ $this->days = $days;
+ }
- /**
- * Should the filter display a day selection.
- */
- public function isDaySelectionEnabled() {
- return $this->daySelectionEnabled;
- }
+ /**
+ * Should the filter display a day selection.
+ *
+ * @return bool
+ */
+ public function isDaySelectionEnabled()
+ {
+ return $this->daySelectionEnabled;
+ }
}
-
-?> \ No newline at end of file
diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php
index 765a6f3b..bc905f39 100644
--- a/includes/view/Shifts_view.php
+++ b/includes/view/Shifts_view.php
@@ -1,163 +1,233 @@
<?php
+
use Engelsystem\ShiftSignupState;
-function Shift_editor_info_render($shift) {
- $info = [];
- if ($shift['created_by_user_id'] != null) {
- $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'])));
- }
- if ($shift['edited_by_user_id'] != null) {
- $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'])));
- }
- return join('<br />', $info);
+/**
+ * @param array $shift
+ * @return string
+ */
+function Shift_editor_info_render($shift)
+{
+ $info = [];
+ if ($shift['created_by_user_id'] != null) {
+ $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']))
+ );
+ }
+ if ($shift['edited_by_user_id'] != null) {
+ $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']))
+ );
+ }
+ return join('<br />', $info);
}
-function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null) {
- global $user;
-
- if ($user_angeltype == null) {
- $user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
- }
-
- if ($angeltype['shift_signup_state']->isSignupAllowed()) {
- return button(page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'], _('Sign up'));
- } elseif ($user_angeltype == null) {
- return button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], sprintf(_('Become %s'), $angeltype['name']));
- }
- return '';
+/**
+ * @param array $shift
+ * @param array $angeltype
+ * @param array $user_angeltype
+ * @return string
+ */
+function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
+{
+ global $user;
+
+ if ($user_angeltype == null) {
+ $user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
+ }
+
+ if ($angeltype['shift_signup_state']->isSignupAllowed()) {
+ return button(
+ page_link_to('user_shifts', ['shift_id' => $shift['SID'], 'type_id' => $angeltype['id']]),
+ _('Sign up')
+ );
+ } elseif ($user_angeltype == null) {
+ return button(
+ page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
+ sprintf(_('Become %s'),
+ $angeltype['name'])
+ );
+ }
+ return '';
}
-function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupState $shift_signup_state) {
- global $privileges;
-
- $shift_admin = in_array('admin_shifts', $privileges);
- $user_shift_admin = in_array('user_shifts_admin', $privileges);
- $admin_rooms = in_array('admin_rooms', $privileges);
- $admin_shifttypes = in_array('shifttypes', $privileges);
-
- $parsedown = new Parsedown();
-
- $angeltypes = [];
- foreach ($angeltypes_source as $angeltype) {
- $angeltypes[$angeltype['id']] = $angeltype;
- }
-
- $needed_angels = '';
- foreach ($shift['NeedAngels'] as $needed_angeltype) {
- $needed_angels .= Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shift, $user_shift_admin);
- }
-
- return page_with_title($shift['name'] . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>', [
- msg(),
- $shift_signup_state->getState() == ShiftSignupState::COLLIDES ? info(_('This shift collides with one of your shifts.'), true) : '',
- $shift_signup_state->getState() == ShiftSignupState::SIGNED_UP ? info(_('You are signed up for this shift.'), true) : '',
- ($shift_admin || $admin_shifttypes || $admin_rooms) ? buttons([
- $shift_admin ? button(shift_edit_link($shift), glyph('pencil') . _('edit')) : '',
- $shift_admin ? button(shift_delete_link($shift), glyph('trash') . _('delete')) : '',
- $admin_shifttypes ? button(shifttype_link($shifttype), $shifttype['name']) : '',
- $admin_rooms ? button(room_link($room), glyph('map-marker') . $room['Name']) : ''
- ]) : '',
- 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>'
- ]),
- div('col-sm-3 col-xs-6', [
- '<h4>' . _('Start') . '</h4>',
- '<p class="lead' . (time() >= $shift['start'] ? ' text-success' : '') . '">',
- glyph('calendar') . date(_('Y-m-d'), $shift['start']),
- '<br />',
- glyph('time') . date('H:i', $shift['start']),
- '</p>'
- ]),
- div('col-sm-3 col-xs-6', [
- '<h4>' . _('End') . '</h4>',
- '<p class="lead' . (time() >= $shift['end'] ? ' text-success' : '') . '">',
- glyph('calendar') . date(_('Y-m-d'), $shift['end']),
- '<br />',
- glyph('time') . date('H:i', $shift['end']),
- '</p>'
- ]),
- div('col-sm-3 col-xs-6', [
- '<h4>' . _('Location') . '</h4>',
- '<p class="lead">' . Room_name_render($room) . '</p>'
- ])
- ]),
- div('row', [
- div('col-sm-6', [
- '<h2>' . _('Needed angels') . '</h2>',
- '<div class="list-group">' . $needed_angels . '</div>'
- ]),
- div('col-sm-6', [
- '<h2>' . _('Description') . '</h2>',
- $parsedown->parse($shifttype['description'])
- ])
- ]),
- $shift_admin ? Shift_editor_info_render($shift) : ''
- ]);
+/**
+ * @param array $shift
+ * @param array $shifttype
+ * @param array $room
+ * @param array[] $angeltypes_source
+ * @param ShiftSignupState $shift_signup_state
+ * @return string
+ */
+function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupState $shift_signup_state)
+{
+ global $privileges;
+
+ $shift_admin = in_array('admin_shifts', $privileges);
+ $user_shift_admin = in_array('user_shifts_admin', $privileges);
+ $admin_rooms = in_array('admin_rooms', $privileges);
+ $admin_shifttypes = in_array('shifttypes', $privileges);
+
+ $parsedown = new Parsedown();
+
+ $angeltypes = [];
+ foreach ($angeltypes_source as $angeltype) {
+ $angeltypes[$angeltype['id']] = $angeltype;
+ }
+
+ $needed_angels = '';
+ foreach ($shift['NeedAngels'] as $needed_angeltype) {
+ $needed_angels .= Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shift, $user_shift_admin);
+ }
+
+ return page_with_title(
+ $shift['name'] . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>',
+ [
+ msg(),
+ $shift_signup_state->getState() == ShiftSignupState::COLLIDES
+ ? info(_('This shift collides with one of your shifts.'), true)
+ : '',
+ $shift_signup_state->getState() == ShiftSignupState::SIGNED_UP
+ ? info(_('You are signed up for this shift.'), true)
+ : '',
+ ($shift_admin || $admin_shifttypes || $admin_rooms) ? buttons([
+ $shift_admin ? button(shift_edit_link($shift), glyph('pencil') . _('edit')) : '',
+ $shift_admin ? button(shift_delete_link($shift), glyph('trash') . _('delete')) : '',
+ $admin_shifttypes ? button(shifttype_link($shifttype), $shifttype['name']) : '',
+ $admin_rooms ? button(room_link($room), glyph('map-marker') . $room['Name']) : ''
+ ]) : '',
+ 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>'
+ ]),
+ div('col-sm-3 col-xs-6', [
+ '<h4>' . _('Start') . '</h4>',
+ '<p class="lead' . (time() >= $shift['start'] ? ' text-success' : '') . '">',
+ glyph('calendar') . date(_('Y-m-d'), $shift['start']),
+ '<br />',
+ glyph('time') . date('H:i', $shift['start']),
+ '</p>'
+ ]),
+ div('col-sm-3 col-xs-6', [
+ '<h4>' . _('End') . '</h4>',
+ '<p class="lead' . (time() >= $shift['end'] ? ' text-success' : '') . '">',
+ glyph('calendar') . date(_('Y-m-d'), $shift['end']),
+ '<br />',
+ glyph('time') . date('H:i', $shift['end']),
+ '</p>'
+ ]),
+ div('col-sm-3 col-xs-6', [
+ '<h4>' . _('Location') . '</h4>',
+ '<p class="lead">' . Room_name_render($room) . '</p>'
+ ])
+ ]),
+ div('row', [
+ div('col-sm-6', [
+ '<h2>' . _('Needed angels') . '</h2>',
+ '<div class="list-group">' . $needed_angels . '</div>'
+ ]),
+ div('col-sm-6', [
+ '<h2>' . _('Description') . '</h2>',
+ $parsedown->parse($shifttype['description'])
+ ])
+ ]),
+ $shift_admin ? Shift_editor_info_render($shift) : ''
+ ]
+ );
}
-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);
-
- $needed_angels = '';
-
- $class = 'progress-bar-warning';
- if ($needed_angeltype['taken'] == 0) {
- $class = 'progress-bar-danger';
- }
- if ($needed_angeltype['taken'] >= $needed_angeltype['count']) {
- $class = 'progress-bar-success';
- }
- $needed_angels .= '<div class="list-group-item">';
-
- $needed_angels .= '<div class="pull-right">' . Shift_signup_button_render($shift, $angeltype) . '</div>';
-
- $needed_angels .= '<h3>' . AngelType_name_render($angeltype) . '</h3>';
- $bar_max = max($needed_angeltype['count'] * 10, $needed_angeltype['taken'] * 10, 10);
- $bar_value = max(1, $needed_angeltype['taken'] * 10);
- $needed_angels .= progress_bar(0, $bar_max, $bar_value, $class, $needed_angeltype['taken'] . ' / ' . $needed_angeltype['count']);
-
- $angels = [];
- foreach ($shift['ShiftEntry'] as $shift_entry) {
- if ($shift_entry['TID'] == $needed_angeltype['TID']) {
- $angels[] = Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angeltype_supporter);
+/**
+ * @param array $needed_angeltype
+ * @param array $angeltypes
+ * @param array[] $shift
+ * @param bool $user_shift_admin
+ * @return string
+ */
+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);
+
+ $needed_angels = '';
+
+ $class = 'progress-bar-warning';
+ if ($needed_angeltype['taken'] == 0) {
+ $class = 'progress-bar-danger';
}
- }
-
- $needed_angels .= join(', ', $angels);
- $needed_angels .= '</div>';
-
- return $needed_angels;
+ if ($needed_angeltype['taken'] >= $needed_angeltype['count']) {
+ $class = 'progress-bar-success';
+ }
+ $needed_angels .= '<div class="list-group-item">';
+
+ $needed_angels .= '<div class="pull-right">' . Shift_signup_button_render($shift, $angeltype) . '</div>';
+
+ $needed_angels .= '<h3>' . AngelType_name_render($angeltype) . '</h3>';
+ $bar_max = max($needed_angeltype['count'] * 10, $needed_angeltype['taken'] * 10, 10);
+ $bar_value = max(1, $needed_angeltype['taken'] * 10);
+ $needed_angels .= progress_bar(
+ 0,
+ $bar_max,
+ $bar_value,
+ $class,
+ $needed_angeltype['taken'] . ' / ' . $needed_angeltype['count']
+ );
+
+ $angels = [];
+ foreach ($shift['ShiftEntry'] as $shift_entry) {
+ if ($shift_entry['TID'] == $needed_angeltype['TID']) {
+ $angels[] = Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angeltype_supporter);
+ }
+ }
+
+ $needed_angels .= join(', ', $angels);
+ $needed_angels .= '</div>';
+
+ return $needed_angels;
}
-function Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angeltype_supporter) {
- $entry = User_Nick_render(User($shift_entry['UID']));
- if ($shift_entry['freeloaded']) {
- $entry = '<strike>' . $entry . '</strike>';
- }
- if ($user_shift_admin || $angeltype_supporter) {
- $entry .= ' <div class="btn-group">';
- if ($user_shift_admin) {
- $entry .= button_glyph(page_link_to('user_myshifts') . '&edit=' . $shift_entry['id'] . '&id=' . $shift_entry['UID'], 'pencil', 'btn-xs');
+/**
+ * @param array $shift_entry
+ * @param bool $user_shift_admin
+ * @param bool $angeltype_supporter
+ * @return string
+ */
+function Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angeltype_supporter)
+{
+ $entry = User_Nick_render(User($shift_entry['UID']));
+ if ($shift_entry['freeloaded']) {
+ $entry = '<del>' . $entry . '</del>';
+ }
+ if ($user_shift_admin || $angeltype_supporter) {
+ $entry .= ' <div class="btn-group">';
+ if ($user_shift_admin) {
+ $entry .= button_glyph(
+ page_link_to('user_myshifts', ['edit' => $shift_entry['id'], 'id' => $shift_entry['UID']]),
+ 'pencil',
+ 'btn-xs'
+ );
+ }
+ $entry .= button_glyph(page_link_to('user_shifts', ['entry_id' => $shift_entry['id']]), 'trash', 'btn-xs');
+ $entry .= '</div>';
}
- $entry .= button_glyph(page_link_to('user_shifts') . '&entry_id=' . $shift_entry['id'], 'trash', 'btn-xs');
- $entry .= '</div>';
- }
- return $entry;
+ return $entry;
}
/**
* Calc shift length in format 12:23h.
*
- * @param Shift $shift
+ * @param array $shift
+ * @return string
*/
-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";
- return $length;
+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';
+ return $length;
}
-?>
diff --git a/includes/view/UserAngelTypes_view.php b/includes/view/UserAngelTypes_view.php
index da4a2352..98f6c3e9 100644
--- a/includes/view/UserAngelTypes_view.php
+++ b/includes/view/UserAngelTypes_view.php
@@ -1,88 +1,205 @@
<?php
-function UserAngelType_update_view($user_angeltype, $user, $angeltype, $supporter) {
- return page_with_title($supporter ? _("Add supporter rights") : _("Remove supporter rights"), [
- msg(),
- info(sprintf($supporter ? _("Do you really want to add supporter rights for %s to %s?") : _("Do you really want to remove supporter rights for %s from %s?"), $angeltype['name'], User_Nick_render($user)), true),
- buttons([
- button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
- button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $user_angeltype['id'] . '&supporter=' . ($supporter ? '1' : '0') . '&confirmed', _("yes"), 'ok')
- ])
- ]);
+/**
+ * @param array $user_angeltype
+ * @param array $user
+ * @param array $angeltype
+ * @param bool $supporter
+ * @return string
+ */
+function UserAngelType_update_view($user_angeltype, $user, $angeltype, $supporter)
+{
+ return page_with_title($supporter ? _('Add supporter rights') : _('Remove supporter rights'), [
+ msg(),
+ info(sprintf(
+ $supporter
+ ? _('Do you really want to add supporter rights for %s to %s?')
+ : _('Do you really want to remove supporter rights for %s from %s?'),
+ $angeltype['name'],
+ User_Nick_render($user)
+ ), true),
+ buttons([
+ button(
+ page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
+ _('cancel'),
+ 'cancel'
+ ),
+ button(
+ page_link_to('user_angeltypes', [
+ 'action' => 'update',
+ 'user_angeltype_id' => $user_angeltype['id'],
+ 'supporter' => ($supporter ? '1' : '0'),
+ 'confirmed' => 1,
+ ]),
+ _('yes'),
+ 'ok'
+ )
+ ])
+ ]);
}
-function UserAngelTypes_delete_all_view($angeltype) {
- return page_with_title(_("Deny all users"), [
- msg(),
- info(sprintf(_("Do you really want to deny all users for %s?"), $angeltype['name']), true),
- buttons([
- button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
- button(page_link_to('user_angeltypes') . '&action=delete_all&angeltype_id=' . $angeltype['id'] . '&confirmed', _("yes"), 'ok')
- ])
- ]);
+/**
+ * @param array $angeltype
+ * @return string
+ */
+function UserAngelTypes_delete_all_view($angeltype)
+{
+ return page_with_title(_('Deny all users'), [
+ msg(),
+ info(sprintf(_('Do you really want to deny all users for %s?'), $angeltype['name']), true),
+ buttons([
+ button(
+ page_link_to(
+ 'angeltypes',
+ ['action' => 'view', 'angeltype_id' => $angeltype['id']]
+ ),
+ _('cancel'),
+ 'cancel'
+ ),
+ button(
+ page_link_to(
+ 'user_angeltypes',
+ ['action' => 'delete_all', 'angeltype_id' => $angeltype['id'], 'confirmed' => 1]
+ ),
+ _('yes'),
+ 'ok'
+ )
+ ])
+ ]);
}
-function UserAngelTypes_confirm_all_view($angeltype) {
- return page_with_title(_("Confirm all users"), [
- msg(),
- info(sprintf(_("Do you really want to confirm all users for %s?"), $angeltype['name']), true),
- buttons([
- button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
- button(page_link_to('user_angeltypes') . '&action=confirm_all&angeltype_id=' . $angeltype['id'] . '&confirmed', _("yes"), 'ok')
- ])
- ]);
+/**
+ * @param array $angeltype
+ * @return string
+ */
+function UserAngelTypes_confirm_all_view($angeltype)
+{
+ return page_with_title(_('Confirm all users'), [
+ msg(),
+ info(sprintf(_('Do you really want to confirm all users for %s?'), $angeltype['name']), true),
+ buttons([
+ button(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]), _('cancel'),
+ 'cancel'),
+ button(
+ page_link_to('user_angeltypes',
+ ['action' => 'confirm_all', 'angeltype_id' => $angeltype['id'], 'confirmed' => 1]),
+ _('yes'),
+ 'ok'
+ )
+ ])
+ ]);
}
-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),
- buttons([
- button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
- button(page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed', _("yes"), 'ok')
- ])
- ]);
+/**
+ * @param array $user_angeltype
+ * @param array $user
+ * @param array $angeltype
+ * @return string
+ */
+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),
+ buttons([
+ button(
+ page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
+ _('cancel'),
+ 'cancel'
+ ),
+ button(
+ page_link_to(
+ 'user_angeltypes',
+ ['action' => 'confirm', 'user_angeltype_id' => $user_angeltype['id'], 'confirmed' => 1]
+ ),
+ _('yes'),
+ 'ok'
+ )
+ ])
+ ]);
}
-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),
- buttons([
- button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
- button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed', _("yes"), 'ok')
- ])
- ]);
+/**
+ * @param array $user_angeltype
+ * @param array $user
+ * @param array $angeltype
+ * @return string
+ */
+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),
+ buttons([
+ button(
+ page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
+ _('cancel'),
+ 'cancel'
+ ),
+ button(
+ page_link_to('user_angeltypes',
+ ['action' => 'delete', 'user_angeltype_id' => $user_angeltype['id'], 'confirmed' => 1]),
+ _('yes'),
+ 'ok'
+ )
+ ])
+ ]);
}
-function UserAngelType_add_view($angeltype, $users_source, $user_id) {
- $users = [];
- foreach ($users_source as $user_source) {
- $users[$user_source['UID']] = User_Nick_render($user_source);
- }
-
- return page_with_title(_("Add user to angeltype"), [
- msg(),
- buttons([
- button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("back"), 'back')
- ]),
- form([
- form_info(_("Angeltype"), $angeltype['name']),
- form_select('user_id', _("User"), $users, $user_id),
- form_submit('submit', _("Add"))
- ])
- ]);
-}
+/**
+ * @param array $angeltype
+ * @param array[] $users_source
+ * @param int $user_id
+ * @return string
+ */
+function UserAngelType_add_view($angeltype, $users_source, $user_id)
+{
+ $users = [];
+ foreach ($users_source as $user_source) {
+ $users[$user_source['UID']] = User_Nick_render($user_source);
+ }
-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),
- buttons([
- button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
- button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'] . '&user_id=' . $user['UID'] . '&confirmed', _("save"), 'ok')
- ])
- ]);
+ return page_with_title(_('Add user to angeltype'), [
+ msg(),
+ buttons([
+ button(
+ page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
+ _('back'),
+ 'back'
+ )
+ ]),
+ form([
+ form_info(_('Angeltype'), $angeltype['name']),
+ form_select('user_id', _('User'), $users, $user_id),
+ form_submit('submit', _('Add'))
+ ])
+ ]);
}
-?> \ No newline at end of file
+/**
+ * @param array $user
+ * @param array $angeltype
+ * @return string
+ */
+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),
+ buttons([
+ button(
+ page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
+ _('cancel'),
+ 'cancel'
+ ),
+ button(
+ page_link_to(
+ 'user_angeltypes',
+ ['action' => 'add', 'angeltype_id' => $angeltype['id'], 'user_id' => $user['UID'], 'confirmed' => 1]
+ ),
+ _('save'),
+ 'ok'
+ )
+ ])
+ ]);
+}
diff --git a/includes/view/UserDriverLicenses_view.php b/includes/view/UserDriverLicenses_view.php
index 3c0eaf8d..5eacf456 100644
--- a/includes/view/UserDriverLicenses_view.php
+++ b/includes/view/UserDriverLicenses_view.php
@@ -3,45 +3,60 @@
/**
* Edit a user's driving license information.
*
- * @param User $user_source
- * The user
- * @param bool $wants_to_drive
- * true, if the user wants to drive
- * @param UserDriverLicense $user_driver_license
- * The user driver license
+ * @param array $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
*/
-function UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver_license) {
- return page_with_title(sprintf(_("Edit %s driving license information"), User_Nick_render($user_source)), [
- buttons([
- button(user_link($user_source), _("Back to profile"), 'back')
- ]),
- msg(),
- form([
- form_info(_("Privacy"), _("Your driving license information is only visible for supporters and admins.")),
- form_checkbox('wants_to_drive', _("I am willing to drive a car for the event"), $wants_to_drive),
- div('panel panel-default', [
- div('panel-body', [
- form_checkbox('has_car', _("I have my own car with me and am willing to use it for the event (You'll get reimbursed for fuel)"), $user_driver_license['has_car']),
- heading(_("Driver license"), 3),
- form_checkbox('has_license_car', _("Car"), $user_driver_license['has_license_car']),
- form_checkbox('has_license_3_5t_transporter', _("Transporter 3,5t"), $user_driver_license['has_license_3_5t_transporter']),
- form_checkbox('has_license_7_5t_truck', _("Truck 7,5t"), $user_driver_license['has_license_7_5t_truck']),
- form_checkbox('has_license_12_5t_truck', _("Truck 12,5t"), $user_driver_license['has_license_12_5t_truck']),
- form_checkbox('has_license_forklift', _("Forklift"), $user_driver_license['has_license_forklift'])
- ])
- ], 'driving_license'),
- form_submit('submit', _("Save"))
- ]),
- '<script type="text/javascript">
+function UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver_license)
+{
+ return page_with_title(sprintf(_('Edit %s driving license information'), User_Nick_render($user_source)), [
+ buttons([
+ button(user_link($user_source), _('Back to profile'), 'back')
+ ]),
+ msg(),
+ form([
+ form_info(_('Privacy'), _('Your driving license information is only visible for supporters and admins.')),
+ form_checkbox('wants_to_drive', _('I am willing to drive a car for the event'), $wants_to_drive),
+ div('panel panel-default', [
+ div('panel-body', [
+ form_checkbox(
+ 'has_car',
+ _('I have my own car with me and am willing to use it for the event (You\'ll get reimbursed for fuel)'),
+ $user_driver_license['has_car']
+ ),
+ heading(_('Driver license'), 3),
+ form_checkbox('has_license_car', _('Car'), $user_driver_license['has_license_car']),
+ form_checkbox(
+ 'has_license_3_5t_transporter',
+ _('Transporter 3,5t'),
+ $user_driver_license['has_license_3_5t_transporter']
+ ),
+ form_checkbox(
+ 'has_license_7_5t_truck',
+ _('Truck 7,5t'),
+ $user_driver_license['has_license_7_5t_truck']
+ ),
+ form_checkbox(
+ 'has_license_12_5t_truck',
+ _('Truck 12,5t'),
+ $user_driver_license['has_license_12_5t_truck']
+ ),
+ form_checkbox('has_license_forklift', _('Forklift'), $user_driver_license['has_license_forklift'])
+ ])
+ ], 'driving_license'),
+ form_submit('submit', _('Save'))
+ ]),
+ '<script type="text/javascript">
$(function() {
- if($("#wants_to_drive").is(":checked"))
+ var checkbox = $("#wants_to_drive");
+ if(checkbox.is(":checked"))
$("#driving_license").show();
else
$("#driving_license").hide();
-
- $("#wants_to_drive").click(
- function(e) {
+
+ checkbox.click(
+ function() {
if($("#wants_to_drive").is(":checked"))
$("#driving_license").show();
else
@@ -49,8 +64,6 @@ function UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver
}
);
});
- </script>'
- ]);
+ </script>'
+ ]);
}
-
-?> \ No newline at end of file
diff --git a/includes/view/UserHintsRenderer.php b/includes/view/UserHintsRenderer.php
index cf4b1414..aac8ecfd 100644
--- a/includes/view/UserHintsRenderer.php
+++ b/includes/view/UserHintsRenderer.php
@@ -2,58 +2,65 @@
namespace Engelsystem;
-class UserHintsRenderer {
+class UserHintsRenderer
+{
+ /** @var string[] */
+ private $hints = [];
- private $hints = [];
+ private $important = false;
- private $important = false;
+ /**
+ * Render the added hints to a popover for the toolbar.
+ *
+ * @return string
+ */
+ public function render()
+ {
+ if (count($this->hints) > 0) {
+ $hint_class = $this->important ? 'danger' : 'info';
+ $glyphicon = $this->important ? 'warning-sign' : 'info-sign';
- /**
- * Render the added hints to a popover for the toolbar.
- */
- public function render() {
- if (count($this->hints) > 0) {
- $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 '';
}
-
- return '';
- }
-
- /**
- * Add a hint to the list, if its not null and a not empty string.
- *
- * @param string $hint
- * The hint
- * @param boolean $important
- * Is the hint important?
- */
- public function addHint($hint, $important = false) {
- if ($hint != null && $hint != '') {
- if ($important) {
- $this->important = true;
- $this->hints[] = error($hint, true);
- } else {
- $this->hints[] = info($hint, true);
- }
+
+ /**
+ * Add a hint to the list, if its not null and a not empty string.
+ *
+ * @param string $hint The hint
+ * @param boolean $important Is the hint important?
+ */
+ public function addHint($hint, $important = false)
+ {
+ if ($hint != null && $hint != '') {
+ if ($important) {
+ $this->important = true;
+ $this->hints[] = error($hint, true);
+ } else {
+ $this->hints[] = info($hint, true);
+ }
+ }
}
- }
-
- /**
- * Get all hints.
- */
- public function getHints() {
- return $this->hints;
- }
-
- /**
- * Are there important hints? This leads to a more intensive icon.
- */
- public function isImportant() {
- return $this->important;
- }
-}
-?> \ No newline at end of file
+ /**
+ * Get all hints.
+ *
+ * @return string[]
+ */
+ public function getHints()
+ {
+ return $this->hints;
+ }
+
+ /**
+ * Are there important hints? This leads to a more intensive icon.
+ *
+ * @return bool
+ */
+ public function isImportant()
+ {
+ return $this->important;
+ }
+}
diff --git a/includes/view/User_view.php b/includes/view/User_view.php
index 65cb36b3..c1e6f49e 100644
--- a/includes/view/User_view.php
+++ b/includes/view/User_view.php
@@ -1,494 +1,701 @@
<?php
/**
- * Available T-Shirt sizes
- */
-$tshirt_sizes = [
- '' => _("Please select..."),
- 'S' => "S",
- 'M' => "M",
- 'L' => "L",
- 'XL' => "XL",
- '2XL' => "2XL",
- '3XL' => "3XL",
- '4XL' => "4XL",
- '5XL' => "5XL",
- 'S-G' => "S Girl",
- 'M-G' => "M Girl",
- 'L-G' => "L Girl",
- 'XL-G' => "XL Girl"
-];
-
-/**
* Renders user settings page
*
- * @param User $user_source
- * The user
- * @param array<String> $locales
- * Available languages
- * @param array<String> $themes
- * Available themes
+ * @param array $user_source The user
+ * @param array $locales Available languages
+ * @param array $themes Available themes
+ * @param int $buildup_start_date Unix timestamp
+ * @param int $teardown_end_date Unix timestamp
+ * @param bool $enable_tshirt_size
+ * @param array $tshirt_sizes
+ * @return string
*/
-function User_settings_view($user_source, $locales, $themes, $buildup_start_date, $teardown_end_date, $enable_tshirt_size, $tshirt_sizes) {
- return page_with_title(settings_title(), [
- msg(),
- div('row', [
- div('col-md-6', [
- form([
- form_info('', _("Here you can change your user details.")),
- form_info(entry_required() . ' = ' . _("Entry required!")),
- form_text('nick', _("Nick"), $user_source['Nick'], true),
- form_text('lastname', _("Last name"), $user_source['Name']),
- form_text('prename', _("First name"), $user_source['Vorname']),
- form_date('planned_arrival_date', _("Planned date of arrival") . ' ' . entry_required(), $user_source['planned_arrival_date'], $buildup_start_date, $teardown_end_date),
- form_date('planned_departure_date', _("Planned date of departure"), $user_source['planned_departure_date'], $buildup_start_date, $teardown_end_date),
- form_text('age', _("Age"), $user_source['Alter']),
- form_text('tel', _("Phone"), $user_source['Telefon']),
- form_text('dect', _("DECT"), $user_source['DECT']),
- form_text('mobile', _("Mobile"), $user_source['Handy']),
- form_text('mail', _("E-Mail") . ' ' . entry_required(), $user_source['email']),
- form_checkbox('email_shiftinfo', _("The engelsystem is allowed to send me an email (e.g. when my shifts change)"), $user_source['email_shiftinfo']),
- form_checkbox('email_by_human_allowed', _("Humans are allowed to send me an email (e.g. for ticket vouchers)"), $user_source['email_by_human_allowed']),
- form_text('jabber', _("Jabber"), $user_source['jabber']),
- form_text('hometown', _("Hometown"), $user_source['Hometown']),
- $enable_tshirt_size ? form_select('tshirt_size', _("Shirt size"), $tshirt_sizes, $user_source['Size']) : '',
- form_info('', _('Please visit the angeltypes page to manage your angeltypes.')),
- form_submit('submit', _("Save"))
- ])
- ]),
- div('col-md-6', [
- form([
- form_info(_("Here you can change your password.")),
- form_password('password', _("Old password:")),
- form_password('new_password', _("New password:")),
- form_password('new_password2', _("Password confirmation:")),
- form_submit('submit_password', _("Save"))
- ]),
- form([
- form_info(_("Here you can choose your color settings:")),
- form_select('theme', _("Color settings:"), $themes, $user_source['color']),
- form_submit('submit_theme', _("Save"))
- ]),
- form([
- form_info(_("Here you can choose your language:")),
- form_select('language', _("Language:"), $locales, $user_source['Sprache']),
- form_submit('submit_language', _("Save"))
- ])
- ])
- ])
- ]);
+function User_settings_view(
+ $user_source,
+ $locales,
+ $themes,
+ $buildup_start_date,
+ $teardown_end_date,
+ $enable_tshirt_size,
+ $tshirt_sizes
+) {
+ return page_with_title(settings_title(), [
+ msg(),
+ div('row', [
+ div('col-md-6', [
+ form([
+ form_info('', _('Here you can change your user details.')),
+ form_info(entry_required() . ' = ' . _('Entry required!')),
+ form_text('nick', _('Nick'), $user_source['Nick'], true),
+ form_text('lastname', _('Last name'), $user_source['Name']),
+ form_text('prename', _('First name'), $user_source['Vorname']),
+ form_date(
+ 'planned_arrival_date',
+ _('Planned date of arrival') . ' ' . entry_required(),
+ $user_source['planned_arrival_date'],
+ $buildup_start_date,
+ $teardown_end_date
+ ),
+ form_date(
+ 'planned_departure_date',
+ _('Planned date of departure'),
+ $user_source['planned_departure_date'],
+ $buildup_start_date,
+ $teardown_end_date
+ ),
+ form_text('age', _('Age'), $user_source['Alter']),
+ form_text('tel', _('Phone'), $user_source['Telefon']),
+ form_text('dect', _('DECT'), $user_source['DECT']),
+ form_text('mobile', _('Mobile'), $user_source['Handy']),
+ form_text('mail', _('E-Mail') . ' ' . entry_required(), $user_source['email']),
+ form_checkbox(
+ 'email_shiftinfo',
+ _('The engelsystem is allowed to send me an email (e.g. when my shifts change)'),
+ $user_source['email_shiftinfo']
+ ),
+ form_checkbox(
+ 'email_by_human_allowed',
+ _('Humans are allowed to send me an email (e.g. for ticket vouchers)'),
+ $user_source['email_by_human_allowed']
+ ),
+ form_text('jabber', _('Jabber'), $user_source['jabber']),
+ form_text('hometown', _('Hometown'), $user_source['Hometown']),
+ $enable_tshirt_size ? form_select(
+ 'tshirt_size',
+ _('Shirt size'),
+ $tshirt_sizes,
+ $user_source['Size']
+ ) : '',
+ form_info('', _('Please visit the angeltypes page to manage your angeltypes.')),
+ form_submit('submit', _('Save'))
+ ])
+ ]),
+ div('col-md-6', [
+ form([
+ form_info(_('Here you can change your password.')),
+ form_password('password', _('Old password:')),
+ form_password('new_password', _('New password:')),
+ form_password('new_password2', _('Password confirmation:')),
+ form_submit('submit_password', _('Save'))
+ ]),
+ form([
+ form_info(_('Here you can choose your color settings:')),
+ form_select('theme', _('Color settings:'), $themes, $user_source['color']),
+ form_submit('submit_theme', _('Save'))
+ ]),
+ form([
+ form_info(_('Here you can choose your language:')),
+ form_select('language', _('Language:'), $locales, $user_source['Sprache']),
+ form_submit('submit_language', _('Save'))
+ ])
+ ])
+ ])
+ ]);
}
/**
* Displays the welcome message to the user and shows a login form.
+ *
+ * @param string $event_welcome_message
+ * @return string
*/
-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', [
- div('col-md-4', [
- $event_welcome_message
- ]),
- div('col-md-4', [
- '<h2>' . _("Login") . '</h2>',
- form([
- form_text('nick', _("Nick"), ""),
- form_password('password', _("Password")),
- form_submit('submit', _("Login")),
- buttons([
- button(page_link_to('user_password_recovery'), _("I forgot my password"))
- ]),
- info(_("Please note: You have to activate cookies!"), true)
- ], page_link_to('login'))
- ]),
- div('col-md-4', [
- '<h2>' . _("What can I do?") . '</h2>',
- '<p>' . _("Please read about the jobs you can do to help us.") . '</p>',
- buttons([
- button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description") . ' &raquo;')
- ])
- ])
- ])
- ]);
+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', [
+ div('col-md-4', [
+ $event_welcome_message
+ ]),
+ div('col-md-4', [
+ '<h2>' . _('Login') . '</h2>',
+ form([
+ form_text('nick', _('Nick'), ''),
+ form_password('password', _('Password')),
+ form_submit('submit', _('Login')),
+ buttons([
+ button(page_link_to('user_password_recovery'), _('I forgot my password'))
+ ]),
+ info(_('Please note: You have to activate cookies!'), true)
+ ], page_link_to('login'))
+ ]),
+ div('col-md-4', [
+ '<h2>' . _('What can I do?') . '</h2>',
+ '<p>' . _('Please read about the jobs you can do to help us.') . '</p>',
+ buttons([
+ button(page_link_to('angeltypes', ['action' => 'about']), _('Teams/Job description') . ' &raquo;')
+ ])
+ ])
+ ])
+ ]);
}
/**
* Gui for deleting user with password field.
+ *
+ * @param array $user
+ * @return string
*/
-function User_delete_view($user) {
- return page_with_title(sprintf(_("Delete %s"), User_Nick_render($user)), [
- msg(),
- buttons([
- button(user_edit_link($user), glyph('chevron-left') . _("back"))
- ]),
- error(_("Do you really want to delete the user including all his shifts and every other piece of his data?"), true),
- form([
- form_password('password', _("Your password")),
- form_submit('submit', _("Delete"))
- ])
- ]);
+function User_delete_view($user)
+{
+ return page_with_title(sprintf(_('Delete %s'), User_Nick_render($user)), [
+ msg(),
+ buttons([
+ button(user_edit_link($user), glyph('chevron-left') . _('back'))
+ ]),
+ error(
+ _('Do you really want to delete the user including all his shifts and every other piece of his data?'),
+ true
+ ),
+ form([
+ form_password('password', _('Your password')),
+ form_submit('submit', _('Delete'))
+ ])
+ ]);
}
/**
* View for editing the number of given vouchers
+ *
+ * @param array $user
+ * @return string
*/
-function User_edit_vouchers_view($user) {
- return page_with_title(sprintf(_("%s's vouchers"), User_Nick_render($user)), [
- msg(),
- 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),
- form([
- form_spinner('vouchers', _("Number of vouchers given out"), $user['got_voucher']),
- form_submit('submit', _("Save"))
- ], page_link_to('users') . '&action=edit_vouchers&user_id=' . $user['UID'])
- ]);
+function User_edit_vouchers_view($user)
+{
+ return page_with_title(sprintf(_('%s\'s vouchers'), User_Nick_render($user)), [
+ msg(),
+ 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),
+ form(
+ [
+ form_spinner('vouchers', _('Number of vouchers given out'), $user['got_voucher']),
+ form_submit('submit', _('Save'))
+ ],
+ page_link_to('users', ['action' => 'edit_vouchers', 'user_id' => $user['UID']])
+ )
+ ]);
}
-function Users_view($users, $order_by, $arrived_count, $active_count, $force_active_count, $freeloads_count, $tshirts_count, $voucher_count) {
- foreach ($users as &$user) {
- $user['Nick'] = User_Nick_render($user);
- $user['Gekommen'] = glyph_bool($user['Gekommen']);
- $user['got_voucher'] = $user['got_voucher'];
- $user['Aktiv'] = glyph_bool($user['Aktiv']);
- $user['force_active'] = glyph_bool($user['force_active']);
- $user['Tshirt'] = glyph_bool($user['Tshirt']);
- $user['lastLogIn'] = date(_('m/d/Y h:i a'), $user['lastLogIn']);
- $user['actions'] = table_buttons([
- button_glyph(page_link_to('admin_user') . '&id=' . $user['UID'], 'edit', 'btn-xs')
+/**
+ * @param array[] $users
+ * @param string $order_by
+ * @param int $arrived_count
+ * @param int $active_count
+ * @param int $force_active_count
+ * @param int $freeloads_count
+ * @param int $tshirts_count
+ * @param int $voucher_count
+ * @return string
+ */
+function Users_view(
+ $users,
+ $order_by,
+ $arrived_count,
+ $active_count,
+ $force_active_count,
+ $freeloads_count,
+ $tshirts_count,
+ $voucher_count
+) {
+ foreach ($users as &$user) {
+ $user['Nick'] = User_Nick_render($user);
+ $user['Gekommen'] = glyph_bool($user['Gekommen']);
+ $user['Aktiv'] = glyph_bool($user['Aktiv']);
+ $user['force_active'] = glyph_bool($user['force_active']);
+ $user['Tshirt'] = glyph_bool($user['Tshirt']);
+ $user['lastLogIn'] = date(_('m/d/Y h:i a'), $user['lastLogIn']);
+ $user['actions'] = table_buttons([
+ button_glyph(page_link_to('admin_user', ['id' => $user['UID']]), 'edit', 'btn-xs')
+ ]);
+ }
+ $users[] = [
+ 'Nick' => '<strong>' . _('Sum') . '</strong>',
+ 'Gekommen' => $arrived_count,
+ 'got_voucher' => $voucher_count,
+ 'Aktiv' => $active_count,
+ 'force_active' => $force_active_count,
+ 'freeloads' => $freeloads_count,
+ 'Tshirt' => $tshirts_count,
+ 'actions' => '<strong>' . count($users) . '</strong>'
+ ];
+
+ return page_with_title(_('All users'), [
+ msg(),
+ buttons([
+ button(page_link_to('register'), glyph('plus') . _('New user'))
+ ]),
+ table([
+ 'Nick' => Users_table_header_link('Nick', _('Nick'), $order_by),
+ 'Vorname' => Users_table_header_link('Vorname', _('Prename'), $order_by),
+ 'Name' => Users_table_header_link('Name', _('Name'), $order_by),
+ 'DECT' => Users_table_header_link('DECT', _('DECT'), $order_by),
+ 'Gekommen' => Users_table_header_link('Gekommen', _('Arrived'), $order_by),
+ 'got_voucher' => Users_table_header_link('got_voucher', _('Voucher'), $order_by),
+ 'freeloads' => _('Freeloads'),
+ 'Aktiv' => Users_table_header_link('Aktiv', _('Active'), $order_by),
+ 'force_active' => Users_table_header_link('force_active', _('Forced'), $order_by),
+ 'Tshirt' => Users_table_header_link('Tshirt', _('T-Shirt'), $order_by),
+ 'Size' => Users_table_header_link('Size', _('Size'), $order_by),
+ 'lastLogIn' => Users_table_header_link('lastLogIn', _('Last login'), $order_by),
+ 'actions' => ''
+ ], $users)
]);
- }
- $users[] = [
- 'Nick' => '<strong>' . _('Sum') . '</strong>',
- 'Gekommen' => $arrived_count,
- 'got_voucher' => $voucher_count,
- 'Aktiv' => $active_count,
- 'force_active' => $force_active_count,
- 'freeloads' => $freeloads_count,
- 'Tshirt' => $tshirts_count,
- 'actions' => '<strong>' . count($users) . '</strong>'
- ];
-
- return page_with_title(_("All users"), [
- msg(),
- buttons([
- button(page_link_to('register'), glyph('plus') . _("New user"))
- ]),
- table([
- 'Nick' => Users_table_header_link('Nick', _("Nick"), $order_by),
- 'Vorname' => Users_table_header_link('Vorname', _("Prename"), $order_by),
- 'Name' => Users_table_header_link('Name', _("Name"), $order_by),
- 'DECT' => Users_table_header_link('DECT', _("DECT"), $order_by),
- 'Gekommen' => Users_table_header_link('Gekommen', _("Arrived"), $order_by),
- 'got_voucher' => Users_table_header_link('got_voucher', _("Voucher"), $order_by),
- 'freeloads' => _('Freeloads'),
- 'Aktiv' => Users_table_header_link('Aktiv', _("Active"), $order_by),
- 'force_active' => Users_table_header_link('force_active', _("Forced"), $order_by),
- 'Tshirt' => Users_table_header_link('Tshirt', _("T-Shirt"), $order_by),
- 'Size' => Users_table_header_link('Size', _("Size"), $order_by),
- 'lastLogIn' => Users_table_header_link('lastLogIn', _("Last login"), $order_by),
- 'actions' => ''
- ], $users)
- ]);
}
-function Users_table_header_link($column, $label, $order_by) {
- return '<a href="' . page_link_to('users') . '&OrderBy=' . $column . '">' . $label . ($order_by == $column ? ' <span class="caret"></span>' : '') . '</a>';
+/**
+ * @param string $column
+ * @param string $label
+ * @param string $order_by
+ * @return string
+ */
+function Users_table_header_link($column, $label, $order_by)
+{
+ return '<a href="'
+ . page_link_to('users', ['OrderBy' => $column])
+ . '">'
+ . $label . ($order_by == $column ? ' <span class="caret"></span>' : '')
+ . '</a>';
}
-function User_shift_state_render($user) {
- $upcoming_shifts = ShiftEntries_upcoming_for_user($user);
- if ($upcoming_shifts === false) {
- return false;
- }
-
- if (count($upcoming_shifts) == 0) {
- return '<span class="text-success">' . _("Free") . '</span>';
- }
-
- if ($upcoming_shifts[0]['start'] > time()) {
- if ($upcoming_shifts[0]['start'] - time() > 3600) {
- return '<span class="text-success moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Next shift %c") . '</span>';
+/**
+ * @param array $user
+ * @return string|false
+ */
+function User_shift_state_render($user)
+{
+ $upcoming_shifts = ShiftEntries_upcoming_for_user($user);
+
+ if (empty($upcoming_shifts)) {
+ return '<span class="text-success">' . _('Free') . '</span>';
+ }
+
+ $nextShift = array_shift($upcoming_shifts);
+
+ 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-warning moment-countdown" data-timestamp="' . $nextShift['start'] . '">' . _('Next shift %c') . '</span>';
}
- return '<span class="text-warning moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Next shift %c") . '</span>';
- }
- $halfway = ($upcoming_shifts[0]['start'] + $upcoming_shifts[0]['end']) / 2;
-
- if (time() < $halfway) {
- return '<span class="text-danger moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Shift starts %c") . '</span>';
- }
- return '<span class="text-danger moment-countdown" data-timestamp="' . $upcoming_shifts[0]['end'] . '">' . _("Shift ends %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['end'] . '">' . _('Shift ends %c') . '</span>';
}
-function User_view_shiftentries($needed_angel_type) {
- $shift_info = '<br><b>' . $needed_angel_type['name'] . ':</b> ';
-
- $shift_entries = [];
- foreach ($needed_angel_type['users'] as $user_shift) {
- $member = User_Nick_render($user_shift);
- if ($user_shift['freeloaded']) {
- $member = '<strike>' . $member . '</strike>';
+/**
+ * @param array $needed_angel_type
+ * @return string
+ */
+function User_view_shiftentries($needed_angel_type)
+{
+ $shift_info = '<br><b>' . $needed_angel_type['name'] . ':</b> ';
+
+ $shift_entries = [];
+ foreach ($needed_angel_type['users'] as $user_shift) {
+ $member = User_Nick_render($user_shift);
+ if ($user_shift['freeloaded']) {
+ $member = '<del>' . $member . '</del>';
+ }
+
+ $shift_entries[] = $member;
}
-
- $shift_entries[] = $member;
- }
- $shift_info .= join(", ", $shift_entries);
-
- return $shift_info;
+ $shift_info .= join(', ', $shift_entries);
+
+ return $shift_info;
}
/**
* Helper that renders a shift line for user view
+ *
+ * @param array $shift
+ * @param array $user_source
+ * @param bool $its_me
+ * @return array
*/
-function User_view_myshift($shift, $user_source, $its_me) {
- global $LETZTES_AUSTRAGEN, $privileges;
-
- $shift_info = '<a href="' . shift_link($shift) . '">' . $shift['name'] . '</a>';
- if ($shift['title']) {
- $shift_info .= '<br /><a href="' . shift_link($shift) . '">' . $shift['title'] . '</a>';
- }
- foreach ($shift['needed_angeltypes'] as $needed_angel_type) {
- $shift_info .= User_view_shiftentries($needed_angel_type);
- }
-
- $myshift = [
- 'date' => date("Y-m-d", $shift['start']),
- 'time' => date("H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']),
- 'room' => $shift['Name'],
- 'shift_info' => $shift_info,
- 'comment' => $shift['Comment']
- ];
-
- if ($shift['freeloaded']) {
- if (in_array("user_shifts_admin", $privileges)) {
- $myshift['comment'] .= '<br /><p class="error">' . _("Freeloaded") . ': ' . $shift['freeload_comment'] . '</p>';
- } else {
- $myshift['comment'] .= '<br /><p class="error">' . _("Freeloaded") . '</p>';
+function User_view_myshift($shift, $user_source, $its_me)
+{
+ global $privileges;
+
+ $shift_info = '<a href="' . shift_link($shift) . '">' . $shift['name'] . '</a>';
+ if ($shift['title']) {
+ $shift_info .= '<br /><a href="' . shift_link($shift) . '">' . $shift['title'] . '</a>';
+ }
+ foreach ($shift['needed_angeltypes'] as $needed_angel_type) {
+ $shift_info .= User_view_shiftentries($needed_angel_type);
+ }
+
+ $myshift = [
+ 'date' => date('Y-m-d', $shift['start']),
+ 'time' => date('H:i', $shift['start']) . ' - ' . date('H:i', $shift['end']),
+ 'room' => $shift['Name'],
+ 'shift_info' => $shift_info,
+ 'comment' => $shift['Comment']
+ ];
+
+ if ($shift['freeloaded']) {
+ if (in_array('user_shifts_admin', $privileges)) {
+ $myshift['comment'] .= '<br /><p class="error">' . _('Freeloaded') . ': ' . $shift['freeload_comment'] . '</p>';
+ } else {
+ $myshift['comment'] .= '<br /><p class="error">' . _('Freeloaded') . '</p>';
+ }
+ }
+
+ $myshift['actions'] = [
+ button(shift_link($shift), glyph('eye-open') . _('view'), 'btn-xs')
+ ];
+ if ($its_me || in_array('user_shifts_admin', $privileges)) {
+ $myshift['actions'][] = button(
+ page_link_to('user_myshifts', ['edit' => $shift['id'], 'id' => $user_source['UID']]),
+ glyph('edit') . _('edit'),
+ 'btn-xs'
+ );
+ }
+ if (
+ ($shift['start'] > time() + config('last_unsubscribe') * 3600)
+ || in_array('user_shifts_admin', $privileges)
+ ) {
+ $parameters = [
+ 'cancel' => $shift['id'],
+ 'id' => $user_source['UID'],
+ ];
+ if ($its_me) {
+ $parameters['id'] = '';
+ }
+ $myshift['actions'][] = button(
+ page_link_to('user_myshifts', $parameters),
+ glyph('trash') . _('sign off'),
+ 'btn-xs'
+ );
}
- }
-
- $myshift['actions'] = [
- button(shift_link($shift), glyph('eye-open') . _('view'), 'btn-xs')
- ];
- if ($its_me || in_array('user_shifts_admin', $privileges)) {
- $myshift['actions'][] = button(page_link_to('user_myshifts') . '&edit=' . $shift['id'] . '&id=' . $user_source['UID'], glyph('edit') . _('edit'), 'btn-xs');
- }
- if (($shift['start'] > time() + $LETZTES_AUSTRAGEN * 3600) || in_array('user_shifts_admin', $privileges)) {
- $myshift['actions'][] = button(page_link_to('user_myshifts') . ((! $its_me) ? '&id=' . $user_source['UID'] : '') . '&cancel=' . $shift['id'], glyph('trash') . _('sign off'), 'btn-xs');
- }
- $myshift['actions'] = table_buttons($myshift['actions']);
-
- return $myshift;
+ $myshift['actions'] = table_buttons($myshift['actions']);
+
+ return $myshift;
}
/**
* Helper that prepares the shift table for user view
+ *
+ * @param array[] $shifts
+ * @param array $user_source
+ * @param bool $its_me
+ * @return array
*/
-function User_view_myshifts($shifts, $user_source, $its_me) {
- $myshifts_table = [];
- $timesum = 0;
- foreach ($shifts as $shift) {
- $myshifts_table[] = User_view_myshift($shift, $user_source, $its_me);
-
- if ($shift['freeloaded']) {
- $timesum += (- 2 * ($shift['end'] - $shift['start']));
- } else {
- $timesum += ($shift['end'] - $shift['start']);
+function User_view_myshifts($shifts, $user_source, $its_me)
+{
+ $myshifts_table = [];
+ $timesum = 0;
+ foreach ($shifts as $shift) {
+ $myshifts_table[] = User_view_myshift($shift, $user_source, $its_me);
+
+ if ($shift['freeloaded']) {
+ $timesum += (-2 * ($shift['end'] - $shift['start']));
+ } else {
+ $timesum += ($shift['end'] - $shift['start']);
+ }
}
- }
-
- if (count($myshifts_table) > 0) {
- $myshifts_table[] = [
- 'date' => '<b>' . _("Sum:") . '</b>',
- 'time' => "<b>" . round($timesum / 3600, 1) . " h</b>",
- 'room' => "",
- 'shift_info' => "",
- 'comment' => "",
- 'actions' => ""
- ];
- }
- return $myshifts_table;
+
+ if (count($myshifts_table) > 0) {
+ $myshifts_table[] = [
+ 'date' => '<b>' . _('Sum:') . '</b>',
+ 'time' => '<b>' . round($timesum / 3600, 1) . ' h</b>',
+ 'room' => '',
+ 'shift_info' => '',
+ 'comment' => '',
+ 'actions' => ''
+ ];
+ }
+ return $myshifts_table;
}
/**
* Renders view for a single user
+ *
+ * @param array $user_source
+ * @param bool $admin_user_privilege
+ * @param bool $freeloader
+ * @param array[] $user_angeltypes
+ * @param array[] $user_groups
+ * @param array[] $shifts
+ * @param bool $its_me
+ * @return string
*/
-function User_view($user_source, $admin_user_privilege, $freeloader, $user_angeltypes, $user_groups, $shifts, $its_me) {
- $user_name = htmlspecialchars($user_source['Vorname']) . " " . htmlspecialchars($user_source['Name']);
- $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>', [
- msg(),
- div('row space-top', [
- div('col-md-12', [
- buttons([
- $admin_user_privilege ? button(page_link_to('admin_user') . '&id=' . $user_source['UID'], 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'], _("arrived")) : '',
- $admin_user_privilege ? button(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('ical') . '&key=' . $user_source['api_key'], glyph('calendar') . _("iCal Export")) : '',
- $its_me ? button(page_link_to('shifts_json_export') . '&key=' . $user_source['api_key'], glyph('export') . _("JSON Export")) : '',
- $its_me ? button(page_link_to('user_myshifts') . '&reset', glyph('repeat') . _('Reset API key')) : ''
- ])
- ])
- ]),
- div('row', [
- div('col-md-3', [
- '<h1>',
- '<span class="glyphicon glyphicon-phone"></span>',
- $user_source['DECT'],
- '</h1>'
- ]),
- div('col-md-3', [
- '<h4>' . _("User state") . '</h4>',
- ($admin_user_privilege && $freeloader) ? '<span class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"></span> ' . _("Freeloader") . '</span><br />' : '',
- $user_source['Gekommen'] ? User_shift_state_render($user_source) . '<br />' : '',
- $admin_user_privilege || $its_me ? ($user_source['Gekommen'] ? '<span class="text-success"><span class="glyphicon glyphicon-home"></span> ' . sprintf(_("Arrived at %s"), date('Y-m-d', $user_source['arrival_date'])) . '</span>' : '<span class="text-danger">' . sprintf(_("Not arrived (Planned: %s)"), date('Y-m-d', $user_source['planned_arrival_date'])) . '</span>') : ($user_source['Gekommen'] ? '<span class="text-success"><span class="glyphicon glyphicon-home"></span> ' . _("Arrived") . '</span>' : '<span class="text-danger">' . _("Not arrived") . '</span>'),
- $admin_user_privilege ? ($user_source['got_voucher'] > 0 ? '<br /><span class="text-success">' . glyph('cutlery') . sprintf(ngettext("Got %s voucher", "Got %s vouchers", $user_source['got_voucher']), $user_source['got_voucher']) . '</span><br />' : '<br /><span class="text-danger">' . _("Got no vouchers") . '</span><br />') : '',
- ($user_source['Gekommen'] && $admin_user_privilege && $user_source['Aktiv']) ? ' <span class="text-success">' . _("Active") . '</span>' : '',
- ($user_source['Gekommen'] && $admin_user_privilege && $user_source['Tshirt']) ? ' <span class="text-success">' . _("T-Shirt") . '</span>' : ''
- ]),
- div('col-md-3', [
- '<h4>' . _("Angeltypes") . '</h4>',
- User_angeltypes_render($user_angeltypes)
- ]),
- div('col-md-3', [
- '<h4>' . _("Rights") . '</h4>',
- User_groups_render($user_groups)
- ])
- ]),
- ($its_me || $admin_user_privilege) ? '<h2>' . _("Shifts") . '</h2>' : '',
- ($its_me || $admin_user_privilege) ? table([
- 'date' => _("Day"),
- 'time' => _("Time"),
- 'room' => _("Location"),
- 'shift_info' => _("Name &amp; workmates"),
- '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 && count($shifts) == 0 ? error(sprintf(_("Go to the <a href=\"%s\">shifts table</a> to sign yourself up for some shifts."), page_link_to('user_shifts')), true) : ''
- ]);
+function User_view($user_source, $admin_user_privilege, $freeloader, $user_angeltypes, $user_groups, $shifts, $its_me)
+{
+ $user_name = htmlspecialchars($user_source['Vorname']) . ' ' . htmlspecialchars($user_source['Name']);
+ $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>',
+ [
+ msg(),
+ div('row space-top', [
+ div('col-md-12', [
+ buttons([
+ $admin_user_privilege ? button(
+ page_link_to('admin_user', ['id' => $user_source['UID']]),
+ 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']]),
+ _('arrived')
+ ) : '',
+ $admin_user_privilege ? button(
+ 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('ical', ['key' => $user_source['api_key']]),
+ glyph('calendar') . _('iCal Export')
+ ) : '',
+ $its_me ? button(
+ page_link_to('shifts_json_export', ['key' => $user_source['api_key']]),
+ glyph('export') . _('JSON Export')
+ ) : '',
+ $its_me ? button(
+ page_link_to('user_myshifts', ['reset' => 1]),
+ glyph('repeat') . _('Reset API key')
+ ) : ''
+ ])
+ ])
+ ]),
+ div('row', [
+ div('col-md-3', [
+ '<h1>',
+ '<span class="glyphicon glyphicon-phone"></span>',
+ $user_source['DECT'],
+ '</h1>'
+ ]),
+ div('col-md-3', [
+ '<h4>' . _('User state') . '</h4>',
+ ($admin_user_privilege && $freeloader)
+ ? '<span class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"></span> ' . _('Freeloader') . '</span><br />'
+ : '',
+ $user_source['Gekommen']
+ ? User_shift_state_render($user_source) . '<br />'
+ : '',
+ $admin_user_privilege || $its_me
+ ? (
+ $user_source['Gekommen']
+ ? '<span class="text-success"><span class="glyphicon glyphicon-home"></span> '
+ . sprintf(_('Arrived at %s'), date('Y-m-d', $user_source['arrival_date']))
+ . '</span>'
+ : '<span class="text-danger">'
+ . sprintf(_('Not arrived (Planned: %s)'), date('Y-m-d', $user_source['planned_arrival_date']))
+ . '</span>'
+ )
+ : (
+ $user_source['Gekommen']
+ ? '<span class="text-success"><span class="glyphicon glyphicon-home"></span> ' . _('Arrived') . '</span>'
+ : '<span class="text-danger">' . _('Not arrived') . '</span>'),
+ $admin_user_privilege
+ ? (
+ $user_source['got_voucher'] > 0
+ ? '<br /><span class="text-success">'
+ . glyph('cutlery')
+ . sprintf(
+ ngettext('Got %s voucher', 'Got %s vouchers', $user_source['got_voucher']),
+ $user_source['got_voucher']
+ )
+ . '</span><br />'
+ : '<br /><span class="text-danger">' . _('Got no vouchers') . '</span><br />')
+ : '',
+ ($user_source['Gekommen'] && $admin_user_privilege && $user_source['Aktiv']) ? ' <span class="text-success">' . _('Active') . '</span>' : '',
+ ($user_source['Gekommen'] && $admin_user_privilege && $user_source['Tshirt']) ? ' <span class="text-success">' . _('T-Shirt') . '</span>' : ''
+ ]),
+ div('col-md-3', [
+ '<h4>' . _('Angeltypes') . '</h4>',
+ User_angeltypes_render($user_angeltypes)
+ ]),
+ div('col-md-3', [
+ '<h4>' . _('Rights') . '</h4>',
+ User_groups_render($user_groups)
+ ])
+ ]),
+ ($its_me || $admin_user_privilege) ? '<h2>' . _('Shifts') . '</h2>' : '',
+ ($its_me || $admin_user_privilege) ? table([
+ 'date' => _('Day'),
+ 'time' => _('Time'),
+ 'room' => _('Location'),
+ 'shift_info' => _('Name &amp; workmates'),
+ '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 && count($shifts) == 0
+ ? error(sprintf(
+ _('Go to the <a href="%s">shifts table</a> to sign yourself up for some shifts.'),
+ page_link_to('user_shifts')
+ ), true)
+ : ''
+ ]
+ );
}
/**
* View for password recovery step 1: E-Mail
+ *
+ * @return string
*/
-function User_password_recovery_view() {
- return page_with_title(user_password_recovery_title(), [
- msg(),
- _("We will send you an e-mail with a password recovery link. Please use the email address you used for registration."),
- form([
- form_text('email', _("E-Mail"), ""),
- form_submit('submit', _("Recover"))
- ])
- ]);
+function User_password_recovery_view()
+{
+ return page_with_title(user_password_recovery_title(), [
+ msg(),
+ _('We will send you an e-mail with a password recovery link. Please use the email address you used for registration.'),
+ form([
+ form_text('email', _('E-Mail'), ''),
+ form_submit('submit', _('Recover'))
+ ])
+ ]);
}
/**
* View for password recovery step 2: New password
+ *
+ * @return string
*/
-function User_password_set_view() {
- return page_with_title(user_password_recovery_title(), [
- msg(),
- _("Please enter a new password."),
- form([
- form_password('password', _("Password")),
- form_password('password2', _("Confirm password")),
- form_submit('submit', _("Save"))
- ])
- ]);
+function User_password_set_view()
+{
+ return page_with_title(user_password_recovery_title(), [
+ msg(),
+ _('Please enter a new password.'),
+ form([
+ form_password('password', _('Password')),
+ form_password('password2', _('Confirm password')),
+ form_submit('submit', _('Save'))
+ ])
+ ]);
}
-function User_angeltypes_render($user_angeltypes) {
- $output = [];
- foreach ($user_angeltypes as $angeltype) {
- $class = "";
- if ($angeltype['restricted'] == 1) {
- if ($angeltype['confirm_user_id'] != null) {
+/**
+ * @param array[] $user_angeltypes
+ * @return string
+ */
+function User_angeltypes_render($user_angeltypes)
+{
+ $output = [];
+ foreach ($user_angeltypes as $angeltype) {
$class = 'text-success';
- } else {
- $class = 'text-warning';
- }
- } else {
- $class = 'text-success';
+ if ($angeltype['restricted'] == 1 && $angeltype['confirm_user_id'] == null) {
+ $class = 'text-warning';
+ }
+ $output[] = '<a href="' . angeltype_link($angeltype['id']) . '" class="' . $class . '">'
+ . ($angeltype['supporter'] ? glyph('education') : '') . $angeltype['name']
+ . '</a>';
}
- $output[] = '<a href="' . angeltype_link($angeltype['id']) . '" class="' . $class . '">' . ($angeltype['supporter'] ? glyph('education') : '') . $angeltype['name'] . '</a>';
- }
- return join('<br />', $output);
+ return join('<br />', $output);
}
-function User_groups_render($user_groups) {
- $output = [];
- foreach ($user_groups as $group) {
- $output[] = substr($group['Name'], 2);
- }
- return join('<br />', $output);
+/**
+ * @param array[] $user_groups
+ * @return string
+ */
+function User_groups_render($user_groups)
+{
+ $output = [];
+ foreach ($user_groups as $group) {
+ $output[] = substr($group['Name'], 2);
+ }
+ return join('<br />', $output);
}
/**
* Render a user nickname.
*
- * @param User $user_source
+ * @param array $user_source
* @return string
*/
-function User_Nick_render($user_source) {
- return '<a class="' . ($user_source['Gekommen'] ? '' : 'text-muted') . '" href="' . page_link_to('users') . '&amp;action=view&amp;user_id=' . $user_source['UID'] . '"><span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . '</a>';
+function User_Nick_render($user_source)
+{
+ return '<a class="' . ($user_source['Gekommen'] ? '' : 'text-muted') . '" href="'
+ . page_link_to('users', ['action' => 'view', 'user_id' => $user_source['UID']])
+ . '"><span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . '</a>';
}
-function render_user_departure_date_hint() {
- global $user;
-
- if (! isset($user['planned_departure_date']) || $user['planned_departure_date'] == null) {
- return _("Please enter your planned date of departure on your settings page to give us a feeling for teardown capacities.");
- }
-
- return null;
-}
+/**
+ * @return string|null
+ */
+function render_user_departure_date_hint()
+{
+ global $user;
-function render_user_freeloader_hint() {
- global $user, $max_freeloadable_shifts;
-
- if (User_is_freeloader($user)) {
- return sprintf(_("You freeloaded at least %s shifts. Shift signup is locked. Please go to heavens desk to be unlocked again."), $max_freeloadable_shifts);
- }
-
- return null;
+ if (!isset($user['planned_departure_date']) || $user['planned_departure_date'] == null) {
+ return _('Please enter your planned date of departure on your settings page to give us a feeling for teardown capacities.');
+ }
+
+ return null;
}
-// Hinweis für Engel, die noch nicht angekommen sind
-function render_user_arrived_hint() {
- global $user;
-
- if ($user['Gekommen'] == 0) {
- 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 null;
+/**
+ * @return string|null
+ */
+function render_user_freeloader_hint()
+{
+ global $user;
+
+ if (User_is_freeloader($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')
+ );
+ }
+
+ return null;
}
-function render_user_tshirt_hint() {
- global $enable_tshirt_size, $user;
-
- if ($enable_tshirt_size && $user['Size'] == "") {
- return _("You need to specify a tshirt size in your settings!");
- }
-
- return null;
+/**
+ * Hinweis für Engel, die noch nicht angekommen sind
+ *
+ * @return string|null
+ */
+function render_user_arrived_hint()
+{
+ global $user;
+
+ if ($user['Gekommen'] == 0) {
+ 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 null;
}
-function render_user_dect_hint() {
- global $user;
-
- if ($user['DECT'] == "") {
- return _("You need to specify a DECT phone number in your settings! If you don't have a DECT phone, just enter \"-\".");
- }
-
- return null;
+/**
+ * @return string|null
+ */
+function render_user_tshirt_hint()
+{
+ global $user;
+
+ if (config('enable_tshirt_size') && $user['Size'] == '') {
+ return _('You need to specify a tshirt size in your settings!');
+ }
+
+ return null;
}
-?>
+/**
+ * @return string|null
+ */
+function render_user_dect_hint()
+{
+ global $user;
+
+ if ($user['DECT'] == '') {
+ return _('You need to specify a DECT phone number in your settings! If you don\'t have a DECT phone, just enter \'-\'.');
+ }
+
+ return null;
+}