From db6ccac0f29076aa2031d0e26d2ed66e0d9b3b94 Mon Sep 17 00:00:00 2001 From: kumy Date: Sun, 8 Oct 2023 18:30:48 +0200 Subject: [PATCH] fix: Use an intermediate page to link to a move id (#877) Closes #873 --- .../js/geokrety/geokrety_details_map.tpl.js | 5 ++++- .../GeoKrety/Controller/Pages/GeokretDetails.php | 15 +++++++++++++++ website/app/authorizations.ini | 1 + website/app/routes.ini | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/website/app-templates/smarty/js/geokrety/geokrety_details_map.tpl.js b/website/app-templates/smarty/js/geokrety/geokrety_details_map.tpl.js index 8f5cdb06a7..31f4d0a2da 100644 --- a/website/app-templates/smarty/js/geokrety/geokrety_details_map.tpl.js +++ b/website/app-templates/smarty/js/geokrety/geokrety_details_map.tpl.js @@ -105,6 +105,9 @@ function onEachFeature(feature, layer) { } else { author = `${ author }`; } + let move_link = "{'geokret_details_by_move_id'|alias:'gkid=%GKID%,moveid=%MOVEID%'}" + .replace('%MOVEID%', feature.properties.move_id) + .replace('%GKID%', "{$geokret->gkid}"); layer.bindPopup(`

${ moveTypeIcon(feature.properties.move_type) } ${ moveTypeText(feature.properties.move_type) }

{t}Move details:{/t}
@@ -119,7 +122,7 @@ function onEachFeature(feature, layer) {
${ previousMoveButton(feature) } - + {t}Show move{/t} ${ nextMoveButton(feature) } diff --git a/website/app/GeoKrety/Controller/Pages/GeokretDetails.php b/website/app/GeoKrety/Controller/Pages/GeokretDetails.php index 9229506e03..efee1312f2 100644 --- a/website/app/GeoKrety/Controller/Pages/GeokretDetails.php +++ b/website/app/GeoKrety/Controller/Pages/GeokretDetails.php @@ -27,4 +27,19 @@ public function get($f3) { // TODO check if GeoKret has already been discovered, and display Tracking Code } + + public function geokret_details_by_move_id(\Base $f3) { + $move_id = $f3->get('PARAMS.moveid'); + if (!ctype_digit($move_id)) { + \Flash::instance()->addMessage(_('Invalid log_id'), 'danger'); + $f3->reroute(sprintf('@geokret_details(@gkid=%s)', $this->geokret->gkid)); + } + $move = new Move(); + $move->load(['id = ?', $move_id]); + if ($move->dry()) { + \Flash::instance()->addMessage(_('Invalid log_id'), 'danger'); + $f3->reroute(sprintf('@geokret_details(@gkid=%s)', $this->geokret->gkid)); + } + $f3->reroute(sprintf('@geokret_details_paginate(@gkid=%s,@page=%d)#log%d', $this->geokret->gkid, $move->getMoveOnPage(), $move_id)); + } } diff --git a/website/app/authorizations.ini b/website/app/authorizations.ini index 84504d65b7..c1de10bf50 100644 --- a/website/app/authorizations.ini +++ b/website/app/authorizations.ini @@ -55,6 +55,7 @@ allow @user_update_email_revalidate = * allow @user_update_email_revalidate_token = * allow @geokret_details = * allow @geokret_details_paginate = * +allow @geokret_details_by_move_id = * allow @photo_gallery = * allow @photo_gallery_paginate = * allow @move_create = * diff --git a/website/app/routes.ini b/website/app/routes.ini index f28fd0737e..b01864ffe6 100644 --- a/website/app/routes.ini +++ b/website/app/routes.ini @@ -139,6 +139,7 @@ POST @geokrety_move_edit: /moves/@moveid/edit = \GeoKrety\Controller\MoveCreate- GET @move_delete: /moves/@moveid/delete [sync] = \GeoKrety\Controller\MoveDelete->get GET @move_delete: /moves/@moveid/delete [ajax] = \GeoKrety\Controller\MoveDelete->get_ajax POST @move_delete: /moves/@moveid/delete = \GeoKrety\Controller\MoveDelete->post +GET @geokret_details_by_move_id: /geokrety/@gkid/move/@moveid = \GeoKrety\Controller\GeokretDetails->geokret_details_by_move_id ; Validations POST @validate_tracking_code: /validate/tracking-code = \GeoKrety\Controller\Validation\TrackingCode->post