From 237d10f908d2db7232cee79368db9be20c00d58f Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Thu, 4 Jun 2020 19:11:29 +0100 Subject: [PATCH] Bugfix: Display link when redirect page sends user to a another page that doesn't exist Note that this only shows for users with permission to edit the target page at the moment. --- Changelog.md | 1 + modules/page-edit.php | 11 ++++++----- modules/page-view.php | 7 +++++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Changelog.md b/Changelog.md index b611242..645dcdb 100644 --- a/Changelog.md +++ b/Changelog.md @@ -28,6 +28,7 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t ### Fixed - Squashed a warning when using the fenced code block syntax + - If a redirect page sends you to a page that doesn't exist, a link back to the redirect page itself is now displayed ## v0.21 diff --git a/modules/page-edit.php b/modules/page-edit.php index 3b9b0fb..c217740 100644 --- a/modules/page-edit.php +++ b/modules/page-edit.php @@ -1,7 +1,7 @@ "Page editor", - "version" => "0.17.7", + "version" => "0.17.8", "author" => "Starbeamrainbowlabs", "description" => "Allows you to edit pages by adding the edit and save actions. You should probably include this one.", "id" => "page-edit", @@ -72,8 +72,7 @@ register_module([ $isOtherUsersPage // this page actually belongs to another user ) { - if(!$creatingpage) - { + if(!$creatingpage) { // The page already exists - let the user view the page source $sourceViewContent = "

$settings->sitename does not allow anonymous users to make edits. You can view the source of $env->page below, but you can't edit it. You could, however, try logging in.

\n"; @@ -91,8 +90,7 @@ register_module([ exit(page_renderer::render_main("Viewing source for $env->page", $sourceViewContent)); } - else - { + else { $errorMessage = "

The page $env->page does not exist, but you do not have permission to create it.

If you haven't already, perhaps you should try logging in.

\n"; if($isOtherUsersPage) { @@ -111,6 +109,9 @@ register_module([ if(!$env->is_logged_in and $settings->anonedits) { $content .= "

Warning: You are not logged in! Your IP address may be recorded.

"; } + if(isset($_GET["redirected_from"])) { + $content .= "

Redirected from ".htmlentities($_GET["redirected_from"])."

\n"; + } // Include preview, if set if(isset($_POST['preview-edit']) && isset($_POST['content'])) { diff --git a/modules/page-view.php b/modules/page-view.php index 4e91acc..f1205e6 100644 --- a/modules/page-view.php +++ b/modules/page-view.php @@ -1,7 +1,7 @@ "Page viewer", - "version" => "0.16.8", + "version" => "0.16.9", "author" => "Starbeamrainbowlabs", "description" => "Allows you to view pages. You really should include this one.", "id" => "page-view", @@ -40,8 +40,11 @@ register_module([ // TODO: make this intelligent so we only redirect if the user is actually able to create the page if($settings->editing) { // Editing is enabled, redirect to the editing page + $redirectUrl = "index.php?action=edit&newpage=yes&page=".rawurlencode($env->page); + if(isset($_GET["redirected_from"])) + $redirectUrl .= "&redirected_from=".rawurlencode($_GET["redirected_from"]); http_response_code(307); // Temporary redirect - header("location: index.php?action=edit&newpage=yes&page=" . rawurlencode($env->page)); + header("location: $redirectUrl"); exit(); } else { // Editing is disabled, show an error message