link to next shift in menu

main
Philip Häusler 10 years ago
parent d02272afd6
commit 038bf97178

@ -16,7 +16,7 @@ function shift_controller() {
global $user, $privileges; global $user, $privileges;
if (! in_array('user_shifts', $privileges)) if (! in_array('user_shifts', $privileges))
redirect(page_link_to('user_shifts')); redirect(page_link_to('?'));
if (! isset($_REQUEST['shift_id'])) if (! isset($_REQUEST['shift_id']))
redirect(page_link_to('user_shifts')); redirect(page_link_to('user_shifts'));
@ -58,9 +58,30 @@ function shifts_controller() {
redirect(page_link_to('?')); redirect(page_link_to('?'));
case 'view': case 'view':
return shift_controller(); return shift_controller();
case 'next':
return shift_next_controller();
} }
} }
/**
* Redirects the user to his next shift.
*/
function shift_next_controller() {
global $user, $privileges;
if (! in_array('user_shifts', $privileges))
redirect(page_link_to('?'));
$upcoming_shifts = ShiftEntries_upcoming_for_user($user);
if ($upcoming_shifts === false)
return false;
if (count($upcoming_shifts) > 0)
redirect(shift_link($upcoming_shifts[0]));
redirect(page_link_to('user_shifts'));
}
/** /**
* Export all shifts using api-key. * Export all shifts using api-key.
*/ */

