1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-22 04:23:01 +00:00

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.

This commit is contained in:
Starbeamrainbowlabs 2020-06-04 19:11:29 +01:00
parent 79ddc234d2
commit 237d10f908
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
3 changed files with 12 additions and 7 deletions

View file

@ -28,6 +28,7 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
### Fixed ### Fixed
- Squashed a warning when using the fenced code block syntax - 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 ## v0.21

View file

@ -1,7 +1,7 @@
<?php <?php
register_module([ register_module([
"name" => "Page editor", "name" => "Page editor",
"version" => "0.17.7", "version" => "0.17.8",
"author" => "Starbeamrainbowlabs", "author" => "Starbeamrainbowlabs",
"description" => "Allows you to edit pages by adding the edit and save actions. You should probably include this one.", "description" => "Allows you to edit pages by adding the edit and save actions. You should probably include this one.",
"id" => "page-edit", "id" => "page-edit",
@ -72,8 +72,7 @@ register_module([
$isOtherUsersPage // this page actually belongs to another user $isOtherUsersPage // this page actually belongs to another user
) )
{ {
if(!$creatingpage) if(!$creatingpage) {
{
// The page already exists - let the user view the page source // The page already exists - let the user view the page source
$sourceViewContent = "<p>$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 <a href='index.php?action=login&returnto=" . rawurlencode($_SERVER["REQUEST_URI"]) . "'>logging in</a>.</p>\n"; $sourceViewContent = "<p>$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 <a href='index.php?action=login&returnto=" . rawurlencode($_SERVER["REQUEST_URI"]) . "'>logging in</a>.</p>\n";
@ -91,8 +90,7 @@ register_module([
exit(page_renderer::render_main("Viewing source for $env->page", $sourceViewContent)); exit(page_renderer::render_main("Viewing source for $env->page", $sourceViewContent));
} }
else else {
{
$errorMessage = "<p>The page <code>$env->page</code> does not exist, but you do not have permission to create it.</p><p>If you haven't already, perhaps you should try <a href='index.php?action=login&returnto=" . rawurlencode($_SERVER["REQUEST_URI"]) . "'>logging in</a>.</p>\n"; $errorMessage = "<p>The page <code>$env->page</code> does not exist, but you do not have permission to create it.</p><p>If you haven't already, perhaps you should try <a href='index.php?action=login&returnto=" . rawurlencode($_SERVER["REQUEST_URI"]) . "'>logging in</a>.</p>\n";
if($isOtherUsersPage) { if($isOtherUsersPage) {
@ -111,6 +109,9 @@ register_module([
if(!$env->is_logged_in and $settings->anonedits) { if(!$env->is_logged_in and $settings->anonedits) {
$content .= "<p><strong>Warning: You are not logged in! Your IP address <em>may</em> be recorded.</strong></p>"; $content .= "<p><strong>Warning: You are not logged in! Your IP address <em>may</em> be recorded.</strong></p>";
} }
if(isset($_GET["redirected_from"])) {
$content .= "<p><em>Redirected from <a href='?page=".rawurlencode($_GET["redirected_from"])."&amp;redirect=no'>".htmlentities($_GET["redirected_from"])."</a></em></p>\n";
}
// Include preview, if set // Include preview, if set
if(isset($_POST['preview-edit']) && isset($_POST['content'])) { if(isset($_POST['preview-edit']) && isset($_POST['content'])) {

View file

@ -1,7 +1,7 @@
<?php <?php
register_module([ register_module([
"name" => "Page viewer", "name" => "Page viewer",
"version" => "0.16.8", "version" => "0.16.9",
"author" => "Starbeamrainbowlabs", "author" => "Starbeamrainbowlabs",
"description" => "Allows you to view pages. You really should include this one.", "description" => "Allows you to view pages. You really should include this one.",
"id" => "page-view", "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 // TODO: make this intelligent so we only redirect if the user is actually able to create the page
if($settings->editing) { if($settings->editing) {
// Editing is enabled, redirect to the editing page // 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 http_response_code(307); // Temporary redirect
header("location: index.php?action=edit&newpage=yes&page=" . rawurlencode($env->page)); header("location: $redirectUrl");
exit(); exit();
} else { } else {
// Editing is disabled, show an error message // Editing is disabled, show an error message