summaryrefslogtreecommitdiff
path: root/includes/view
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2017-09-11 17:52:55 +0200
committerGitHub <noreply@github.com>2017-09-11 17:52:55 +0200
commit359160613027a480620e22deef19ff883eaaeb21 (patch)
tree310600aaa23404f0cd7d3e198bacdbc93645da32 /includes/view
parent581b81f1b25dc6b6f0a3b34810c293738fd40217 (diff)
parent0a20883aa862779b48fd2a297456c2db04cffb95 (diff)
Merge pull request #344 from MyIgel/master
Prepared routing, added symfony http Closes #336 and closes #337
Diffstat (limited to 'includes/view')
-rw-r--r--includes/view/AngelTypes_view.php71
-rw-r--r--includes/view/Questions_view.php12
-rw-r--r--includes/view/Rooms_view.php11
-rw-r--r--includes/view/ShiftCalendarRenderer.php76
-rw-r--r--includes/view/ShiftCalendarShiftRenderer.php26
-rw-r--r--includes/view/ShiftTypes_view.php34
-rw-r--r--includes/view/ShiftsFilterRenderer.php11
-rw-r--r--includes/view/Shifts_view.php9
-rw-r--r--includes/view/UserAngelTypes_view.php73
-rw-r--r--includes/view/User_view.php46
10 files changed, 248 insertions, 121 deletions
diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php
index 37b4fb2c..f75cc616 100644
--- a/includes/view/AngelTypes_view.php
+++ b/includes/view/AngelTypes_view.php
@@ -50,7 +50,10 @@ function AngelType_delete_view($angeltype)
buttons([
button(page_link_to('angeltypes'), _('cancel'), 'cancel'),
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'),
'ok'
)
@@ -67,7 +70,6 @@ function AngelType_delete_view($angeltype)
*/
function AngelType_edit_view($angeltype, $supporter_mode)
{
- $contact_info = AngelType_contact_info($angeltype);
return page_with_title(sprintf(_('Edit %s'), $angeltype['name']), [
buttons([
button(page_link_to('angeltypes'), _('Angeltypes'), 'back')
@@ -127,7 +129,7 @@ function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes,
if ($user_angeltype == null) {
$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'),
'add'
);
@@ -142,20 +144,22 @@ function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes,
$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 || $supporter) {
$buttons[] = button(
- page_link_to('angeltypes') . '&action=edit&angeltype_id=' . $angeltype['id'],
+ page_link_to('angeltypes', ['action' => 'edit', 'angeltype_id' => $angeltype['id']]),
_('edit'),
'edit'
);
}
if ($admin_angeltypes) {
$buttons[] = button(
- page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'],
+ page_link_to('angeltypes', ['action' => 'delete', 'angeltype_id' => $angeltype['id']]),
_('delete'),
'delete'
);
@@ -193,12 +197,18 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a
if ($angeltype['restricted'] && $member['confirm_user_id'] == null) {
$member['actions'] = table_buttons([
button(
- page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $member['user_angeltype_id'],
+ page_link_to(
+ 'user_angeltypes',
+ ['action' => 'confirm', 'user_angeltype_id' => $member['user_angeltype_id']]
+ ),
_('confirm'),
'btn-xs'
),
button(
- page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'],
+ page_link_to(
+ 'user_angeltypes',
+ ['action' => 'delete', 'user_angeltype_id' => $member['user_angeltype_id']]
+ ),
_('deny'),
'btn-xs'
)
@@ -208,7 +218,11 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a
if ($admin_angeltypes) {
$member['actions'] = table_buttons([
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'),
'btn-xs'
)
@@ -221,11 +235,18 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a
if ($admin_user_angeltypes) {
$member['actions'] = table_buttons([
$admin_angeltypes
- ? button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&supporter=1',
+ ? button(page_link_to('user_angeltypes', [
+ 'action' => 'update',
+ 'user_angeltype_id' => $member['user_angeltype_id'],
+ 'supporter' => 1
+ ]),
_('Add supporter rights'), 'btn-xs')
: '',
button(
- page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'],
+ page_link_to('user_angeltypes', [
+ 'action' => 'delete',
+ 'user_angeltype_id' => $member['user_angeltype_id']
+ ]),
_('remove'),
'btn-xs'
)
@@ -339,7 +360,14 @@ function AngelType_view(
$page[] = '<h3>' . _('Members') . '</h3>';
if ($admin_user_angeltypes) {
$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);
@@ -348,12 +376,12 @@ function AngelType_view(
$page[] = '<h3>' . _('Unconfirmed') . '</h3>';
$page[] = buttons([
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'),
'ok'
),
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'),
'cancel'
)
@@ -376,8 +404,10 @@ function AngelTypes_list_view($angeltypes, $admin_angeltypes)
return page_with_title(angeltypes_title(), [
msg(),
buttons([
- $admin_angeltypes ? button(page_link_to('angeltypes') . '&action=edit', _('New angeltype'), 'add') : '',
- button(page_link_to('angeltypes') . '&action=about', _('Teams/Job description'))
+ $admin_angeltypes
+ ? button(page_link_to('angeltypes', ['action' => 'edit']), _('New angeltype'), 'add')
+ : '',
+ button(page_link_to('angeltypes', ['action' => 'about']), _('Teams/Job description'))
]),
table([
'name' => _('Name'),
@@ -405,13 +435,16 @@ function AngelTypes_about_view_angeltype($angeltype)
$buttons = [];
if ($angeltype['user_angeltype_id'] != null) {
$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'),
'cancel'
);
} else {
$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'),
'add'
);
diff --git a/includes/view/Questions_view.php b/includes/view/Questions_view.php
index dee7585c..a44a099d 100644
--- a/includes/view/Questions_view.php
+++ b/includes/view/Questions_view.php
@@ -9,14 +9,22 @@
function Questions_view($open_questions, $answered_questions, $ask_action)
{
foreach ($open_questions as &$question) {
- $question['actions'] = '<a href="' . page_link_to('user_questions') . '&action=delete&id=' . $question['QID'] . '">' . _('delete') . '</a>';
+ $question['actions'] = '<a href="'
+ . page_link_to('user_questions', ['action' => 'delete', 'id' => $question['QID']])
+ . '">'
+ . _('delete')
+ . '</a>';
$question['Question'] = str_replace("\n", '<br />', $question['Question']);
}
foreach ($answered_questions as &$question) {
$question['Question'] = str_replace("\n", '<br />', $question['Question']);
$question['Answer'] = str_replace("\n", '<br />', $question['Answer']);
- $question['actions'] = '<a href="' . page_link_to('user_questions') . '&action=delete&id=' . $question['QID'] . '">' . _('delete') . '</a>';
+ $question['actions'] = '<a href="'
+ . page_link_to('user_questions', ['action' => 'delete', 'id' => $question['QID']])
+ . '">'
+ . _('delete')
+ . '</a>';
}
return page_with_title(questions_title(), [
diff --git a/includes/view/Rooms_view.php b/includes/view/Rooms_view.php
index 802b4c8e..adb58a9a 100644
--- a/includes/view/Rooms_view.php
+++ b/includes/view/Rooms_view.php
@@ -1,4 +1,5 @@
<?php
+
use Engelsystem\ShiftCalendarRenderer;
use Engelsystem\ShiftsFilterRenderer;
@@ -10,8 +11,16 @@ use Engelsystem\ShiftsFilterRenderer;
*/
function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer)
{
+ global $user;
+
+ $assignNotice = '';
+ if (config('signup_requires_arrival') && !$user['Gekommen']) {
+ $assignNotice = info(render_user_arrived_hint(), true);
+ }
+
return page_with_title(glyph('map-marker') . $room['Name'], [
- $shiftsFilterRenderer->render(room_link($room)),
+ $shiftsFilterRenderer->render($room),
+ $assignNotice,
$shiftCalendarRenderer->render()
]);
}
diff --git a/includes/view/ShiftCalendarRenderer.php b/includes/view/ShiftCalendarRenderer.php
index 3269f338..d2becb58 100644
--- a/includes/view/ShiftCalendarRenderer.php
+++ b/includes/view/ShiftCalendarRenderer.php
@@ -1,11 +1,9 @@
<?php
-namespace Engelsystem;
-use Exception;
+namespace Engelsystem;
class ShiftCalendarRenderer
{
-
/**
* 15m * 60s/m = 900s
*/
@@ -51,10 +49,10 @@ class ShiftCalendarRenderer
/**
* ShiftCalendarRenderer constructor.
*
- * @param array[] $shifts
- * @param array[] $needed_angeltypes
- * @param array[] $shift_entries
- * @param ShiftsFilter $shiftsFilter
+ * @param array[] $shifts
+ * @param array[] $needed_angeltypes
+ * @param array[] $shift_entries
+ * @param ShiftsFilter $shiftsFilter
*/
public function __construct($shifts, $needed_angeltypes, $shift_entries, ShiftsFilter $shiftsFilter)
{
@@ -69,23 +67,21 @@ class ShiftCalendarRenderer
/**
* Assigns the shifts to different lanes per room if they collide
*
- * @param array[] $shifts
- * The shifts to assign
- *
+ * @param array[] $shifts The shifts to assign
* @return array Returns an array that assigns a room_id to an array of ShiftCalendarLane containing the shifts
*/
private function assignShiftsToLanes($shifts)
{
// array that assigns a room id to a list of lanes (per room)
$lanes = [];
-
+
foreach ($shifts as $shift) {
$room_id = $shift['RID'];
$header = Room_name_render([
- 'RID' => $room_id,
+ 'RID' => $room_id,
'Name' => $shift['room_name']
]);
- if (! isset($lanes[$room_id])) {
+ if (!isset($lanes[$room_id])) {
// initialize room with one lane
$lanes[$room_id] = [
new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot())
@@ -95,7 +91,7 @@ class ShiftCalendarRenderer
$shift_added = false;
foreach ($lanes[$room_id] as $lane) {
/** @var ShiftCalendarLane $lane */
- if($lane->shiftFits($shift)) {
+ if ($lane->shiftFits($shift)) {
$lane->addShift($shift);
$shift_added = true;
break;
@@ -108,12 +104,11 @@ class ShiftCalendarRenderer
$lanes[$room_id][] = $newLane;
}
}
-
+
return $lanes;
}
/**
- *
* @return int
*/
public function getFirstBlockStartTime()
@@ -122,7 +117,6 @@ class ShiftCalendarRenderer
}
/**
- *
* @return int
*/
public function getLastBlockEndTime()
@@ -131,7 +125,6 @@ class ShiftCalendarRenderer
}
/**
- *
* @return float
*/
public function getBlocksPerSlot()
@@ -153,9 +146,9 @@ class ShiftCalendarRenderer
return '';
}
return div('shift-calendar', [
- $this->renderTimeLane(),
- $this->renderShiftLanes()
- ]) . $this->renderLegend();
+ $this->renderTimeLane(),
+ $this->renderShiftLanes()
+ ]) . $this->renderLegend();
}
/**
@@ -171,41 +164,45 @@ class ShiftCalendarRenderer
$html .= $this->renderLane($lane);
}
}
-
+
return $html;
}
/**
* Renders a single lane
*
- * @param ShiftCalendarLane $lane
- * The lane to render
+ * @param ShiftCalendarLane $lane The lane to render
* @return string
*/
private function renderLane(ShiftCalendarLane $lane)
{
global $user;
-
+
$shift_renderer = new ShiftCalendarShiftRenderer();
$html = '';
$rendered_until = $this->getFirstBlockStartTime();
-
+
foreach ($lane->getShifts() as $shift) {
while ($rendered_until + ShiftCalendarRenderer::SECONDS_PER_ROW <= $shift['start']) {
$html .= $this->renderTick($rendered_until);
$rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW;
}
-
- list ($shift_height, $shift_html) = $shift_renderer->render($shift, $this->needed_angeltypes[$shift['SID']], $this->shift_entries[$shift['SID']], $user);
+
+ list ($shift_height, $shift_html) = $shift_renderer->render(
+ $shift,
+ $this->needed_angeltypes[$shift['SID']],
+ $this->shift_entries[$shift['SID']],
+ $user
+ );
$html .= $shift_html;
$rendered_until += $shift_height * ShiftCalendarRenderer::SECONDS_PER_ROW;
}
-
+
while ($rendered_until < $this->getLastBlockEndTime()) {
$html .= $this->renderTick($rendered_until);
$rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW;
}
-
+
return div('lane', [
div('header', $lane->getHeader()),
$html
@@ -215,23 +212,21 @@ class ShiftCalendarRenderer
/**
* Renders a tick/block for given time
*
- * @param int $time
- * unix timestamp
- * @param boolean $label
- * Should time labels be generated?
+ * @param int $time unix timestamp
+ * @param boolean $label Should time labels be generated?
* @return string rendered tick html
*/
private function renderTick($time, $label = false)
{
if ($time % (24 * 60 * 60) == 23 * 60 * 60) {
- if (! $label) {
+ if (!$label) {
return div('tick day');
}
return div('tick day', [
date('m-d<b\r />H:i', $time)
]);
} elseif ($time % (60 * 60) == 0) {
- if (! $label) {
+ if (!$label) {
return div('tick hour');
}
return div('tick hour', [
@@ -253,7 +248,7 @@ class ShiftCalendarRenderer
_('Time')
])
];
- for ($block = 0; $block < $this->getBlocksPerSlot(); $block ++) {
+ for ($block = 0; $block < $this->getBlocksPerSlot(); $block++) {
$thistime = $this->getFirstBlockStartTime() + ($block * ShiftCalendarRenderer::SECONDS_PER_ROW);
$time_slot[] = $this->renderTick($thistime, true);
}
@@ -261,8 +256,7 @@ class ShiftCalendarRenderer
}
/**
- *
- * @param array[] $shifts
+ * @param array[] $shifts
* @return int
*/
private function calcFirstBlockStartTime($shifts)
@@ -277,8 +271,7 @@ class ShiftCalendarRenderer
}
/**
- *
- * @param array[] $shifts
+ * @param array[] $shifts
* @return int
*/
private function calcLastBlockEndTime($shifts)
@@ -293,7 +286,6 @@ class ShiftCalendarRenderer
}
/**
- *
* @return int
*/
private function calcBlocksPerSlot()
diff --git a/includes/view/ShiftCalendarShiftRenderer.php b/includes/view/ShiftCalendarShiftRenderer.php
index 8560d47d..0e5fc8c3 100644
--- a/includes/view/ShiftCalendarShiftRenderer.php
+++ b/includes/view/ShiftCalendarShiftRenderer.php
@@ -124,11 +124,15 @@ class ShiftCalendarShiftRenderer
}
if (in_array('user_shifts_admin', $privileges)) {
- $html .= '<li class="list-group-item">' . button(
- page_link_to('user_shifts') . '&amp;shift_id=' . $shift['SID'],
- _('Add more angels'),
- 'btn-xs'
- ) . '</li>';
+ $html .= '<li class="list-group-item">' . _('Add more angels') . ':';
+ foreach ($needed_angeltypes as $angeltype) {
+ $html .= ' ' . button(
+ page_link_to('user_shifts', ['shift_id' => $shift['SID'], 'type_id' => $angeltype['id']]),
+ $angeltype['name'],
+ 'btn-xs'
+ );
+ }
+ $html .= '</li>';
}
if ($html != '') {
return [
@@ -169,11 +173,13 @@ class ShiftCalendarShiftRenderer
case ShiftSignupState::ADMIN:
case ShiftSignupState::FREE:
// When admin or free display a link + button for sign up
- $entry_list[] = '<a href="' . page_link_to('user_shifts') . '&amp;shift_id=' . $shift['SID'] . '&amp;type_id=' . $angeltype['id'] . '">'
+ $entry_list[] = '<a href="'
+ . page_link_to('user_shifts', ['shift_id' => $shift['SID'], 'type_id' => $angeltype['id']])
+ . '">'
. $inner_text
. '</a> '
. button(
- page_link_to('user_shifts') . '&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'
);
break;
@@ -191,7 +197,7 @@ class ShiftCalendarShiftRenderer
// Add link to join the angeltype first
$entry_list[] = $inner_text . '<br />'
. 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']),
'btn-xs'
);
@@ -232,8 +238,8 @@ class ShiftCalendarShiftRenderer
$header_buttons = '';
if (in_array('admin_shifts', $privileges)) {
$header_buttons = '<div class="pull-right">' . table_buttons([
- button(page_link_to('user_shifts') . '&edit_shift=' . $shift['SID'], glyph('edit'), 'btn-xs'),
- button(page_link_to('user_shifts') . '&delete_shift=' . $shift['SID'], glyph('trash'), 'btn-xs')
+ button(page_link_to('user_shifts', ['edit_shift' => $shift['SID']]), glyph('edit'), 'btn-xs'),
+ button(page_link_to('user_shifts', ['delete_shift' => $shift['SID']]), glyph('trash'), 'btn-xs')
]) . '</div>';
}
$shift_heading = date('H:i', $shift['start']) . ' &dash; '
diff --git a/includes/view/ShiftTypes_view.php b/includes/view/ShiftTypes_view.php
index e0750617..74e0d7c0 100644
--- a/includes/view/ShiftTypes_view.php
+++ b/includes/view/ShiftTypes_view.php
@@ -24,7 +24,10 @@ function ShiftType_delete_view($shifttype)
buttons([
button(page_link_to('shifttypes'), _('cancel'), 'cancel'),
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'),
'ok btn-danger'
)
@@ -81,12 +84,16 @@ function ShiftType_view($shifttype, $angeltype)
buttons([
button(page_link_to('shifttypes'), shifttypes_title(), 'back'),
$angeltype ? button(
- page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'],
+ page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
$angeltype['name']
) : '',
- button(page_link_to('shifttypes') . '&action=edit&shifttype_id=' . $shifttype['id'], _('edit'), 'edit'),
button(
- page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'],
+ 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'
)
@@ -103,11 +110,22 @@ function ShiftType_view($shifttype, $angeltype)
function ShiftTypes_list_view($shifttypes)
{
foreach ($shifttypes as &$shifttype) {
- $shifttype['name'] = '<a href="' . page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype['id'] . '">' . $shifttype['name'] . '</a>';
+ $shifttype['name'] = '<a href="'
+ . page_link_to('shifttypes', ['action' => 'view', 'shifttype_id' => $shifttype['id']])
+ . '">'
+ . $shifttype['name']
+ . '</a>';
$shifttype['actions'] = table_buttons([
- button(page_link_to('shifttypes') . '&action=edit&shifttype_id=' . $shifttype['id'], _('edit'), 'btn-xs'),
button(
- page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'],
+ page_link_to(
+ 'shifttypes',
+ ['action' => 'edit', 'shifttype_id' => $shifttype['id']]
+ ),
+ _('edit'),
+ 'btn-xs'
+ ),
+ button(
+ page_link_to('shifttypes', ['action' => 'delete', 'shifttype_id' => $shifttype['id']]),
_('delete'),
'btn-xs'
)
@@ -117,7 +135,7 @@ function ShiftTypes_list_view($shifttypes)
return page_with_title(shifttypes_title(), [
msg(),
buttons([
- button(page_link_to('shifttypes') . '&action=edit', _('New shifttype'), 'add')
+ button(page_link_to('shifttypes', ['action' => 'edit']), _('New shifttype'), 'add')
]),
table([
'name' => _('Name'),
diff --git a/includes/view/ShiftsFilterRenderer.php b/includes/view/ShiftsFilterRenderer.php
index 43a23ef6..c3e0ccf1 100644
--- a/includes/view/ShiftsFilterRenderer.php
+++ b/includes/view/ShiftsFilterRenderer.php
@@ -39,17 +39,22 @@ class ShiftsFilterRenderer
/**
* Renders the filter.
*
- * @param string $link_base
+ * @param array $room
* @return string Generated HTML
*/
- public function render($link_base)
+ public function render($room)
{
$toolbar = [];
if ($this->daySelectionEnabled && !empty($this->days)) {
$selected_day = date('Y-m-d', $this->shiftsFilter->getStartTime());
$day_dropdown_items = [];
foreach ($this->days as $day) {
- $day_dropdown_items[] = toolbar_item_link($link_base . '&shifts_filter_day=' . $day, '', $day);
+ $link = page_link_to('rooms', [
+ 'action' => 'view',
+ 'room_id' => $room['RID'],
+ 'shifts_filter_day' => $day,
+ ]);
+ $day_dropdown_items[] = toolbar_item_link($link, '', $day);
}
$toolbar[] = toolbar_dropdown('', $selected_day, $day_dropdown_items, 'active');
}
diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php
index 094af7ad..bc905f39 100644
--- a/includes/view/Shifts_view.php
+++ b/includes/view/Shifts_view.php
@@ -1,4 +1,5 @@
<?php
+
use Engelsystem\ShiftSignupState;
/**
@@ -41,12 +42,12 @@ function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
if ($angeltype['shift_signup_state']->isSignupAllowed()) {
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')
);
} elseif ($user_angeltype == null) {
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'),
$angeltype['name'])
);
@@ -207,12 +208,12 @@ function Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angelty
$entry .= ' <div class="btn-group">';
if ($user_shift_admin) {
$entry .= button_glyph(
- page_link_to('user_myshifts') . '&edit=' . $shift_entry['id'] . '&id=' . $shift_entry['UID'],
+ page_link_to('user_myshifts', ['edit' => $shift_entry['id'], 'id' => $shift_entry['UID']]),
'pencil',
'btn-xs'
);
}
- $entry .= button_glyph(page_link_to('user_shifts') . '&entry_id=' . $shift_entry['id'], 'trash', 'btn-xs');
+ $entry .= button_glyph(page_link_to('user_shifts', ['entry_id' => $shift_entry['id']]), 'trash', 'btn-xs');
$entry .= '</div>';
}
return $entry;
diff --git a/includes/view/UserAngelTypes_view.php b/includes/view/UserAngelTypes_view.php
index 15d99961..98f6c3e9 100644
--- a/includes/view/UserAngelTypes_view.php
+++ b/includes/view/UserAngelTypes_view.php
@@ -19,12 +19,18 @@ function UserAngelType_update_view($user_angeltype, $user, $angeltype, $supporte
User_Nick_render($user)
), true),
buttons([
- button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'),
button(
- page_link_to('user_angeltypes')
- . '&action=update&user_angeltype_id=' . $user_angeltype['id']
- . '&supporter=' . ($supporter ? '1' : '0')
- . '&confirmed',
+ page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
+ _('cancel'),
+ 'cancel'
+ ),
+ button(
+ page_link_to('user_angeltypes', [
+ 'action' => 'update',
+ 'user_angeltype_id' => $user_angeltype['id'],
+ 'supporter' => ($supporter ? '1' : '0'),
+ 'confirmed' => 1,
+ ]),
_('yes'),
'ok'
)
@@ -42,9 +48,19 @@ function UserAngelTypes_delete_all_view($angeltype)
msg(),
info(sprintf(_('Do you really want to deny all users for %s?'), $angeltype['name']), true),
buttons([
- button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'),
button(
- page_link_to('user_angeltypes') . '&action=delete_all&angeltype_id=' . $angeltype['id'] . '&confirmed',
+ page_link_to(
+ 'angeltypes',
+ ['action' => 'view', 'angeltype_id' => $angeltype['id']]
+ ),
+ _('cancel'),
+ 'cancel'
+ ),
+ button(
+ page_link_to(
+ 'user_angeltypes',
+ ['action' => 'delete_all', 'angeltype_id' => $angeltype['id'], 'confirmed' => 1]
+ ),
_('yes'),
'ok'
)
@@ -62,9 +78,11 @@ function UserAngelTypes_confirm_all_view($angeltype)
msg(),
info(sprintf(_('Do you really want to confirm all users for %s?'), $angeltype['name']), true),
buttons([
- button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'),
+ button(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]), _('cancel'),
+ 'cancel'),
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'),
'ok'
)
@@ -84,9 +102,16 @@ function UserAngelType_confirm_view($user_angeltype, $user, $angeltype)
msg(),
info(sprintf(_('Do you really want to confirm %s for %s?'), User_Nick_render($user), $angeltype['name']), true),
buttons([
- button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'),
button(
- page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed',
+ page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
+ _('cancel'),
+ 'cancel'
+ ),
+ button(
+ page_link_to(
+ 'user_angeltypes',
+ ['action' => 'confirm', 'user_angeltype_id' => $user_angeltype['id'], 'confirmed' => 1]
+ ),
_('yes'),
'ok'
)
@@ -106,9 +131,14 @@ function UserAngelType_delete_view($user_angeltype, $user, $angeltype)
msg(),
info(sprintf(_('Do you really want to delete %s from %s?'), User_Nick_render($user), $angeltype['name']), true),
buttons([
- button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'),
button(
- page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed',
+ page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
+ _('cancel'),
+ 'cancel'
+ ),
+ button(
+ page_link_to('user_angeltypes',
+ ['action' => 'delete', 'user_angeltype_id' => $user_angeltype['id'], 'confirmed' => 1]),
_('yes'),
'ok'
)
@@ -132,7 +162,11 @@ function UserAngelType_add_view($angeltype, $users_source, $user_id)
return page_with_title(_('Add user to angeltype'), [
msg(),
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_info(_('Angeltype'), $angeltype['name']),
@@ -153,9 +187,16 @@ function UserAngelType_join_view($user, $angeltype)
msg(),
info(sprintf(_('Do you really want to add %s to %s?'), User_Nick_render($user), $angeltype['name']), true),
buttons([
- button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _('cancel'), 'cancel'),
button(
- page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'] . '&user_id=' . $user['UID'] . '&confirmed',
+ page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
+ _('cancel'),
+ 'cancel'
+ ),
+ button(
+ page_link_to(
+ 'user_angeltypes',
+ ['action' => 'add', 'angeltype_id' => $angeltype['id'], 'user_id' => $user['UID'], 'confirmed' => 1]
+ ),
_('save'),
'ok'
)
diff --git a/includes/view/User_view.php b/includes/view/User_view.php
index 932614a7..c1e6f49e 100644
--- a/includes/view/User_view.php
+++ b/includes/view/User_view.php
@@ -127,7 +127,7 @@ function User_registration_success_view($event_welcome_message)
'<h2>' . _('What can I do?') . '</h2>',
'<p>' . _('Please read about the jobs you can do to help us.') . '</p>',
buttons([
- button(page_link_to('angeltypes') . '&action=about', _('Teams/Job description') . ' &raquo;')
+ 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'))
]),
info(sprintf(_('Angel should receive at least %d vouchers.'), User_get_eligable_voucher_count($user)), true),
- form([
- form_spinner('vouchers', _('Number of vouchers given out'), $user['got_voucher']),
- form_submit('submit', _('Save'))
- ], page_link_to('users') . '&action=edit_vouchers&user_id=' . $user['UID'])
+ form(
+ [
+ form_spinner('vouchers', _('Number of vouchers given out'), $user['got_voucher']),
+ form_submit('submit', _('Save'))
+ ],
+ page_link_to('users', ['action' => 'edit_vouchers', 'user_id' => $user['UID']])
+ )
]);
}
@@ -208,7 +211,7 @@ function Users_view(
$user['Tshirt'] = glyph_bool($user['Tshirt']);
$user['lastLogIn'] = date(_('m/d/Y h:i a'), $user['lastLogIn']);
$user['actions'] = table_buttons([
- button_glyph(page_link_to('admin_user') . '&id=' . $user['UID'], 'edit', 'btn-xs')
+ button_glyph(page_link_to('admin_user', ['id' => $user['UID']]), 'edit', 'btn-xs')
]);
}
$users[] = [
@@ -253,7 +256,11 @@ function Users_view(
*/
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)) {
$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'),
'btn-xs'
);
@@ -356,8 +363,15 @@ function User_view_myshift($shift, $user_source, $its_me)
($shift['start'] > time() + config('last_unsubscribe') * 3600)
|| in_array('user_shifts_admin', $privileges)
) {
+ $parameters = [
+ 'cancel' => $shift['id'],
+ 'id' => $user_source['UID'],
+ ];
+ if ($its_me) {
+ $parameters['id'] = '';
+ }
$myshift['actions'][] = button(
- page_link_to('user_myshifts') . ((!$its_me) ? '&id=' . $user_source['UID'] : '') . '&cancel=' . $shift['id'],
+ page_link_to('user_myshifts', $parameters),
glyph('trash') . _('sign off'),
'btn-xs'
);
@@ -427,7 +441,7 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
div('col-md-12', [
buttons([
$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')
) : '',
$admin_user_privilege ? button(
@@ -435,24 +449,24 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
glyph('road') . _('driving license')
) : '',
($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')
) : '',
$admin_user_privilege ? button(
- page_link_to('users') . '&action=edit_vouchers&user_id=' . $user_source['UID'],
+ page_link_to('users', ['action' => 'edit_vouchers', 'user_id' => $user_source['UID']]),
glyph('cutlery') . _('Edit vouchers')
) : '',
$its_me ? button(page_link_to('user_settings'), glyph('list-alt') . _('Settings')) : '',
$its_me ? button(
- page_link_to('ical') . '&key=' . $user_source['api_key'],
+ page_link_to('ical', ['key' => $user_source['api_key']]),
glyph('calendar') . _('iCal Export')
) : '',
$its_me ? button(
- page_link_to('shifts_json_export') . '&key=' . $user_source['api_key'],
+ page_link_to('shifts_json_export', ['key' => $user_source['api_key']]),
glyph('export') . _('JSON Export')
) : '',
$its_me ? button(
- page_link_to('user_myshifts') . '&reset',
+ page_link_to('user_myshifts', ['reset' => 1]),
glyph('repeat') . _('Reset API key')
) : ''
])
@@ -607,7 +621,7 @@ function User_groups_render($user_groups)
function User_Nick_render($user_source)
{
return '<a class="' . ($user_source['Gekommen'] ? '' : 'text-muted') . '" href="'
- . page_link_to('users') . '&amp;action=view&amp;user_id=' . $user_source['UID']
+ . page_link_to('users', ['action' => 'view', 'user_id' => $user_source['UID']])
. '"><span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . '</a>';
}