@ -19,7 +19,7 @@ function header_toolbar() {
$toolbar_items = array(); $toolbar_items = array();
if (isset($user)) if (isset($user))
$toolbar_items[] = toolbar_item_link(page_link_to('users') . '&action=view', 'time', User_shift_state_render($user)); $toolbar_items[] = toolbar_item_link(page_link_to('shifts') . '&action=next', 'time', User_shift_state_render($user));
if (! isset($user) && in_array('register', $privileges)) if (! isset($user) && in_array('register', $privileges))
$toolbar_items[] = toolbar_item_link(page_link_to('register'), 'plus', register_title(), $p == 'register'); $toolbar_items[] = toolbar_item_link(page_link_to('register'), 'plus', register_title(), $p == 'register');

@ -1,8 +1,18 @@
<?php <?php
/** /**
* AngelTypes * AngelTypes
*/ */
/**
* Renders the angeltypes name as link.
*
* @param AngelType $angeltype
*/
function AngelType_name_render($angeltype) {
return '<a href="' . page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'] . '">' . ($angeltype['restricted'] ? glyph('lock') : '') . $angeltype['name'] . '</a>';
}
/** /**
* Render angeltype membership state * Render angeltype membership state
* *
@ -35,15 +45,15 @@ function AngelType_delete_view($angeltype) {
info(sprintf(_("Do you want to delete angeltype %s?"), $angeltype['name']), true), info(sprintf(_("Do you want to delete angeltype %s?"), $angeltype['name']), true),
buttons(array( buttons(array(
button(page_link_to('angeltypes'), _("cancel"), 'cancel'), button(page_link_to('angeltypes'), _("cancel"), 'cancel'),
button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'] . '&confirmed', _("delete"), 'ok') button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'] . '&confirmed', _("delete"), 'ok')
)) ))
)); ));
} }
function AngelType_edit_view($name, $restricted, $description, $coordinator_mode) { function AngelType_edit_view($name, $restricted, $description, $coordinator_mode) {
return page_with_title(sprintf(_("Edit %s"), $name), array( return page_with_title(sprintf(_("Edit %s"), $name), array(
buttons(array( buttons(array(
button(page_link_to('angeltypes'), _("Angeltypes"), 'back') button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
)), )),
msg(), msg(),
form(array( form(array(
@ -52,16 +62,16 @@ function AngelType_edit_view($name, $restricted, $description, $coordinator_mode
form_info("", _("Restricted angel types can only be used by an angel if enabled by an archangel (double opt-in).")), form_info("", _("Restricted angel types can only be used by an angel if enabled by an archangel (double opt-in).")),
form_textarea('description', _("Description"), $description), form_textarea('description', _("Description"), $description),
form_info("", _("Please use markdown for the description.")), form_info("", _("Please use markdown for the description.")),
form_submit('submit', _("Save")) form_submit('submit', _("Save"))
)) ))
)); ));
} }
function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angeltypes, $admin_angeltypes, $coordinator) { function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angeltypes, $admin_angeltypes, $coordinator) {
$buttons = array( $buttons = array(
button(page_link_to('angeltypes'), _("Angeltypes"), 'back') button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
); );
if ($user_angeltype == null) if ($user_angeltype == null)
$buttons[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), 'add'); $buttons[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), 'add');
else { else {
@ -69,24 +79,24 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
error(sprintf(_("You are unconfirmed for this angeltype. Please go to the introduction for %s to get confirmed."), $angeltype['name'])); 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'); $buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'], _("leave"), 'cancel');
} }
if ($admin_angeltypes || $coordinator) if ($admin_angeltypes || $coordinator)
$buttons[] = button(page_link_to('angeltypes') . '&action=edit&angeltype_id=' . $angeltype['id'], _("edit"), 'edit'); $buttons[] = button(page_link_to('angeltypes') . '&action=edit&angeltype_id=' . $angeltype['id'], _("edit"), 'edit');
if ($admin_angeltypes) if ($admin_angeltypes)
$buttons[] = button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'], _("delete"), 'delete'); $buttons[] = button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'], _("delete"), 'delete');
$page = array( $page = array(
msg(), msg(),
buttons($buttons) buttons($buttons)
); );
$page[] = '<h3>' . _("Description") . '</h3>'; $page[] = '<h3>' . _("Description") . '</h3>';
$parsedown = new Parsedown(); $parsedown = new Parsedown();
if ($angeltype['description'] != "") if ($angeltype['description'] != "")
$page[] = '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>'; $page[] = '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
// Team-Coordinators list missing // Team-Coordinators list missing
$coordinators = array(); $coordinators = array();
$members_confirmed = array(); $members_confirmed = array();
$members_unconfirmed = array(); $members_unconfirmed = array();
@ -95,7 +105,7 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
if ($angeltype['restricted'] && $member['confirm_user_id'] == null) { if ($angeltype['restricted'] && $member['confirm_user_id'] == null) {
$member['actions'] = join(" ", array( $member['actions'] = join(" ", array(
'<a href="' . page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $member['user_angeltype_id'] . '" class="ok">' . _("confirm") . '</a>', '<a href="' . page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $member['user_angeltype_id'] . '" class="ok">' . _("confirm") . '</a>',
'<a href="' . page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'] . '" class="cancel">' . _("deny") . '</a>' '<a href="' . page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'] . '" class="cancel">' . _("deny") . '</a>'
)); ));
$members_unconfirmed[] = $member; $members_unconfirmed[] = $member;
} elseif ($member['coordinator']) { } elseif ($member['coordinator']) {
@ -108,7 +118,7 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
if ($admin_user_angeltypes) if ($admin_user_angeltypes)
$member['actions'] = join(" ", array( $member['actions'] = join(" ", array(
$admin_angeltypes ? '<a href="' . page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&coordinator=1" class="add">' . _("Add coordinator rights") . '</a>' : '', $admin_angeltypes ? '<a href="' . page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&coordinator=1" class="add">' . _("Add coordinator rights") . '</a>' : '',
'<a href="' . page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'] . '" class="cancel">' . _("remove") . '</a>' '<a href="' . page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'] . '" class="cancel">' . _("remove") . '</a>'
)); ));
$members_confirmed[] = $member; $members_confirmed[] = $member;
} }
@ -118,74 +128,74 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
$page[] = table(array( $page[] = table(array(
'Nick' => _("Nick"), 'Nick' => _("Nick"),
'DECT' => _("DECT"), 'DECT' => _("DECT"),
'actions' => "" 'actions' => ""
), $coordinators); ), $coordinators);
} }
$page[] = '<h3>' . _("Members") . '</h3>'; $page[] = '<h3>' . _("Members") . '</h3>';
if ($admin_user_angeltypes) if ($admin_user_angeltypes)
$page[] = buttons(array( $page[] = buttons(array(
button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("Add"), 'add') button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("Add"), 'add')
)); ));
$page[] = table(array( $page[] = table(array(
'Nick' => _("Nick"), 'Nick' => _("Nick"),
'DECT' => _("DECT"), 'DECT' => _("DECT"),
'actions' => "" 'actions' => ""
), $members_confirmed); ), $members_confirmed);
if ($admin_user_angeltypes && $angeltype['restricted'] && count($members_unconfirmed) > 0) { if ($admin_user_angeltypes && $angeltype['restricted'] && count($members_unconfirmed) > 0) {
$page[] = '<h3>' . _("Unconfirmed") . '</h3>'; $page[] = '<h3>' . _("Unconfirmed") . '</h3>';
$page[] = buttons(array( $page[] = buttons(array(
button(page_link_to('user_angeltypes') . '&action=confirm_all&angeltype_id=' . $angeltype['id'], _("confirm all"), 'ok'), 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') button(page_link_to('user_angeltypes') . '&action=delete_all&angeltype_id=' . $angeltype['id'], _("deny all"), 'cancel')
)); ));
$page[] = table(array( $page[] = table(array(
'Nick' => _("Nick"), 'Nick' => _("Nick"),
'DECT' => _("DECT"), 'DECT' => _("DECT"),
'actions' => "" 'actions' => ""
), $members_unconfirmed); ), $members_unconfirmed);
} }
return page_with_title(sprintf(_("Team %s"), $angeltype['name']), $page); return page_with_title(sprintf(_("Team %s"), $angeltype['name']), $page);
} }
/** /**
* Display the list of angeltypes. * Display the list of angeltypes.
* *
* @param array $angeltypes * @param array $angeltypes
*/ */
function AngelTypes_list_view($angeltypes, $admin_angeltypes) { function AngelTypes_list_view($angeltypes, $admin_angeltypes) {
return page_with_title(angeltypes_title(), array( return page_with_title(angeltypes_title(), array(
msg(), msg(),
buttons(array( buttons(array(
$admin_angeltypes ? button(page_link_to('angeltypes') . '&action=edit', _("New angeltype"), 'add') : '', $admin_angeltypes ? button(page_link_to('angeltypes') . '&action=edit', _("New angeltype"), 'add') : '',
button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description")) button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description"))
)), )),
table(array( table(array(
'name' => _("Name"), 'name' => _("Name"),
'restricted' => glyph('lock') . _("Restricted"), 'restricted' => glyph('lock') . _("Restricted"),
'membership' => _("Membership"), 'membership' => _("Membership"),
'actions' => "" 'actions' => ""
), $angeltypes) ), $angeltypes)
)); ));
} }
function AngelTypes_about_view($angeltypes, $user_logged_in) { function AngelTypes_about_view($angeltypes, $user_logged_in) {
global $faq_url; global $faq_url;
$content = array( $content = array(
buttons(array( buttons(array(
! $user_logged_in ? button(page_link_to('register'), register_title()) : '', ! $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('login'), login_title()) : '',
$user_logged_in ? button(page_link_to('angeltypes'), angeltypes_title(), 'back') : '', $user_logged_in ? button(page_link_to('angeltypes'), angeltypes_title(), 'back') : '',
button($faq_url, _("FAQ"), "btn-primary") button($faq_url, _("FAQ"), "btn-primary")
)), )),
'<p>' . _("Here is the list of teams and their tasks. If you have questions, read the FAQ.") . '</p>', '<p>' . _("Here is the list of teams and their tasks. If you have questions, read the FAQ.") . '</p>',
'<hr />' '<hr />'
); );
$parsedown = new Parsedown(); $parsedown = new Parsedown();
foreach ($angeltypes as $angeltype) { foreach ($angeltypes as $angeltype) {
$content[] = '<h2>' . $angeltype['name'] . '</h2>'; $content[] = '<h2>' . $angeltype['name'] . '</h2>';
if (isset($angeltype['user_angeltype_id'])) { if (isset($angeltype['user_angeltype_id'])) {
$buttons = array(); $buttons = array();
if ($angeltype['user_angeltype_id'] != null) if ($angeltype['user_angeltype_id'] != null)
@ -194,14 +204,14 @@ function AngelTypes_about_view($angeltypes, $user_logged_in) {
$buttons[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), 'add'); $buttons[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), 'add');
$content[] = buttons($buttons); $content[] = buttons($buttons);
} }
if ($angeltype['restricted']) if ($angeltype['restricted'])
$content[] = info(_("This angeltype is restricted by double-opt-in by a team coordinator. Please show up at the according introduction meetings."), true); $content[] = info(_("This angeltype is restricted by double-opt-in by a team coordinator. Please show up at the according introduction meetings."), true);
if ($angeltype['description'] != "") if ($angeltype['description'] != "")
$content[] = '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>'; $content[] = '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
$content[] = '<hr />'; $content[] = '<hr />';
} }
return page_with_title(_("Teams/Job description"), $content); return page_with_title(_("Teams/Job description"), $content);
} }

