#337: Added routing

This commit is contained in:
Igor Scheller 2017-08-28 16:21:10 +02:00
parent e1762e7764
commit 73175e2b64
38 changed files with 662 additions and 316 deletions

View File

@ -20,6 +20,9 @@ return [
// Set to development to enable debugging messages // Set to development to enable debugging messages
'environment' => 'production', 'environment' => 'production',
// Site URL, used to generate links on page (https://example.com/[sub-dir/])
'url' => null,
// URL to the angel faq and job description // URL to the angel faq and job description
'faq_url' => 'https://events.ccc.de/congress/2013/wiki/Static:Volunteers', 'faq_url' => 'https://events.ccc.de/congress/2013/wiki/Static:Volunteers',

9
includes/autoload.php Normal file
View File

@ -0,0 +1,9 @@
<?php
// Check for autoloader
if (!is_readable(__DIR__ . '/../vendor/autoload.php')) {
die('Please run composer.phar install');
}
// Include composer autoloader
require_once __DIR__ . '/../vendor/autoload.php';

View File

@ -42,7 +42,7 @@ function angeltypes_controller()
*/ */
function angeltype_link($angeltype_id) function angeltype_link($angeltype_id)
{ {
return page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype_id; return page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype_id]);
} }
/** /**
@ -211,17 +211,21 @@ function angeltypes_list_controller()
foreach ($angeltypes as &$angeltype) { foreach ($angeltypes as &$angeltype) {
$actions = [ $actions = [
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('view'), 'btn-xs') button(
page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
_('view'),
'btn-xs'
)
]; ];
if (in_array('admin_angel_types', $privileges)) { if (in_array('admin_angel_types', $privileges)) {
$actions[] = button( $actions[] = button(
page_link_to('angeltypes') . '&action=edit&angeltype_id=' . $angeltype['id'], page_link_to('angeltypes', ['action' => 'edit', 'angeltype_id' => $angeltype['id']]),
_('edit'), _('edit'),
'btn-xs' 'btn-xs'
); );
$actions[] = button( $actions[] = button(
page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'], page_link_to('angeltypes', ['action' => 'delete', 'angeltype_id' => $angeltype['id']]),
_('delete'), _('delete'),
'btn-xs' 'btn-xs'
); );
@ -230,13 +234,15 @@ function angeltypes_list_controller()
$angeltype['membership'] = AngelType_render_membership($angeltype); $angeltype['membership'] = AngelType_render_membership($angeltype);
if ($angeltype['user_angeltype_id'] != null) { if ($angeltype['user_angeltype_id'] != null) {
$actions[] = button( $actions[] = button(
page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $angeltype['user_angeltype_id'], page_link_to('user_angeltypes',
['action' => 'delete', 'user_angeltype_id' => $angeltype['user_angeltype_id']]
),
_('leave'), _('leave'),
'btn-xs' 'btn-xs'
); );
} else { } else {
$actions[] = button( $actions[] = button(
page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], page_link_to('user_angeltypes', ['action' => 'add', 'angeltype_id' => $angeltype['id']]),
_('join'), _('join'),
'btn-xs' 'btn-xs'
); );
@ -245,7 +251,11 @@ function angeltypes_list_controller()
$angeltype['restricted'] = $angeltype['restricted'] ? glyph('lock') : ''; $angeltype['restricted'] = $angeltype['restricted'] ? glyph('lock') : '';
$angeltype['no_self_signup'] = $angeltype['no_self_signup'] ? '' : glyph('share'); $angeltype['no_self_signup'] = $angeltype['no_self_signup'] ? '' : glyph('share');
$angeltype['name'] = '<a href="' . page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'] . '">' . $angeltype['name'] . '</a>'; $angeltype['name'] = '<a href="'
. page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']])
. '">'
. $angeltype['name']
. '</a>';
$angeltype['actions'] = table_buttons($actions); $angeltype['actions'] = table_buttons($actions);
} }

View File

@ -1,4 +1,5 @@
<?php <?php
use Engelsystem\ShiftsFilter; use Engelsystem\ShiftsFilter;
use Engelsystem\ShiftsFilterRenderer; use Engelsystem\ShiftsFilterRenderer;
@ -91,7 +92,7 @@ function rooms_controller()
*/ */
function room_link($room) function room_link($room)
{ {
return page_link_to('rooms') . '&action=view&room_id=' . $room['RID']; return page_link_to('rooms', ['action' => 'view', 'room_id' => $room['RID']]);
} }
/** /**
@ -100,7 +101,7 @@ function room_link($room)
*/ */
function room_edit_link($room) function room_edit_link($room)
{ {
return page_link_to('admin_rooms') . '&show=edit&id=' . $room['RID']; return page_link_to('admin_rooms', ['show' => 'edit', 'id' => $room['RID']]);
} }
/** /**

View File

@ -1,4 +1,5 @@
<?php <?php
use Engelsystem\ShiftSignupState; use Engelsystem\ShiftSignupState;
/** /**
@ -7,7 +8,7 @@ use Engelsystem\ShiftSignupState;
*/ */
function shift_link($shift) function shift_link($shift)
{ {
$link = page_link_to('shifts') . '&action=view'; $link = page_link_to('shifts', ['action' => 'view']);
if (isset($shift['SID'])) { if (isset($shift['SID'])) {
$link .= '&shift_id=' . $shift['SID']; $link .= '&shift_id=' . $shift['SID'];
} }
@ -20,7 +21,7 @@ function shift_link($shift)
*/ */
function shift_delete_link($shift) function shift_delete_link($shift)
{ {
return page_link_to('user_shifts') . '&delete_shift=' . $shift['SID']; return page_link_to('user_shifts', ['delete_shift' => $shift['SID']]);
} }
/** /**
@ -29,7 +30,7 @@ function shift_delete_link($shift)
*/ */
function shift_edit_link($shift) function shift_edit_link($shift)
{ {
return page_link_to('user_shifts') . '&edit_shift=' . $shift['SID']; return page_link_to('user_shifts', ['edit_shift' => $shift['SID']]);
} }
/** /**
@ -228,7 +229,9 @@ function shift_delete_controller()
date('Y-m-d H:i', $shift['start']), date('Y-m-d H:i', $shift['start']),
date('H:i', $shift['end']) date('H:i', $shift['end'])
), true), ), true),
'<a class="button" href="?p=user_shifts&delete_shift=' . $shift_id . '&delete">' . _('delete') . '</a>' '<a class="button" href="'
. page_link_to('user_shifts', ['delete_shift' => $shift_id, 'delete' => 1]) .
'">' . _('delete') . '</a>'
]); ]);
} }

View File

@ -6,7 +6,7 @@
*/ */
function shifttype_link($shifttype) function shifttype_link($shifttype)
{ {
return page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype['id']; return page_link_to('shifttypes', ['action' => 'view', 'shifttype_id' => $shifttype['id']]);
} }
/** /**
@ -107,7 +107,7 @@ function shifttype_edit_controller()
engelsystem_log('Created shifttype ' . $name); engelsystem_log('Created shifttype ' . $name);
success(_('Created shifttype.')); success(_('Created shifttype.'));
} }
redirect(page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype_id); redirect(page_link_to('shifttypes', ['action' => 'view', 'shifttype_id' => $shifttype_id]));
} }
} }

View File

@ -17,8 +17,7 @@ function user_angeltypes_unconfirmed_hint()
$unconfirmed_links = []; $unconfirmed_links = [];
foreach ($unconfirmed_user_angeltypes as $user_angeltype) { foreach ($unconfirmed_user_angeltypes as $user_angeltype) {
$unconfirmed_links[] = '<a href="' $unconfirmed_links[] = '<a href="'
. page_link_to('angeltypes') . page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $user_angeltype['angeltype_id']])
. '&action=view&angeltype_id=' . $user_angeltype['angeltype_id']
. '">' . $user_angeltype['name'] . '">' . $user_angeltype['name']
. ' (+' . $user_angeltype['count'] . ')' . ' (+' . $user_angeltype['count'] . ')'
. '</a>'; . '</a>';
@ -61,7 +60,7 @@ function user_angeltypes_delete_all_controller()
engelsystem_log(sprintf('Denied all users for angeltype %s', AngelType_name_render($angeltype))); engelsystem_log(sprintf('Denied all users for angeltype %s', AngelType_name_render($angeltype)));
success(sprintf(_('Denied all users for angeltype %s.'), AngelType_name_render($angeltype))); success(sprintf(_('Denied all users for angeltype %s.'), AngelType_name_render($angeltype)));
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']); redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
} }
return [ return [
@ -107,7 +106,7 @@ function user_angeltypes_confirm_all_controller()
engelsystem_log(sprintf('Confirmed all users for angeltype %s', AngelType_name_render($angeltype))); engelsystem_log(sprintf('Confirmed all users for angeltype %s', AngelType_name_render($angeltype)));
success(sprintf(_('Confirmed all users for angeltype %s.'), AngelType_name_render($angeltype))); success(sprintf(_('Confirmed all users for angeltype %s.'), AngelType_name_render($angeltype)));
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']); redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
} }
return [ return [
@ -167,7 +166,7 @@ function user_angeltype_confirm_controller()
User_Nick_render($user_source), User_Nick_render($user_source),
AngelType_name_render($angeltype) AngelType_name_render($angeltype)
)); ));
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']); redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
} }
return [ return [
@ -224,7 +223,7 @@ function user_angeltype_delete_controller()
engelsystem_log($success_message); engelsystem_log($success_message);
success($success_message); success($success_message);
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']); redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
} }
return [ return [
@ -290,7 +289,7 @@ function user_angeltype_update_controller()
engelsystem_log($success_message); engelsystem_log($success_message);
success($success_message); success($success_message);
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']); redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
} }
return [ return [
@ -344,7 +343,7 @@ function user_angeltype_add_controller()
AngelType_name_render($angeltype) AngelType_name_render($angeltype)
)); ));
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']); redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
} }
} }
@ -386,7 +385,7 @@ function user_angeltype_join_controller($angeltype)
)); ));
} }
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']); redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
} }
return [ return [

View File

@ -63,7 +63,7 @@ function user_driver_license_edit_link($user = null)
if ($user == null) { if ($user == null) {
return page_link_to('user_driver_licenses'); return page_link_to('user_driver_licenses');
} }
return page_link_to('user_driver_licenses') . '&user_id=' . $user['UID']; return page_link_to('user_driver_licenses', ['user_id' => $user['UID']]);
} }
/** /**

View File

@ -109,7 +109,7 @@ function users_link()
*/ */
function user_edit_link($user) function user_edit_link($user)
{ {
return page_link_to('admin_user') . '&user_id=' . $user['UID']; return page_link_to('admin_user', ['user_id' => $user['UID']]);
} }
/** /**
@ -118,7 +118,7 @@ function user_edit_link($user)
*/ */
function user_delete_link($user) function user_delete_link($user)
{ {
return page_link_to('users') . '&action=delete&user_id=' . $user['UID']; return page_link_to('users', ['action' => 'delete', 'user_id' => $user['UID']]);
} }
/** /**
@ -127,7 +127,7 @@ function user_delete_link($user)
*/ */
function user_link($user) function user_link($user)
{ {
return page_link_to('users') . '&action=view&user_id=' . $user['UID']; return page_link_to('users', ['action' => 'view', 'user_id' => $user['UID']]);
} }
/** /**
@ -363,7 +363,7 @@ function user_password_recovery_start_controller()
_('Password recovery'), _('Password recovery'),
sprintf( sprintf(
_('Please visit %s to recover your password.'), _('Please visit %s to recover your password.'),
page_link_to_absolute('user_password_recovery') . '&token=' . $token page_link_to_absolute('user_password_recovery', ['token' => $token])
) )
); );
success(_('We sent an email containing your password recovery link.')); success(_('We sent an email containing your password recovery link.'));

View File

@ -11,11 +11,7 @@ use Engelsystem\Renderer\Renderer;
* This file includes all needed functions, connects to the db etc. * This file includes all needed functions, connects to the db etc.
*/ */
if (!is_readable(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/autoload.php';
die('Please run composer.phar install');
}
require __DIR__ . '/../vendor/autoload.php';
/** /**
* Load configuration * Load configuration
@ -38,7 +34,7 @@ date_default_timezone_set($config->get('timezone'));
* Initialize Request * Initialize Request
*/ */
$request = new Request(); $request = new Request();
$request->create(); $request->create($_GET, $_POST, $_SERVER, config('url'));
$request::setInstance($request); $request::setInstance($request);
/** /**

View File

@ -82,9 +82,13 @@ function admin_active()
$limit = ''; $limit = '';
$msg = success(_('Marked angels.'), true); $msg = success(_('Marked angels.'), true);
} else { } else {
$set_active = '<a href="' . page_link_to('admin_active') . '&amp;serach=' . $search . '">&laquo; ' $set_active = '<a href="' . page_link_to('admin_active', ['search' => $search]) . '">&laquo; '
. _('back') . '</a> | <a href="' . _('back')
. page_link_to('admin_active') . '&amp;search=' . $search . '&amp;count=' . $count . '&amp;set_active&amp;ack">' . '</a> | <a href="'
. page_link_to(
'admin_active',
['search' => $search, 'count' => $count, 'set_active' => 1, 'ack' => 1]
) . '">'
. _('apply') . _('apply')
. '</a>'; . '</a>';
} }
@ -176,28 +180,46 @@ function admin_active()
$actions = []; $actions = [];
if ($usr['Aktiv'] == 0) { if ($usr['Aktiv'] == 0) {
$actions[] = '<a href="' $parameters = [
. page_link_to('admin_active') . '&amp;active=' . $usr['UID'] 'active' => $usr['UID'],
. ($show_all_shifts ? '&amp;show_all_shifts=' : '') . '&amp;search=' . $search . '">' 'search' => $search,
];
if ($show_all_shifts) {
$parameters['show_all_shifts'] = 1;
}
$actions[] = '<a href="' . page_link_to('admin_active', $parameters) . '">'
. _('set active') . _('set active')
. '</a>'; . '</a>';
} }
if ($usr['Aktiv'] == 1 && $usr['Tshirt'] == 0) { if ($usr['Aktiv'] == 1 && $usr['Tshirt'] == 0) {
$actions[] = '<a href="' $parametersRemove = [
. page_link_to('admin_active') . '&amp;not_active=' . $usr['UID'] 'not_active' => $usr['UID'],
. ($show_all_shifts ? '&amp;show_all_shifts=' : '') . '&amp;search=' . $search . '">' 'search' => $search,
];
$parametersShirt = [
'tshirt' => $usr['UID'],
'search' => $search,
];
if ($show_all_shifts) {
$parametersRemove['show_all_shifts'] = 1;
$parametersShirt['show_all_shifts'] = 1;
}
$actions[] = '<a href="' . page_link_to('admin_active', $parametersRemove) . '">'
. _('remove active') . _('remove active')
. '</a>'; . '</a>';
$actions[] = '<a href="' $actions[] = '<a href="' . page_link_to('admin_active', $parametersShirt) . '">'
. page_link_to('admin_active') . '&amp;tshirt=' . $usr['UID']
. ($show_all_shifts ? '&amp;show_all_shifts=' : '') . '&amp;search=' . $search . '">'
. _('got t-shirt') . _('got t-shirt')
. '</a>'; . '</a>';
} }
if ($usr['Tshirt'] == 1) { if ($usr['Tshirt'] == 1) {
$actions[] = '<a href="' $parameters = [
. page_link_to('admin_active') . '&amp;not_tshirt=' . $usr['UID'] 'not_tshirt' => $usr['UID'],
. ($show_all_shifts ? '&amp;show_all_shifts=' : '') . '&amp;search=' . $search . '">' 'search' => $search,
];
if ($show_all_shifts) {
$parameters['show_all_shifts'] = 1;
}
$actions[] = '<a href="' . page_link_to('admin_active', $parameters) . '">'
. _('remove t-shirt') . _('remove t-shirt')
. '</a>'; . '</a>';
} }

View File

@ -92,8 +92,14 @@ function admin_arrive()
$usr['rendered_arrival_date'] = $usr['arrival_date'] > 0 ? date('Y-m-d', $usr['arrival_date']) : '-'; $usr['rendered_arrival_date'] = $usr['arrival_date'] > 0 ? date('Y-m-d', $usr['arrival_date']) : '-';
$usr['arrived'] = $usr['Gekommen'] == 1 ? _('yes') : ''; $usr['arrived'] = $usr['Gekommen'] == 1 ? _('yes') : '';
$usr['actions'] = $usr['Gekommen'] == 1 $usr['actions'] = $usr['Gekommen'] == 1
? '<a href="' . page_link_to('admin_arrive') . '&reset=' . $usr['UID'] . '&search=' . $search . '">' . _('reset') . '</a>' ? '<a href="' . page_link_to(
: '<a href="' . page_link_to('admin_arrive') . '&arrived=' . $usr['UID'] . '&search=' . $search . '">' . _('arrived') . '</a>'; 'admin_arrive',
['reset' => $usr['UID'], 'search' => $search]
) . '">' . _('reset') . '</a>'
: '<a href="' . page_link_to(
'admin_arrive',
['arrived' => $usr['UID'], 'search' => $search]
) . '">' . _('arrived') . '</a>';
if ($usr['arrival_date'] > 0) { if ($usr['arrival_date'] > 0) {
$day = date('Y-m-d', $usr['arrival_date']); $day = date('Y-m-d', $usr['arrival_date']);

View File

@ -94,7 +94,7 @@ function admin_free()
'email' => $usr['email_by_human_allowed'] ? $usr['email'] : glyph('eye-close'), 'email' => $usr['email_by_human_allowed'] ? $usr['email'] : glyph('eye-close'),
'actions' => 'actions' =>
in_array('admin_user', $privileges) in_array('admin_user', $privileges)
? button(page_link_to('admin_user') . '&amp;id=' . $usr['UID'], _('edit'), 'btn-xs') ? button(page_link_to('admin_user', ['id' => $usr['UID']]), _('edit'), 'btn-xs')
: '' : ''
]; ];
} }

View File

@ -38,7 +38,8 @@ function admin_groups()
'name' => $group['Name'], 'name' => $group['Name'],
'privileges' => join(', ', $privileges_html), 'privileges' => join(', ', $privileges_html),
'actions' => button( 'actions' => button(
page_link_to('admin_groups') . '&action=edit&id=' . $group['UID'], page_link_to('admin_groups',
['action' => 'edit', 'id' => $group['UID']]),
_('edit'), _('edit'),
'btn-xs' 'btn-xs'
) )
@ -93,7 +94,10 @@ function admin_groups()
$privileges_form[] = form_submit('submit', _('Save')); $privileges_form[] = form_submit('submit', _('Save'));
$html .= page_with_title(_('Edit group'), [ $html .= page_with_title(_('Edit group'), [
form($privileges_form, page_link_to('admin_groups') . '&action=save&id=' . $group_id) form(
$privileges_form,
page_link_to('admin_groups', ['action' => 'save', 'id' => $group_id])
)
]); ]);
} else { } else {
return error('No Group found.', true); return error('No Group found.', true);

View File

@ -31,16 +31,21 @@ function admin_news()
$news = array_shift($news); $news = array_shift($news);
$user_source = User($news['UID']); $user_source = User($news['UID']);
$html .= form([ $html .= form(
[
form_info(_('Date'), date('Y-m-d H:i', $news['Datum'])), form_info(_('Date'), date('Y-m-d H:i', $news['Datum'])),
form_info(_('Author'), User_Nick_render($user_source)), form_info(_('Author'), User_Nick_render($user_source)),
form_text('eBetreff', _('Subject'), $news['Betreff']), form_text('eBetreff', _('Subject'), $news['Betreff']),
form_textarea('eText', _('Message'), $news['Text']), form_textarea('eText', _('Message'), $news['Text']),
form_checkbox('eTreffen', _('Meeting'), $news['Treffen'] == 1, 1), form_checkbox('eTreffen', _('Meeting'), $news['Treffen'] == 1, 1),
form_submit('submit', _('Save')) form_submit('submit', _('Save'))
], page_link_to('admin_news&action=save&id=' . $news_id)); ],
page_link_to('admin_news', ['action' => 'save', 'id' => $news_id])
);
$html .= '<a class="btn btn-danger" href="' . page_link_to('admin_news&action=delete&id=' . $news_id) . '">' $html .= '<a class="btn btn-danger" href="'
. page_link_to('admin_news', ['action' => 'delete', 'id' => $news_id])
. '">'
. '<span class="glyphicon glyphicon-trash"></span> ' . _('Delete') . '<span class="glyphicon glyphicon-trash"></span> ' . _('Delete')
. '</a>'; . '</a>';
break; break;

View File

@ -52,9 +52,9 @@ function admin_questions()
'answer' => form([ 'answer' => form([
form_textarea('answer', '', ''), form_textarea('answer', '', ''),
form_submit('submit', _('Save')) form_submit('submit', _('Save'))
], page_link_to('admin_questions') . '&action=answer&id=' . $question['QID']), ], page_link_to('admin_questions', ['action' => 'answer', 'id' => $question['QID']])),
'actions' => button( 'actions' => button(
page_link_to('admin_questions') . '&action=delete&id=' . $question['QID'], page_link_to('admin_questions', ['action' => 'delete', 'id' => $question['QID']]),
_('delete'), _('delete'),
'btn-xs' 'btn-xs'
) )
@ -72,7 +72,7 @@ function admin_questions()
'answered_by' => User_Nick_render($answer_user_source), 'answered_by' => User_Nick_render($answer_user_source),
'answer' => str_replace("\n", '<br />', $question['Answer']), 'answer' => str_replace("\n", '<br />', $question['Answer']),
'actions' => button( 'actions' => button(
page_link_to('admin_questions') . '&action=delete&id=' . $question['QID'], page_link_to('admin_questions', ['action' => 'delete', 'id' => $question['QID']]),
_('delete'), _('delete'),
'btn-xs' 'btn-xs'
) )

View File

@ -25,8 +25,8 @@ function admin_rooms()
'from_pentabarf' => $room['FromPentabarf'] == 'Y' ? '&#10003;' : '', 'from_pentabarf' => $room['FromPentabarf'] == 'Y' ? '&#10003;' : '',
'public' => $room['show'] == 'Y' ? '&#10003;' : '', 'public' => $room['show'] == 'Y' ? '&#10003;' : '',
'actions' => table_buttons([ 'actions' => table_buttons([
button(page_link_to('admin_rooms') . '&show=edit&id=' . $room['RID'], _('edit'), 'btn-xs'), button(page_link_to('admin_rooms', ['show' => 'edit', 'id' => $room['RID']]), _('edit'), 'btn-xs'),
button(page_link_to('admin_rooms') . '&show=delete&id=' . $room['RID'], _('delete'), 'btn-xs') button(page_link_to('admin_rooms', ['show' => 'delete', 'id' => $room['RID']]), _('delete'), 'btn-xs')
]) ])
]; ];
} }
@ -227,7 +227,7 @@ function admin_rooms()
sprintf(_('Do you want to delete room %s?'), $name), sprintf(_('Do you want to delete room %s?'), $name),
buttons([ buttons([
button( button(
page_link_to('admin_rooms') . '&show=delete&id=' . $room_id . '&ack', page_link_to('admin_rooms', ['show' => 'delete', 'id' => $room_id, 'ack' => 1]),
_('Delete'), _('Delete'),
'delete btn-danger' 'delete btn-danger'
) )
@ -238,7 +238,7 @@ function admin_rooms()
return page_with_title(admin_rooms_title(), [ return page_with_title(admin_rooms_title(), [
buttons([ buttons([
button(page_link_to('admin_rooms') . '&show=edit', _('add')) button(page_link_to('admin_rooms', ['show' => 'edit']), _('add'))
]), ]),
msg(), msg(),
table([ table([

View File

@ -46,25 +46,27 @@ function admin_user()
. 'Wenn T-Shirt ein \'Ja\' enth&auml;lt, bedeutet dies, dass der Engel ' . 'Wenn T-Shirt ein \'Ja\' enth&auml;lt, bedeutet dies, dass der Engel '
. 'bereits sein T-Shirt erhalten hat.<br /><br />' . "\n"; . 'bereits sein T-Shirt erhalten hat.<br /><br />' . "\n";
$html .= '<form action="' . page_link_to('admin_user') . '&action=save&id=' . $user_id . '" method="post">' . "\n"; $html .= '<form action="'
. page_link_to('admin_user', ['action' => 'save', 'id' => $user_id])
. '" method="post">' . "\n";
$html .= '<table border="0">' . "\n"; $html .= '<table border="0">' . "\n";
$html .= '<input type="hidden" name="Type" value="Normal">' . "\n"; $html .= '<input type="hidden" name="Type" value="Normal">' . "\n";
$html .= '<tr><td>' . "\n"; $html .= '<tr><td>' . "\n";
$html .= '<table>' . "\n"; $html .= '<table>' . "\n";
$html .= ' <tr><td>Nick</td><td>' . '<input type="text" size="40" name="eNick" value="' . $user_source['Nick'] . '" class="form-control"></td></tr>' . "\n"; $html .= ' <tr><td>Nick</td><td>' . '<input size="40" name="eNick" value="' . $user_source['Nick'] . '" class="form-control"></td></tr>' . "\n";
$html .= ' <tr><td>Last login</td><td><p class="help-block">' $html .= ' <tr><td>Last login</td><td><p class="help-block">'
. date('Y-m-d H:i', $user_source['lastLogIn']) . date('Y-m-d H:i', $user_source['lastLogIn'])
. '</p></td></tr>' . "\n"; . '</p></td></tr>' . "\n";
$html .= ' <tr><td>Name</td><td>' . '<input type="text" size="40" name="eName" value="' . $user_source['Name'] . '" class="form-control"></td></tr>' . "\n"; $html .= ' <tr><td>Name</td><td>' . '<input size="40" name="eName" value="' . $user_source['Name'] . '" class="form-control"></td></tr>' . "\n";
$html .= ' <tr><td>Vorname</td><td>' . '<input type="text" size="40" name="eVorname" value="' . $user_source['Vorname'] . '" class="form-control"></td></tr>' . "\n"; $html .= ' <tr><td>Vorname</td><td>' . '<input size="40" name="eVorname" value="' . $user_source['Vorname'] . '" class="form-control"></td></tr>' . "\n";
$html .= ' <tr><td>Alter</td><td>' . '<input type="text" size="5" name="eAlter" value="' . $user_source['Alter'] . '" class="form-control"></td></tr>' . "\n"; $html .= ' <tr><td>Alter</td><td>' . '<input size="5" name="eAlter" value="' . $user_source['Alter'] . '" class="form-control"></td></tr>' . "\n";
$html .= ' <tr><td>Telefon</td><td>' . '<input type="text" size="40" name="eTelefon" value="' . $user_source['Telefon'] . '" class="form-control"></td></tr>' . "\n"; $html .= ' <tr><td>Telefon</td><td>' . '<input size="40" name="eTelefon" value="' . $user_source['Telefon'] . '" class="form-control"></td></tr>' . "\n";
$html .= ' <tr><td>Handy</td><td>' . '<input type="text" size="40" name="eHandy" value="' . $user_source['Handy'] . '" class="form-control"></td></tr>' . "\n"; $html .= ' <tr><td>Handy</td><td>' . '<input size="40" name="eHandy" value="' . $user_source['Handy'] . '" class="form-control"></td></tr>' . "\n";
$html .= ' <tr><td>DECT</td><td>' . '<input type="text" size="4" name="eDECT" value="' . $user_source['DECT'] . '" class="form-control"></td></tr>' . "\n"; $html .= ' <tr><td>DECT</td><td>' . '<input size="4" name="eDECT" value="' . $user_source['DECT'] . '" class="form-control"></td></tr>' . "\n";
if ($user_source['email_by_human_allowed']) { if ($user_source['email_by_human_allowed']) {
$html .= " <tr><td>email</td><td>" . '<input type="text" size="40" name="eemail" value="' . $user_source['email'] . '" class="form-control"></td></tr>' . "\n"; $html .= " <tr><td>email</td><td>" . '<input size="40" name="eemail" value="' . $user_source['email'] . '" class="form-control"></td></tr>' . "\n";
} }
$html .= " <tr><td>jabber</td><td>" . '<input type="text" size="40" name="ejabber" value="' . $user_source['jabber'] . '" class="form-control"></td></tr>' . "\n"; $html .= " <tr><td>jabber</td><td>" . '<input size="40" name="ejabber" value="' . $user_source['jabber'] . '" class="form-control"></td></tr>' . "\n";
$html .= ' <tr><td>Size</td><td>' $html .= ' <tr><td>Size</td><td>'
. html_select_key('size', 'eSize', $tshirt_sizes, $user_source['Size']) . '</td></tr>' . "\n"; . html_select_key('size', 'eSize', $tshirt_sizes, $user_source['Size']) . '</td></tr>' . "\n";
@ -91,7 +93,7 @@ function admin_user()
$html .= ' <tr><td>T-Shirt</td><td>' . "\n"; $html .= ' <tr><td>T-Shirt</td><td>' . "\n";
$html .= html_options('eTshirt', $options, $user_source['Tshirt']) . '</td></tr>' . "\n"; $html .= html_options('eTshirt', $options, $user_source['Tshirt']) . '</td></tr>' . "\n";
$html .= ' <tr><td>Hometown</td><td>' . '<input type="text" size="40" name="Hometown" value="' . $user_source['Hometown'] . '" class="form-control"></td></tr>' . "\n"; $html .= ' <tr><td>Hometown</td><td>' . '<input size="40" name="Hometown" value="' . $user_source['Hometown'] . '" class="form-control"></td></tr>' . "\n";
$html .= '</table>' . "\n" . '</td><td valign="top"></td></tr>'; $html .= '</table>' . "\n" . '</td><td valign="top"></td></tr>';
@ -105,7 +107,8 @@ function admin_user()
$html .= form_info('', _('Please visit the angeltypes page or the users profile to manage users angeltypes.')); $html .= form_info('', _('Please visit the angeltypes page or the users profile to manage users angeltypes.'));
$html .= 'Hier kannst Du das Passwort dieses Engels neu setzen:<form action="' $html .= 'Hier kannst Du das Passwort dieses Engels neu setzen:<form action="'
. page_link_to('admin_user') . '&action=change_pw&id=' . $user_id . '" method="post">' . "\n"; . page_link_to('admin_user', ['action' => 'change_pw', 'id' => $user_id])
. '" method="post">' . "\n";
$html .= '<table>' . "\n"; $html .= '<table>' . "\n";
$html .= ' <tr><td>Passwort</td><td>' . '<input type="password" size="40" name="new_pw" value="" class="form-control"></td></tr>' . "\n"; $html .= ' <tr><td>Passwort</td><td>' . '<input type="password" size="40" name="new_pw" value="" class="form-control"></td></tr>' . "\n";
$html .= ' <tr><td>Wiederholung</td><td>' . '<input type="password" size="40" name="new_pw2" value="" class="form-control"></td></tr>' . "\n"; $html .= ' <tr><td>Wiederholung</td><td>' . '<input type="password" size="40" name="new_pw2" value="" class="form-control"></td></tr>' . "\n";
@ -134,7 +137,8 @@ function admin_user()
if ($user_id != $user['UID'] && $my_highest_group <= $his_highest_group) { if ($user_id != $user['UID'] && $my_highest_group <= $his_highest_group) {
$html .= 'Hier kannst Du die Benutzergruppen des Engels festlegen:<form action="' $html .= 'Hier kannst Du die Benutzergruppen des Engels festlegen:<form action="'
. page_link_to('admin_user') . '&action=save_groups&id=' . $user_id . '" method="post">' . "\n"; . page_link_to('admin_user', ['action' => 'save_groups', 'id' => $user_id])
. '" method="post">' . "\n";
$html .= '<table>'; $html .= '<table>';
$groups = DB::select(' $groups = DB::select('

View File

@ -328,7 +328,7 @@ function guest_register()
'angel_types', 'angel_types',
_('What do you want to do?') . sprintf( _('What do you want to do?') . sprintf(
' (<a href="%s">%s</a>)', ' (<a href="%s">%s</a>)',
page_link_to('angeltypes') . '&action=about', page_link_to('angeltypes', ['action' => 'about']),
_('Description of job types') _('Description of job types')
), ),
$angel_types, $angel_types,
@ -467,7 +467,10 @@ function guest_login()
heading(_('What can I do?'), 2), heading(_('What can I do?'), 2),
'<p>' . _('Please read about the jobs you can do to help us.') . '</p>', '<p>' . _('Please read about the jobs you can do to help us.') . '</p>',
buttons([ buttons([
button(page_link_to('angeltypes') . '&action=about', _('Teams/Job description') . ' &raquo;') button(
page_link_to('angeltypes', ['action' => 'about']),
_('Teams/Job description') . ' &raquo;'
)
]) ])
]) ])
]) ])

View File

@ -66,9 +66,9 @@ function make_atom_entry_from_news($news_entry)
{ {
return ' <entry> return ' <entry>
<title>' . htmlspecialchars($news_entry['Betreff']) . '</title> <title>' . htmlspecialchars($news_entry['Betreff']) . '</title>
<link href="' . page_link_to_absolute('news_comments&amp;nid=') . $news_entry['ID'] . '"/> <link href="' . page_link_to_absolute('news_comments', ['nid' => $news_entry['ID']]) . '"/>
<id>' . preg_replace('#^https?://#', '', page_link_to_absolute('news')) . '-' . $news_entry['ID'] . '</id> <id>' . preg_replace('#^https?://#', '', page_link_to_absolute('news')) . '-' . $news_entry['ID'] . '</id>
<updated>' . date('Y-m-d\TH:i:sP', $news_entry['Datum']) . '</updated> <updated>' . date('Y-m-d\TH:i:sP', $news_entry['Datum']) . '</updated>
<summary type="html">' . htmlspecialchars($news_entry['Text']) . '</summary> <summary>' . htmlspecialchars($news_entry['Text']) . '</summary>
</entry>' . "\n"; </entry>' . "\n";
} }

View File

@ -92,14 +92,14 @@ function user_messages()
if ($message['RUID'] == $user['UID']) { if ($message['RUID'] == $user['UID']) {
if ($message['isRead'] == 'N') { if ($message['isRead'] == 'N') {
$messages_table_entry['actions'] = button( $messages_table_entry['actions'] = button(
page_link_to('user_messages') . '&action=read&id=' . $message['id'], page_link_to('user_messages', ['action' => 'read', 'id' => $message['id']]),
_('mark as read'), _('mark as read'),
'btn-xs' 'btn-xs'
); );
} }
} else { } else {
$messages_table_entry['actions'] = button( $messages_table_entry['actions'] = button(
page_link_to('user_messages') . '&action=delete&id=' . $message['id'], page_link_to('user_messages', ['action' => 'delete', 'id' => $message['id']]),
_('delete message'), _('delete message'),
'btn-xs' 'btn-xs'
); );
@ -119,7 +119,7 @@ function user_messages()
'text' => _('Message'), 'text' => _('Message'),
'actions' => '' 'actions' => ''
], $messages_table) ], $messages_table)
], page_link_to('user_messages') . '&action=send') ], page_link_to('user_messages', ['action' => 'send']))
]); ]);
} else { } else {
switch ($request->input('action')) { switch ($request->input('action')) {

View File

@ -38,14 +38,14 @@ function user_myshifts()
if ($request->input('reset') == 'ack') { if ($request->input('reset') == 'ack') {
User_reset_api_key($user); User_reset_api_key($user);
success(_('Key changed.')); success(_('Key changed.'));
redirect(page_link_to('users') . '&action=view&user_id=' . $shifts_user['UID']); redirect(page_link_to('users', ['action' => 'view', 'user_id' => $shifts_user['UID']]));
} }
return page_with_title(_('Reset API key'), [ return page_with_title(_('Reset API key'), [
error( error(
_('If you reset the key, the url to your iCal- and JSON-export and your atom feed changes! You have to update it in every application using one of these exports.'), _('If you reset the key, the url to your iCal- and JSON-export and your atom feed changes! You have to update it in every application using one of these exports.'),
true true
), ),
button(page_link_to('user_myshifts') . '&reset=ack', _('Continue'), 'btn-danger') button(page_link_to('user_myshifts', ['reset' => 'ack']), _('Continue'), 'btn-danger')
]); ]);
} elseif ($request->has('edit') && preg_match('/^\d*$/', $request->input('edit'))) { } elseif ($request->has('edit') && preg_match('/^\d*$/', $request->input('edit'))) {
$user_id = $request->input('edit'); $user_id = $request->input('edit');
@ -111,7 +111,7 @@ function user_myshifts()
. '. Freeloaded: ' . ($freeloaded ? 'YES Comment: ' . $freeload_comment : 'NO') . '. Freeloaded: ' . ($freeloaded ? 'YES Comment: ' . $freeload_comment : 'NO')
); );
success(_('Shift saved.')); success(_('Shift saved.'));
redirect(page_link_to('users') . '&action=view&user_id=' . $shifts_user['UID']); redirect(page_link_to('users', ['action' => 'view', 'user_id' => $shifts_user['UID']]));
} }
} }
@ -172,6 +172,6 @@ function user_myshifts()
} }
} }
redirect(page_link_to('users') . '&action=view&user_id=' . $shifts_user['UID']); redirect(page_link_to('users', ['action' => 'view', 'user_id' => $shifts_user['UID']]));
return ''; return '';
} }

View File

@ -35,8 +35,8 @@ function user_meetings()
$html = '<div class="col-md-12"><h1>' . meetings_title() . '</h1>' . msg(); $html = '<div class="col-md-12"><h1>' . meetings_title() . '</h1>' . msg();
$request = request(); $request = request();
if ($request->has('page') && preg_match('/^\d{1,}$/', $request->input('page'))) { if (preg_match('/^\d{1,}$/', $request->input('page', 0))) {
$page = $request->input('page'); $page = $request->input('page', 0);
} else { } else {
$page = 0; $page = 0;
} }
@ -57,14 +57,14 @@ function user_meetings()
$dis_rows = ceil(count(DB::select('SELECT `ID` FROM `News`')) / $display_news); $dis_rows = ceil(count(DB::select('SELECT `ID` FROM `News`')) / $display_news);
$html .= '<div class="text-center">' . '<ul class="pagination">'; $html .= '<div class="text-center">' . '<ul class="pagination">';
for ($i = 0; $i < $dis_rows; $i++) { for ($i = 0; $i < $dis_rows; $i++) {
if ($request->has('page') && $i == $request->input('page')) { if ($request->has('page') && $i == $request->input('page', 0)) {
$html .= '<li class="active">'; $html .= '<li class="active">';
} elseif (!$request->has('page') && $i == 0) { } elseif (!$request->has('page') && $i == 0) {
$html .= '<li class="active">'; $html .= '<li class="active">';
} else { } else {
$html .= '<li>'; $html .= '<li>';
} }
$html .= '<a href="' . page_link_to('user_meetings') . '&page=' . $i . '">' . ($i + 1) . '</a></li>'; $html .= '<a href="' . page_link_to('user_meetings', ['page' => $i]) . '">' . ($i + 1) . '</a></li>';
} }
$html .= '</ul></div></div>'; $html .= '</ul></div></div>';
@ -89,7 +89,7 @@ function display_news($news)
$html .= '<div class="panel-footer text-muted">'; $html .= '<div class="panel-footer text-muted">';
if (in_array('admin_news', $privileges)) { if (in_array('admin_news', $privileges)) {
$html .= '<div class="pull-right">' $html .= '<div class="pull-right">'
. button_glyph(page_link_to('admin_news') . '&action=edit&id=' . $news['ID'], 'edit', 'btn-xs') . button_glyph(page_link_to('admin_news', ['action' => 'edit', 'id' => $news['ID']]), 'edit', 'btn-xs')
. '</div>'; . '</div>';
} }
$html .= '<span class="glyphicon glyphicon-time"></span> ' . date('Y-m-d H:i', $news['Datum']) . '&emsp;'; $html .= '<span class="glyphicon glyphicon-time"></span> ' . date('Y-m-d H:i', $news['Datum']) . '&emsp;';
@ -98,7 +98,7 @@ function display_news($news)
$html .= User_Nick_render($user_source); $html .= User_Nick_render($user_source);
if ($page != 'news_comments') { if ($page != 'news_comments') {
$html .= '&emsp;<a href="' . page_link_to('news_comments') . '&nid=' . $news['ID'] . '">' $html .= '&emsp;<a href="' . page_link_to('news_comments', ['nid' => $news['ID']]) . '">'
. '<span class="glyphicon glyphicon-comment"></span> ' . '<span class="glyphicon glyphicon-comment"></span> '
. _('Comments') . ' &raquo;</a> ' . _('Comments') . ' &raquo;</a> '
. '<span class="badge">' . '<span class="badge">'
@ -167,7 +167,7 @@ function user_news_comments()
$html .= form([ $html .= form([
form_textarea('text', _('Message'), ''), form_textarea('text', _('Message'), ''),
form_submit('submit', _('Save')) form_submit('submit', _('Save'))
], page_link_to('news_comments') . '&nid=' . $news['ID']); ], page_link_to('news_comments', ['nid' => $news['ID']]));
} else { } else {
$html .= _('Invalid request.'); $html .= _('Invalid request.');
} }
@ -208,8 +208,8 @@ function user_news()
redirect(page_link_to('news')); redirect(page_link_to('news'));
} }
if ($request->has('page') && preg_match('/^\d{1,}$/', $request->input('page'))) { if (preg_match('/^\d{1,}$/', $request->input('page', 0))) {
$page = $request->input('page'); $page = $request->input('page', 0);
} else { } else {
$page = 0; $page = 0;
} }
@ -230,14 +230,14 @@ function user_news()
$dis_rows = ceil(count(DB::select('SELECT `ID` FROM `News`')) / $display_news); $dis_rows = ceil(count(DB::select('SELECT `ID` FROM `News`')) / $display_news);
$html .= '<div class="text-center">' . '<ul class="pagination">'; $html .= '<div class="text-center">' . '<ul class="pagination">';
for ($i = 0; $i < $dis_rows; $i++) { for ($i = 0; $i < $dis_rows; $i++) {
if ($request->has('page') && $i == $request->input('page')) { if ($request->has('page') && $i == $request->input('page', 0)) {
$html .= '<li class="active">'; $html .= '<li class="active">';
} elseif (!$request->has('page') && $i == 0) { } elseif (!$request->has('page') && $i == 0) {
$html .= '<li class="active">'; $html .= '<li class="active">';
} else { } else {
$html .= '<li>'; $html .= '<li>';
} }
$html .= '<a href="' . page_link_to('news') . '&page=' . $i . '">' . ($i + 1) . '</a></li>'; $html .= '<a href="' . page_link_to('news', ['page' => $i]) . '">' . ($i + 1) . '</a></li>';
} }
$html .= '</ul></div>'; $html .= '</ul></div>';

View File

@ -33,7 +33,11 @@ function user_questions()
$question['answer_user'] = User_Nick_render($answer_user_source); $question['answer_user'] = User_Nick_render($answer_user_source);
} }
return Questions_view($open_questions, $answered_questions, page_link_to('user_questions') . '&action=ask'); return Questions_view(
$open_questions,
$answered_questions,
page_link_to('user_questions', ['action' => 'ask'])
);
} else { } else {
switch ($request->input('action')) { switch ($request->input('action')) {
case 'ask': case 'ask':

View File

@ -223,15 +223,15 @@ function view_user_shifts()
'task_notice' => 'task_notice' =>
'<sup>1</sup>' '<sup>1</sup>'
. _('The tasks shown here are influenced by the angeltypes you joined already!') . _('The tasks shown here are influenced by the angeltypes you joined already!')
. ' <a href="' . page_link_to('angeltypes') . '&action=about' . '">' . ' <a href="' . page_link_to('angeltypes', ['action' => 'about']) . '">'
. _('Description of the jobs.') . _('Description of the jobs.')
. '</a>', . '</a>',
'shifts_table' => msg() . $shiftCalendarRenderer->render(), 'shifts_table' => msg() . $shiftCalendarRenderer->render(),
'ical_text' => '<h2>' . _('iCal export') . '</h2><p>' . sprintf( 'ical_text' => '<h2>' . _('iCal export') . '</h2><p>' . sprintf(
_('Export of shown shifts. <a href="%s">iCal format</a> or <a href="%s">JSON format</a> available (please keep secret, otherwise <a href="%s">reset the api key</a>).'), _('Export of shown shifts. <a href="%s">iCal format</a> or <a href="%s">JSON format</a> available (please keep secret, otherwise <a href="%s">reset the api key</a>).'),
page_link_to_absolute('ical') . '&key=' . $user['api_key'], page_link_to_absolute('ical', ['key' => $user['api_key']]),
page_link_to_absolute('shifts_json_export') . '&key=' . $user['api_key'], page_link_to_absolute('shifts_json_export', ['key' => $user['api_key']]),
page_link_to('user_myshifts') . '&reset' page_link_to('user_myshifts', ['reset' => 1])
) . '</p>', ) . '</p>',
'filter' => _('Filter') 'filter' => _('Filter')
]) ])

View File

@ -1,28 +1,32 @@
<?php <?php
use Engelsystem\UserHintsRenderer; use Engelsystem\UserHintsRenderer;
/** /**
* @param string $page * @param string $page
* @param array $parameters get parameters
* @return string * @return string
*/ */
function page_link_to($page = '') function page_link_to($page = '', $parameters = [])
{ {
if ($page == '') { $parameters = http_build_query($parameters);
return '?'; $page = ltrim($page, '/');
} $page = str_replace('_', '-', $page);
return '?p=' . $page; return '/' . $page . (!empty($parameters) ? '?' . $parameters : '');
} }
/** /**
* @TODO: remove?
* @param string $page * @param string $page
* @param array $parameters get parameters
* @return string * @return string
*/ */
function page_link_to_absolute($page) function page_link_to_absolute($page, $parameters = [])
{ {
return (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://' return (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://'
. $_SERVER['HTTP_HOST'] . $_SERVER['HTTP_HOST']
. preg_replace("/\?.*$/", '', $_SERVER['REQUEST_URI']) . preg_replace("/\?.*$/", '', $_SERVER['REQUEST_URI'])
. page_link_to($page); . page_link_to($page, $parameters);
} }
/** /**
@ -65,7 +69,7 @@ function header_toolbar()
if (isset($user)) { if (isset($user)) {
$toolbar_items[] = toolbar_item_link( $toolbar_items[] = toolbar_item_link(
page_link_to('shifts') . '&amp;action=next', page_link_to('shifts', ['action' => 'next']),
'time', 'time',
User_shift_state_render($user) User_shift_state_render($user)
); );
@ -86,7 +90,7 @@ function header_toolbar()
$toolbar_items[] = header_render_hints(); $toolbar_items[] = header_render_hints();
if (in_array('user_myshifts', $privileges)) { if (in_array('user_myshifts', $privileges)) {
$toolbar_items[] = toolbar_item_link( $toolbar_items[] = toolbar_item_link(
page_link_to('users') . '&amp;action=view', page_link_to('users', ['action' => 'view']),
' icon-icon_angel', ' icon-icon_angel',
$user['Nick'], $user['Nick'],
$page == 'users' $page == 'users'

View File

@ -50,7 +50,10 @@ function AngelType_delete_view($angeltype)
buttons([ buttons([
button(page_link_to('angeltypes'), _('cancel'), 'cancel'), button(page_link_to('angeltypes'), _('cancel'), 'cancel'),
button( button(
page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'] . '&confirmed', page_link_to(
'angeltypes',
['action' => 'delete', 'angeltype_id' => $angeltype['id'], 'confirmed' => 1]
),
_('delete'), _('delete'),
'ok' 'ok'
) )
@ -67,7 +70,6 @@ function AngelType_delete_view($angeltype)
*/ */
function AngelType_edit_view($angeltype, $supporter_mode) function AngelType_edit_view($angeltype, $supporter_mode)
{ {
$contact_info = AngelType_contact_info($angeltype);
return page_with_title(sprintf(_('Edit %s'), $angeltype['name']), [ return page_with_title(sprintf(_('Edit %s'), $angeltype['name']), [
buttons([ buttons([
button(page_link_to('angeltypes'), _('Angeltypes'), 'back') button(page_link_to('angeltypes'), _('Angeltypes'), 'back')
@ -127,7 +129,7 @@ function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes,
if ($user_angeltype == null) { if ($user_angeltype == null) {
$buttons[] = button( $buttons[] = button(
page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], page_link_to('user_angeltypes', ['action' => 'add', 'angeltype_id' => $angeltype['id']]),
_('join'), _('join'),
'add' 'add'
); );
@ -142,20 +144,22 @@ function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes,
$angeltype['name'] $angeltype['name']
)); ));
} }
$buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'], $buttons[] = button(
_('leave'), 'cancel'); page_link_to('user_angeltypes', ['action' => 'delete', 'user_angeltype_id' => $user_angeltype['id']]),
_('leave'), 'cancel'
);
} }
if ($admin_angeltypes || $supporter) { if ($admin_angeltypes || $supporter) {
$buttons[] = button( $buttons[] = button(
page_link_to('angeltypes') . '&action=edit&angeltype_id=' . $angeltype['id'], page_link_to('angeltypes', ['action' => 'edit', 'angeltype_id' => $angeltype['id']]),
_('edit'), _('edit'),
'edit' 'edit'
); );
} }
if ($admin_angeltypes) { if ($admin_angeltypes) {
$buttons[] = button( $buttons[] = button(
page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'], page_link_to('angeltypes', ['action' => 'delete', 'angeltype_id' => $angeltype['id']]),
_('delete'), _('delete'),
'delete' 'delete'
); );
@ -194,12 +198,18 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a
if ($angeltype['restricted'] && $member['confirm_user_id'] == null) { if ($angeltype['restricted'] && $member['confirm_user_id'] == null) {
$member['actions'] = table_buttons([ $member['actions'] = table_buttons([
button( button(
page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $member['user_angeltype_id'], page_link_to(
'user_angeltypes',
['action' => 'confirm', 'user_angeltype_id' => $member['user_angeltype_id']]
),
_('confirm'), _('confirm'),
'btn-xs' 'btn-xs'
), ),
button( button(
page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'], page_link_to(
'user_angeltypes',
['action' => 'delete', 'user_angeltype_id' => $member['user_angeltype_id']]
),
_('deny'), _('deny'),
'btn-xs' 'btn-xs'
) )
@ -209,7 +219,11 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a
if ($admin_angeltypes) { if ($admin_angeltypes) {
$member['actions'] = table_buttons([ $member['actions'] = table_buttons([
button( button(
page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&supporter=0', page_link_to('user_angeltypes', [
'action' => 'update',
'user_angeltype_id' => $member['user_angeltype_id'],
'supporter' => 0
]),
_('Remove supporter rights'), _('Remove supporter rights'),
'btn-xs' 'btn-xs'
) )
@ -222,11 +236,18 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a
if ($admin_user_angeltypes) { if ($admin_user_angeltypes) {
$member['actions'] = table_buttons([ $member['actions'] = table_buttons([
$admin_angeltypes $admin_angeltypes
? button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&supporter=1', ? button(page_link_to('user_angeltypes', [
'action' => 'update',
'user_angeltype_id' => $member['user_angeltype_id'],
'supporter' => 1
]),
_('Add supporter rights'), 'btn-xs') _('Add supporter rights'), 'btn-xs')
: '', : '',
button( button(
page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'], page_link_to('user_angeltypes', [
'action' => 'delete',
'user_angeltype_id' => $member['user_angeltype_id']
]),
_('remove'), _('remove'),
'btn-xs' 'btn-xs'
) )
@ -340,7 +361,14 @@ function AngelType_view(
$page[] = '<h3>' . _('Members') . '</h3>'; $page[] = '<h3>' . _('Members') . '</h3>';
if ($admin_user_angeltypes) { if ($admin_user_angeltypes) {
$page[] = buttons([ $page[] = buttons([
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($table_headers, $members_confirmed); $page[] = table($table_headers, $members_confirmed);
@ -349,12 +377,12 @@ function AngelType_view(
$page[] = '<h3>' . _('Unconfirmed') . '</h3>'; $page[] = '<h3>' . _('Unconfirmed') . '</h3>';
$page[] = buttons([ $page[] = buttons([
button( button(
page_link_to('user_angeltypes') . '&action=confirm_all&angeltype_id=' . $angeltype['id'], page_link_to('user_angeltypes', ['action' => 'confirm_all', 'angeltype_id' => $angeltype['id']]),
_('confirm all'), _('confirm all'),
'ok' 'ok'
), ),
button( button(
page_link_to('user_angeltypes') . '&action=delete_all&angeltype_id=' . $angeltype['id'], page_link_to('user_angeltypes', ['action' => 'delete_all', 'angeltype_id' => $angeltype['id']]),
_('deny all'), _('deny all'),
'cancel' 'cancel'
) )
@ -377,8 +405,10 @@ function AngelTypes_list_view($angeltypes, $admin_angeltypes)
return page_with_title(angeltypes_title(), [ return page_with_title(angeltypes_title(), [
msg(), msg(),
buttons([ buttons([
$admin_angeltypes ? button(page_link_to('angeltypes') . '&action=edit', _('New angeltype'), 'add') : '', $admin_angeltypes
button(page_link_to('angeltypes') . '&action=about', _('Teams/Job description')) ? button(page_link_to('angeltypes', ['action' => 'edit']), _('New angeltype'), 'add')
: '',
button(page_link_to('angeltypes', ['action' => 'about']), _('Teams/Job description'))
]), ]),
table([ table([
'name' => _('Name'), 'name' => _('Name'),
@ -406,13 +436,16 @@ function AngelTypes_about_view_angeltype($angeltype)
$buttons = []; $buttons = [];
if ($angeltype['user_angeltype_id'] != null) { if ($angeltype['user_angeltype_id'] != null) {
$buttons[] = button( $buttons[] = button(
page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $angeltype['user_angeltype_id'], page_link_to(
'user_angeltypes',
['action' => 'delete', 'user_angeltype_id' => $angeltype['user_angeltype_id']]
),
_('leave'), _('leave'),
'cancel' 'cancel'
); );
} else { } else {
$buttons[] = button( $buttons[] = button(
page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], page_link_to('user_angeltypes', ['action' => 'add', 'angeltype_id' => $angeltype['id']]),
_('join'), _('join'),
'add' 'add'
); );

View File

@ -9,14 +9,22 @@
function Questions_view($open_questions, $answered_questions, $ask_action) function Questions_view($open_questions, $answered_questions, $ask_action)
{ {
foreach ($open_questions as &$question) { foreach ($open_questions as &$question) {
$question['actions'] = '<a href="' . page_link_to('user_questions') . '&action=delete&id=' . $question['QID'] . '">' . _('delete') . '</a>'; $question['actions'] = '<a href="'
. page_link_to('user_questions', ['action' => 'delete', 'id' => $question['QID']])
. '">'
. _('delete')
. '</a>';
$question['Question'] = str_replace("\n", '<br />', $question['Question']); $question['Question'] = str_replace("\n", '<br />', $question['Question']);
} }
foreach ($answered_questions as &$question) { foreach ($answered_questions as &$question) {
$question['Question'] = str_replace("\n", '<br />', $question['Question']); $question['Question'] = str_replace("\n", '<br />', $question['Question']);
$question['Answer'] = str_replace("\n", '<br />', $question['Answer']); $question['Answer'] = str_replace("\n", '<br />', $question['Answer']);
$question['actions'] = '<a href="' . page_link_to('user_questions') . '&action=delete&id=' . $question['QID'] . '">' . _('delete') . '</a>'; $question['actions'] = '<a href="'
. page_link_to('user_questions', ['action' => 'delete', 'id' => $question['QID']])
. '">'
. _('delete')
. '</a>';
} }
return page_with_title(questions_title(), [ return page_with_title(questions_title(), [

View File

@ -125,7 +125,7 @@ class ShiftCalendarShiftRenderer
if (in_array('user_shifts_admin', $privileges)) { if (in_array('user_shifts_admin', $privileges)) {
$html .= '<li class="list-group-item">' . button( $html .= '<li class="list-group-item">' . button(
page_link_to('user_shifts') . '&amp;shift_id=' . $shift['SID'], page_link_to('user_shifts', ['shift_id' => $shift['SID']]),
_('Add more angels'), _('Add more angels'),
'btn-xs' 'btn-xs'
) . '</li>'; ) . '</li>';
@ -169,11 +169,13 @@ class ShiftCalendarShiftRenderer
case ShiftSignupState::ADMIN: case ShiftSignupState::ADMIN:
case ShiftSignupState::FREE: case ShiftSignupState::FREE:
// When admin or free display a link + button for sign up // 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'] . '">' $entry_list[] = '<a href="'
. page_link_to('user_shifts', ['shift_id' => $shift['SID'], 'type_id' => $angeltype['id']])
. '">'
. $inner_text . $inner_text
. '</a> ' . '</a> '
. button( . button(
page_link_to('user_shifts') . '&amp;shift_id=' . $shift['SID'] . '&amp;type_id=' . $angeltype['id'], page_link_to('user_shifts', ['shift_id' => $shift['SID'], 'type_id' => $angeltype['id']]),
_('Sign up'), 'btn-xs btn-primary' _('Sign up'), 'btn-xs btn-primary'
); );
break; break;
@ -191,7 +193,7 @@ class ShiftCalendarShiftRenderer
// Add link to join the angeltype first // Add link to join the angeltype first
$entry_list[] = $inner_text . '<br />' $entry_list[] = $inner_text . '<br />'
. button( . button(
page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], page_link_to('user_angeltypes', ['action' => 'add', 'angeltype_id' => $angeltype['id']]),
sprintf(_('Become %s'), $angeltype['name']), sprintf(_('Become %s'), $angeltype['name']),
'btn-xs' 'btn-xs'
); );
@ -232,8 +234,8 @@ class ShiftCalendarShiftRenderer
$header_buttons = ''; $header_buttons = '';
if (in_array('admin_shifts', $privileges)) { if (in_array('admin_shifts', $privileges)) {
$header_buttons = '<div class="pull-right">' . table_buttons([ $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', ['edit_shift' => $shift['SID']]), glyph('edit'), 'btn-xs'),
button(page_link_to('user_shifts') . '&delete_shift=' . $shift['SID'], glyph('trash'), 'btn-xs') button(page_link_to('user_shifts', ['delete_shift' => $shift['SID']]), glyph('trash'), 'btn-xs')
]) . '</div>'; ]) . '</div>';
} }
$shift_heading = date('H:i', $shift['start']) . ' &dash; ' $shift_heading = date('H:i', $shift['start']) . ' &dash; '

View File

@ -24,7 +24,10 @@ function ShiftType_delete_view($shifttype)
buttons([ buttons([
button(page_link_to('shifttypes'), _('cancel'), 'cancel'), button(page_link_to('shifttypes'), _('cancel'), 'cancel'),
button( button(
page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'] . '&confirmed', page_link_to(
'shifttypes',
['action' => 'delete', 'shifttype_id' => $shifttype['id'], 'confirmed' => 1]
),
_('delete'), _('delete'),
'ok btn-danger' 'ok btn-danger'
) )
@ -81,12 +84,16 @@ function ShiftType_view($shifttype, $angeltype)
buttons([ buttons([
button(page_link_to('shifttypes'), shifttypes_title(), 'back'), button(page_link_to('shifttypes'), shifttypes_title(), 'back'),
$angeltype ? button( $angeltype ? button(
page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
$angeltype['name'] $angeltype['name']
) : '', ) : '',
button(page_link_to('shifttypes') . '&action=edit&shifttype_id=' . $shifttype['id'], _('edit'), 'edit'),
button( button(
page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'], 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'),
'delete' 'delete'
) )
@ -103,11 +110,22 @@ function ShiftType_view($shifttype, $angeltype)
function ShiftTypes_list_view($shifttypes) function ShiftTypes_list_view($shifttypes)
{ {
foreach ($shifttypes as &$shifttype) { foreach ($shifttypes as &$shifttype) {
$shifttype['name'] = '<a href="' . page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype['id'] . '">' . $shifttype['name'] . '</a>'; $shifttype['name'] = '<a href="'
. page_link_to('shifttypes', ['action' => 'view', 'shifttype_id' => $shifttype['id']])
. '">'
. $shifttype['name']
. '</a>';
$shifttype['actions'] = table_buttons([ $shifttype['actions'] = table_buttons([
button(page_link_to('shifttypes') . '&action=edit&shifttype_id=' . $shifttype['id'], _('edit'), 'btn-xs'),
button( button(
page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'], 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'), _('delete'),
'btn-xs' 'btn-xs'
) )
@ -117,7 +135,7 @@ function ShiftTypes_list_view($shifttypes)
return page_with_title(shifttypes_title(), [ return page_with_title(shifttypes_title(), [
msg(), msg(),
buttons([ buttons([
button(page_link_to('shifttypes') . '&action=edit', _('New shifttype'), 'add') button(page_link_to('shifttypes', ['action' => 'edit']), _('New shifttype'), 'add')
]), ]),
table([ table([
'name' => _('Name'), 'name' => _('Name'),

View File

@ -1,4 +1,5 @@
<?php <?php
use Engelsystem\ShiftSignupState; use Engelsystem\ShiftSignupState;
/** /**
@ -41,12 +42,12 @@ function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
if ($angeltype['shift_signup_state']->isSignupAllowed()) { if ($angeltype['shift_signup_state']->isSignupAllowed()) {
return button( return button(
page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'], page_link_to('user_shifts', ['shift_id' => $shift['SID'], 'type_id' => $angeltype['id']]),
_('Sign up') _('Sign up')
); );
} elseif ($user_angeltype == null) { } elseif ($user_angeltype == null) {
return button( return button(
page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
sprintf(_('Become %s'), sprintf(_('Become %s'),
$angeltype['name']) $angeltype['name'])
); );
@ -207,12 +208,12 @@ function Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angelty
$entry .= ' <div class="btn-group">'; $entry .= ' <div class="btn-group">';
if ($user_shift_admin) { if ($user_shift_admin) {
$entry .= button_glyph( $entry .= button_glyph(
page_link_to('user_myshifts') . '&edit=' . $shift_entry['id'] . '&id=' . $shift_entry['UID'], page_link_to('user_myshifts', ['edit' => $shift_entry['id'], 'id' => $shift_entry['UID']]),
'pencil', 'pencil',
'btn-xs' 'btn-xs'
); );
} }
$entry .= button_glyph(page_link_to('user_shifts') . '&entry_id=' . $shift_entry['id'], 'trash', 'btn-xs'); $entry .= button_glyph(page_link_to('user_shifts', ['entry_id' => $shift_entry['id']]), 'trash', 'btn-xs');
$entry .= '</div>'; $entry .= '</div>';
} }
return $entry; return $entry;

View File

@ -19,12 +19,18 @@ function UserAngelType_update_view($user_angeltype, $user, $angeltype, $supporte
User_Nick_render($user) User_Nick_render($user)
), true), ), true),
buttons([ buttons([
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'),
button( button(
page_link_to('user_angeltypes') page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
. '&action=update&user_angeltype_id=' . $user_angeltype['id'] _('cancel'),
. '&supporter=' . ($supporter ? '1' : '0') 'cancel'
. '&confirmed', ),
button(
page_link_to('user_angeltypes', [
'action' => 'update',
'user_angeltype_id' => $user_angeltype['id'],
'supporter' => ($supporter ? '1' : '0'),
'confirmed' => 1,
]),
_('yes'), _('yes'),
'ok' 'ok'
) )
@ -42,9 +48,19 @@ function UserAngelTypes_delete_all_view($angeltype)
msg(), msg(),
info(sprintf(_('Do you really want to deny all users for %s?'), $angeltype['name']), true), info(sprintf(_('Do you really want to deny all users for %s?'), $angeltype['name']), true),
buttons([ buttons([
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'),
button( button(
page_link_to('user_angeltypes') . '&action=delete_all&angeltype_id=' . $angeltype['id'] . '&confirmed', 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'), _('yes'),
'ok' 'ok'
) )
@ -62,9 +78,11 @@ function UserAngelTypes_confirm_all_view($angeltype)
msg(), msg(),
info(sprintf(_('Do you really want to confirm all users for %s?'), $angeltype['name']), true), info(sprintf(_('Do you really want to confirm all users for %s?'), $angeltype['name']), true),
buttons([ buttons([
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'), button(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]), _('cancel'),
'cancel'),
button( button(
page_link_to('user_angeltypes') . '&action=confirm_all&angeltype_id=' . $angeltype['id'] . '&confirmed', page_link_to('user_angeltypes',
['action' => 'confirm_all', 'angeltype_id' => $angeltype['id'], 'confirmed' => 1]),
_('yes'), _('yes'),
'ok' 'ok'
) )
@ -84,9 +102,16 @@ function UserAngelType_confirm_view($user_angeltype, $user, $angeltype)
msg(), msg(),
info(sprintf(_('Do you really want to confirm %s for %s?'), User_Nick_render($user), $angeltype['name']), true), info(sprintf(_('Do you really want to confirm %s for %s?'), User_Nick_render($user), $angeltype['name']), true),
buttons([ buttons([
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'),
button( button(
page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed', 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'), _('yes'),
'ok' 'ok'
) )
@ -106,9 +131,14 @@ function UserAngelType_delete_view($user_angeltype, $user, $angeltype)
msg(), msg(),
info(sprintf(_('Do you really want to delete %s from %s?'), User_Nick_render($user), $angeltype['name']), true), info(sprintf(_('Do you really want to delete %s from %s?'), User_Nick_render($user), $angeltype['name']), true),
buttons([ buttons([
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'),
button( button(
page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed', 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'), _('yes'),
'ok' 'ok'
) )
@ -132,7 +162,11 @@ function UserAngelType_add_view($angeltype, $users_source, $user_id)
return page_with_title(_('Add user to angeltype'), [ return page_with_title(_('Add user to angeltype'), [
msg(), msg(),
buttons([ buttons([
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('back'), 'back') button(
page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
_('back'),
'back'
)
]), ]),
form([ form([
form_info(_('Angeltype'), $angeltype['name']), form_info(_('Angeltype'), $angeltype['name']),
@ -153,9 +187,16 @@ function UserAngelType_join_view($user, $angeltype)
msg(), msg(),
info(sprintf(_('Do you really want to add %s to %s?'), User_Nick_render($user), $angeltype['name']), true), info(sprintf(_('Do you really want to add %s to %s?'), User_Nick_render($user), $angeltype['name']), true),
buttons([ buttons([
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'),
button( button(
page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'] . '&user_id=' . $user['UID'] . '&confirmed', 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'), _('save'),
'ok' 'ok'
) )

View File

@ -127,7 +127,7 @@ function User_registration_success_view($event_welcome_message)
'<h2>' . _('What can I do?') . '</h2>', '<h2>' . _('What can I do?') . '</h2>',
'<p>' . _('Please read about the jobs you can do to help us.') . '</p>', '<p>' . _('Please read about the jobs you can do to help us.') . '</p>',
buttons([ buttons([
button(page_link_to('angeltypes') . '&action=about', _('Teams/Job description') . ' &raquo;') button(page_link_to('angeltypes', ['action' => 'about']), _('Teams/Job description') . ' &raquo;')
]) ])
]) ])
]) ])
@ -172,10 +172,13 @@ function User_edit_vouchers_view($user)
button(user_link($user), glyph('chevron-left') . _('back')) button(user_link($user), glyph('chevron-left') . _('back'))
]), ]),
info(sprintf(_('Angel should receive at least %d vouchers.'), User_get_eligable_voucher_count($user)), true), info(sprintf(_('Angel should receive at least %d vouchers.'), User_get_eligable_voucher_count($user)), true),
form([ form(
[
form_spinner('vouchers', _('Number of vouchers given out'), $user['got_voucher']), form_spinner('vouchers', _('Number of vouchers given out'), $user['got_voucher']),
form_submit('submit', _('Save')) form_submit('submit', _('Save'))
], page_link_to('users') . '&action=edit_vouchers&user_id=' . $user['UID']) ],
page_link_to('users', ['action' => 'edit_vouchers', 'user_id' => $user['UID']])
)
]); ]);
} }
@ -208,7 +211,7 @@ function Users_view(
$user['Tshirt'] = glyph_bool($user['Tshirt']); $user['Tshirt'] = glyph_bool($user['Tshirt']);
$user['lastLogIn'] = date(_('m/d/Y h:i a'), $user['lastLogIn']); $user['lastLogIn'] = date(_('m/d/Y h:i a'), $user['lastLogIn']);
$user['actions'] = table_buttons([ $user['actions'] = table_buttons([
button_glyph(page_link_to('admin_user') . '&id=' . $user['UID'], 'edit', 'btn-xs') button_glyph(page_link_to('admin_user', ['id' => $user['UID']]), 'edit', 'btn-xs')
]); ]);
} }
$users[] = [ $users[] = [
@ -253,7 +256,11 @@ function Users_view(
*/ */
function Users_table_header_link($column, $label, $order_by) 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>'; return '<a href="'
. page_link_to('users', ['OrderBy' => $column])
. '">'
. $label . ($order_by == $column ? ' <span class="caret"></span>' : '')
. '</a>';
} }
/** /**
@ -347,7 +354,7 @@ function User_view_myshift($shift, $user_source, $its_me)
]; ];
if ($its_me || in_array('user_shifts_admin', $privileges)) { if ($its_me || in_array('user_shifts_admin', $privileges)) {
$myshift['actions'][] = button( $myshift['actions'][] = button(
page_link_to('user_myshifts') . '&edit=' . $shift['id'] . '&id=' . $user_source['UID'], page_link_to('user_myshifts', ['edit' => $shift['id'], 'id' => $user_source['UID']]),
glyph('edit') . _('edit'), glyph('edit') . _('edit'),
'btn-xs' 'btn-xs'
); );
@ -356,8 +363,15 @@ function User_view_myshift($shift, $user_source, $its_me)
($shift['start'] > time() + config('last_unsubscribe') * 3600) ($shift['start'] > time() + config('last_unsubscribe') * 3600)
|| in_array('user_shifts_admin', $privileges) || in_array('user_shifts_admin', $privileges)
) { ) {
$parameters = [
'cancel' => $shift['id'],
'id' => $user_source['UID'],
];
if ($its_me) {
$parameters['id'] = '';
}
$myshift['actions'][] = button( $myshift['actions'][] = button(
page_link_to('user_myshifts') . ((!$its_me) ? '&id=' . $user_source['UID'] : '') . '&cancel=' . $shift['id'], page_link_to('user_myshifts', $parameters),
glyph('trash') . _('sign off'), glyph('trash') . _('sign off'),
'btn-xs' 'btn-xs'
); );
@ -427,7 +441,7 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
div('col-md-12', [ div('col-md-12', [
buttons([ buttons([
$admin_user_privilege ? button( $admin_user_privilege ? button(
page_link_to('admin_user') . '&id=' . $user_source['UID'], page_link_to('admin_user', ['id' => $user_source['UID']]),
glyph('edit') . _('edit') glyph('edit') . _('edit')
) : '', ) : '',
$admin_user_privilege ? button( $admin_user_privilege ? button(
@ -435,24 +449,24 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
glyph('road') . _('driving license') glyph('road') . _('driving license')
) : '', ) : '',
($admin_user_privilege && !$user_source['Gekommen']) ? button( ($admin_user_privilege && !$user_source['Gekommen']) ? button(
page_link_to('admin_arrive') . '&arrived=' . $user_source['UID'], page_link_to('admin_arrive', ['arrived' => $user_source['UID']]),
_('arrived') _('arrived')
) : '', ) : '',
$admin_user_privilege ? button( $admin_user_privilege ? button(
page_link_to('users') . '&action=edit_vouchers&user_id=' . $user_source['UID'], page_link_to('users', ['action' => 'edit_vouchers', 'user_id' => $user_source['UID']]),
glyph('cutlery') . _('Edit vouchers') glyph('cutlery') . _('Edit vouchers')
) : '', ) : '',
$its_me ? button(page_link_to('user_settings'), glyph('list-alt') . _('Settings')) : '', $its_me ? button(page_link_to('user_settings'), glyph('list-alt') . _('Settings')) : '',
$its_me ? button( $its_me ? button(
page_link_to('ical') . '&key=' . $user_source['api_key'], page_link_to('ical', ['key' => $user_source['api_key']]),
glyph('calendar') . _('iCal Export') glyph('calendar') . _('iCal Export')
) : '', ) : '',
$its_me ? button( $its_me ? button(
page_link_to('shifts_json_export') . '&key=' . $user_source['api_key'], page_link_to('shifts_json_export', ['key' => $user_source['api_key']]),
glyph('export') . _('JSON Export') glyph('export') . _('JSON Export')
) : '', ) : '',
$its_me ? button( $its_me ? button(
page_link_to('user_myshifts') . '&reset', page_link_to('user_myshifts', ['reset' => 1]),
glyph('repeat') . _('Reset API key') glyph('repeat') . _('Reset API key')
) : '' ) : ''
]) ])
@ -607,7 +621,7 @@ function User_groups_render($user_groups)
function User_Nick_render($user_source) function User_Nick_render($user_source)
{ {
return '<a class="' . ($user_source['Gekommen'] ? '' : 'text-muted') . '" href="' return '<a class="' . ($user_source['Gekommen'] ? '' : 'text-muted') . '" href="'
. page_link_to('users') . '&amp;action=view&amp;user_id=' . $user_source['UID'] . page_link_to('users', ['action' => 'view', 'user_id' => $user_source['UID']])
. '"><span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . '</a>'; . '"><span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . '</a>';
} }

8
public/.htaccess Normal file
View File

@ -0,0 +1,8 @@
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

View File

@ -25,6 +25,10 @@ $title = '';
$content = ''; $content = '';
$page = $request->input('p'); $page = $request->input('p');
if (empty($page)) {
$page = $request->path();
$page = str_replace('-', '_', $page);
}
if (empty($page)) { if (empty($page)) {
$page = isset($user) ? 'news' : 'login'; $page = isset($user) ? 'news' : 'login';
} }
@ -38,120 +42,158 @@ if (
) { ) {
$title = $page; $title = $page;
if ($page == 'api') { switch ($page) {
case 'api':
error('Api disabled temporarily.'); error('Api disabled temporarily.');
redirect(page_link_to()); redirect(page_link_to());
require_once realpath(__DIR__ . '/../includes/controller/api.php'); break;
api_controller(); case 'ical':
} elseif ($page == 'ical') {
require_once realpath(__DIR__ . '/../includes/pages/user_ical.php'); require_once realpath(__DIR__ . '/../includes/pages/user_ical.php');
user_ical(); user_ical();
} elseif ($page == 'atom') { break;
case 'atom':
require_once realpath(__DIR__ . '/../includes/pages/user_atom.php'); require_once realpath(__DIR__ . '/../includes/pages/user_atom.php');
user_atom(); user_atom();
} elseif ($page == 'shifts_json_export') { break;
case 'shifts_json_export':
require_once realpath(__DIR__ . '/../includes/controller/shifts_controller.php'); require_once realpath(__DIR__ . '/../includes/controller/shifts_controller.php');
shifts_json_export_controller(); shifts_json_export_controller();
} elseif ($page == 'shifts_json_export_all') { break;
case 'shifts_json_export_all':
require_once realpath(__DIR__ . '/../includes/controller/shifts_controller.php'); require_once realpath(__DIR__ . '/../includes/controller/shifts_controller.php');
shifts_json_export_all_controller(); shifts_json_export_all_controller();
} elseif ($page == 'stats') { break;
case 'stats':
require_once realpath(__DIR__ . '/../includes/pages/guest_stats.php'); require_once realpath(__DIR__ . '/../includes/pages/guest_stats.php');
guest_stats(); guest_stats();
} elseif ($page == 'user_password_recovery') { break;
case 'user_password_recovery':
require_once realpath(__DIR__ . '/../includes/controller/users_controller.php'); require_once realpath(__DIR__ . '/../includes/controller/users_controller.php');
$title = user_password_recovery_title(); $title = user_password_recovery_title();
$content = user_password_recovery_controller(); $content = user_password_recovery_controller();
} elseif ($page == 'angeltypes') { break;
case 'angeltypes':
list($title, $content) = angeltypes_controller(); list($title, $content) = angeltypes_controller();
} elseif ($page == 'shifts') { break;
case 'shifts':
list($title, $content) = shifts_controller(); list($title, $content) = shifts_controller();
} elseif ($page == 'users') { break;
case 'users':
list($title, $content) = users_controller(); list($title, $content) = users_controller();
} elseif ($page == 'user_angeltypes') { break;
case 'user_angeltypes':
list($title, $content) = user_angeltypes_controller(); list($title, $content) = user_angeltypes_controller();
} elseif ($page == 'user_driver_licenses') { break;
case 'user_driver_licenses':
list($title, $content) = user_driver_licenses_controller(); list($title, $content) = user_driver_licenses_controller();
} elseif ($page == 'shifttypes') { break;
case 'shifttypes':
list($title, $content) = shifttypes_controller(); list($title, $content) = shifttypes_controller();
} elseif ($page == 'admin_event_config') { break;
case 'admin_event_config':
list($title, $content) = event_config_edit_controller(); list($title, $content) = event_config_edit_controller();
} elseif ($page == 'rooms') { break;
case 'rooms':
list($title, $content) = rooms_controller(); list($title, $content) = rooms_controller();
} elseif ($page == 'news') { break;
case 'news':
$title = news_title(); $title = news_title();
$content = user_news(); $content = user_news();
} elseif ($page == 'news_comments') { break;
case 'news_comments':
require_once realpath(__DIR__ . '/../includes/pages/user_news.php'); require_once realpath(__DIR__ . '/../includes/pages/user_news.php');
$title = user_news_comments_title(); $title = user_news_comments_title();
$content = user_news_comments(); $content = user_news_comments();
} elseif ($page == 'user_meetings') { break;
case 'user_meetings':
$title = meetings_title(); $title = meetings_title();
$content = user_meetings(); $content = user_meetings();
} elseif ($page == 'user_myshifts') { break;
case 'user_myshifts':
$title = myshifts_title(); $title = myshifts_title();
$content = user_myshifts(); $content = user_myshifts();
} elseif ($page == 'user_shifts') { break;
case 'user_shifts':
$title = shifts_title(); $title = shifts_title();
$content = user_shifts(); $content = user_shifts();
} elseif ($page == 'user_messages') { break;
case 'user_messages':
$title = messages_title(); $title = messages_title();
$content = user_messages(); $content = user_messages();
} elseif ($page == 'user_questions') { break;
case 'user_questions':
$title = questions_title(); $title = questions_title();
$content = user_questions(); $content = user_questions();
} elseif ($page == 'user_settings') { break;
case 'user_settings':
$title = settings_title(); $title = settings_title();
$content = user_settings(); $content = user_settings();
} elseif ($page == 'login') { break;
case 'login':
$title = login_title(); $title = login_title();
$content = guest_login(); $content = guest_login();
} elseif ($page == 'register') { break;
case 'register':
$title = register_title(); $title = register_title();
$content = guest_register(); $content = guest_register();
} elseif ($page == 'logout') { break;
case 'logout':
$title = logout_title(); $title = logout_title();
$content = guest_logout(); $content = guest_logout();
} elseif ($page == 'admin_questions') { break;
case 'admin_questions':
$title = admin_questions_title(); $title = admin_questions_title();
$content = admin_questions(); $content = admin_questions();
} elseif ($page == 'admin_user') { break;
case 'admin_user':
$title = admin_user_title(); $title = admin_user_title();
$content = admin_user(); $content = admin_user();
} elseif ($page == 'admin_arrive') { break;
case 'admin_arrive':
$title = admin_arrive_title(); $title = admin_arrive_title();
$content = admin_arrive(); $content = admin_arrive();
} elseif ($page == 'admin_active') { break;
case 'admin_active':
$title = admin_active_title(); $title = admin_active_title();
$content = admin_active(); $content = admin_active();
} elseif ($page == 'admin_free') { break;
case 'admin_free':
$title = admin_free_title(); $title = admin_free_title();
$content = admin_free(); $content = admin_free();
} elseif ($page == 'admin_news') { break;
case 'admin_news':
require_once realpath(__DIR__ . '/../includes/pages/admin_news.php'); require_once realpath(__DIR__ . '/../includes/pages/admin_news.php');
$content = admin_news(); $content = admin_news();
} elseif ($page == 'admin_rooms') { break;
case 'admin_rooms':
$title = admin_rooms_title(); $title = admin_rooms_title();
$content = admin_rooms(); $content = admin_rooms();
} elseif ($page == 'admin_groups') { break;
case 'admin_groups':
$title = admin_groups_title(); $title = admin_groups_title();
$content = admin_groups(); $content = admin_groups();
} elseif ($page == 'admin_import') { break;
case 'admin_import':
$title = admin_import_title(); $title = admin_import_title();
$content = admin_import(); $content = admin_import();
} elseif ($page == 'admin_shifts') { break;
case 'admin_shifts':
$title = admin_shifts_title(); $title = admin_shifts_title();
$content = admin_shifts(); $content = admin_shifts();
} elseif ($page == 'admin_log') { break;
case 'admin_log':
$title = admin_log_title(); $title = admin_log_title();
$content = admin_log(); $content = admin_log();
} elseif ($page == 'credits') { break;
case 'credits':
require_once realpath(__DIR__ . '/../includes/pages/guest_credits.php'); require_once realpath(__DIR__ . '/../includes/pages/guest_credits.php');
$title = credits_title(); $title = credits_title();
$content = guest_credits(); $content = guest_credits();
} else { break;
default:
require_once realpath(__DIR__ . '/../includes/pages/guest_start.php'); require_once realpath(__DIR__ . '/../includes/pages/guest_start.php');
$content = guest_start(); $content = guest_start();
break;
} }
} else { } else {
// Wenn schon eingeloggt, keine-Berechtigung-Seite anzeigen // Wenn schon eingeloggt, keine-Berechtigung-Seite anzeigen
@ -166,14 +208,22 @@ if (
$event_config = EventConfig(); $event_config = EventConfig();
$parameters = [
'key' => (isset($user) ? $user['api_key'] : ''),
];
if ($page == 'user_meetings') {
$parameters['meetings'] = 1;
}
echo view(__DIR__ . '/../templates/layout.html', [ echo view(__DIR__ . '/../templates/layout.html', [
'theme' => isset($user) ? $user['color'] : config('theme'), 'theme' => isset($user) ? $user['color'] : config('theme'),
'title' => $title, 'title' => $title,
'atom_link' => ($page == 'news' || $page == 'user_meetings') 'atom_link' => ($page == 'news' || $page == 'user_meetings')
? ' <link href="' . page_link_to('atom') . (($page == 'user_meetings') ? '&meetings=1' : '') ? ' <link href="'
. '&amp;key=' . (isset($user) ? $user['api_key'] : '') . page_link_to('atom', $parameters)
. '" type = "application/atom+xml" rel = "alternate" title = "Atom Feed">' . '" type = "application/atom+xml" rel = "alternate" title = "Atom Feed">'
: '', : '',
'start_page_url' => page_link_to('/'),
'credits_url' => page_link_to('credits'),
'menu' => make_menu(), 'menu' => make_menu(),
'content' => msg() . $content, 'content' => msg() . $content,
'header_toolbar' => header_toolbar(), 'header_toolbar' => header_toolbar(),

View File

@ -9,19 +9,73 @@ class Request
/** @var self */ /** @var self */
protected static $instance; protected static $instance;
/** @var array of POST data */
protected $request;
/** @var array of GET data */ /** @var array of GET data */
protected $query; protected $query;
/** @var array of POST data */
protected $request;
/** @var array of SERVER data */
protected $server;
/** @var string */
protected $scheme;
/** @var string */
protected $host;
/** @var string */
protected $baseUrl = '';
/** @var string */
protected $path;
/** /**
* Initialize request * Initialize request
*
* @param array $query The GET data
* @param array $request the POST data
* @param array $server the SERVER data
* @param string $baseUrl base url to use for links
*/ */
public function create() public function create(array $query, array $request, array $server, $baseUrl = null)
{ {
$this->request = $_POST; $this->query = $query;
$this->query = $_GET; $this->request = $request;
$this->server = array_merge([
'SERVER_NAME' => 'localhost',
'HTTP_HOST' => 'localhost',
'SERVER_PORT' => 80,
'REQUEST_URI' => '/',
], $server);
if (isset($this->server['HTTPS']) && $this->server['HTTPS'] == 'off') {
unset($this->server['HTTPS']);
}
$uri = $this->server['REQUEST_URI'];
$uri = '/' . ltrim($uri, '/');
$uri = explode('?', $uri);
$this->path = array_shift($uri);
$components = parse_url($baseUrl);
if (!$components) {
$components = [];
}
$this->scheme = (isset($components['scheme']) ? $components['scheme'] : ($this->isSecure() ? 'https' : 'http'));
$this->host = (isset($components['host']) ? $components['host'] : $this->server['SERVER_NAME']);
if (isset($components['path'])) {
$this->baseUrl = '/' . ltrim($components['path'], '/');
$this->path = preg_replace('~^' . preg_quote($this->baseUrl, '~') . '~i', '', $this->path);
$this->path = '/' . ltrim($this->path, '/');
}
}
public function isSecure()
{
return isset($this->server['HTTPS']);
} }
/** /**
@ -87,6 +141,50 @@ class Request
return !empty($value); return !empty($value);
} }
/**
* Get the requested path
*
* @return string
*/
public function path()
{
// @TODO: base uri?
return $this->path;
}
public function url()
{
return $this->getSchemeAndHttpHost() . $this->getBaseUrl() . '/' . $this->path();
}
/**
* @return string
*/
public function root()
{
return $this->baseUrl;
}
public function getSchemeAndHttpHost()
{
return $this->getScheme() . '://' . $this->getHttpHost();
}
public function getScheme()
{
return $this->scheme;
}
public function getHttpHost()
{
return $this->host;
}
public function getBaseUrl()
{
return $this->baseUrl;
}
/** /**
* @return self * @return self
* @throws ErrorException * @throws ErrorException

View File

@ -22,7 +22,7 @@
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </button>
<a class="navbar-brand" href="?"><span class="icon-icon_angel"></span> <strong class="visible-lg-inline">ENGELSYSTEM</strong></a> <a class="navbar-brand" href="%start_page_url%"><span class="icon-icon_angel"></span> <strong class="visible-lg-inline">ENGELSYSTEM</strong></a>
</div> </div>
<div class="collapse navbar-collapse" id="navbar-collapse-1">%menu% %header_toolbar%</div> <div class="collapse navbar-collapse" id="navbar-collapse-1">%menu% %header_toolbar%</div>
</div> </div>
@ -38,7 +38,7 @@
· <a href="%contact_email%"><span class="glyphicon glyphicon-envelope"></span> Contact</a> · <a href="%contact_email%"><span class="glyphicon glyphicon-envelope"></span> Contact</a>
· <a href="https://github.com/engelsystem/engelsystem/issues">Bugs / Features</a> · <a href="https://github.com/engelsystem/engelsystem/issues">Bugs / Features</a>
· <a href="https://github.com/engelsystem/engelsystem/">Development Platform</a> · <a href="https://github.com/engelsystem/engelsystem/">Development Platform</a>
· <a href="?p=credits">Credits</a> · <a href="%credits_url%">Credits</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -21,7 +21,7 @@
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </button>
<a class="navbar-brand" href="?"> <a class="navbar-brand" href="#">
<span class="icon-icon_angel"></span> <strong class="visible-lg-inline">ENGELSYSTEM</strong> <span class="icon-icon_angel"></span> <strong class="visible-lg-inline">ENGELSYSTEM</strong>
</a> </a>
</div> </div>