@ -16,7 +16,7 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
$class = 'progress-bar-success'; $class = 'progress-bar-success';
$needed_angels .= '<div class="list-group-item">'; $needed_angels .= '<div class="list-group-item">';
$needed_angels .= '<div class="pull-right">' . button(page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $needed_angeltype['TID'], _('Sign up')) . '</div>'; $needed_angels .= '<div class="pull-right">' . button(page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $needed_angeltype['TID'], _('Sign up')) . '</div>';
$needed_angels .= '<h3>' . $angeltypes[$needed_angeltype['TID']]['name'] . '</h3>'; $needed_angels .= '<h3>' . AngelType_name_render($angeltypes[$needed_angeltype['TID']]) . '</h3>';
$needed_angels .= progress_bar(0, $needed_angeltype['count'], $needed_angeltype['taken'], $class, $needed_angeltype['taken'] . ' / ' . $needed_angeltype['count']); $needed_angels .= progress_bar(0, $needed_angeltype['count'], $needed_angeltype['taken'], $class, $needed_angeltype['taken'] . ' / ' . $needed_angeltype['count']);
$angels = []; $angels = [];
@ -47,7 +47,7 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
button(shift_delete_link($shift), glyph('trash') . _('delete')) button(shift_delete_link($shift), glyph('trash') . _('delete'))
]) : '', ]) : '',
div('row', [ div('row', [
div('col-sm-3', [ div('col-sm-3 col-xs-6', [
'<h4>' . _('Start') . '</h4>', '<h4>' . _('Start') . '</h4>',
'<p class="lead">', '<p class="lead">',
date('y-m-d', $shift['start']), date('y-m-d', $shift['start']),
@ -55,7 +55,7 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
date('H:i', $shift['start']), date('H:i', $shift['start']),
'</p>' '</p>'
]), ]),
div('col-sm-3', [ div('col-sm-3 col-xs-6', [
'<h4>' . _('End') . '</h4>', '<h4>' . _('End') . '</h4>',
'<p class="lead">', '<p class="lead">',
date('y-m-d', $shift['end']), date('y-m-d', $shift['end']),
@ -63,11 +63,11 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
date('H:i', $shift['end']), date('H:i', $shift['end']),
'</p>' '</p>'
]), ]),
div('col-sm-3', [ div('col-sm-3 col-xs-6', [
'<h4>' . _('Location') . '</h4>', '<h4>' . _('Location') . '</h4>',
'<p class="lead">' . $room['Name'] . '</p>' '<p class="lead">' . $room['Name'] . '</p>'
]), ]),
div('col-sm-3', [ div('col-sm-3 col-xs-6', [
'<h4>' . _('More info') . '</h4>', '<h4>' . _('More info') . '</h4>',
$shift['URL'] != '' ? '<a href="' . $shift['URL'] . '">' . $shift['URL'] . '</a>' : '' $shift['URL'] != '' ? '<a href="' . $shift['URL'] . '">' . $shift['URL'] . '</a>' : ''
]) ])

Loading…
Cancel
Save