From 6d54d7491889515a4158dfde5dd8e8d9d06fbb09 Mon Sep 17 00:00:00 2001 From: Jimmi08 Date: Sat, 2 Apr 2022 18:00:19 +0200 Subject: [PATCH] #4245 stay on correct page after editing paginated topic CLOSES #4245 Tested with PHP 8.1 Description: When you edit a post on the next page (with the paginated topic), after saving you are redirected to the first page and you don't see that edited message then. Changes added p parameter to edit URL in post options and edit image shortcodes used this parameter when redirecting after reply is updated it is not needed when updating the thread because you are always on the first page added check if it is the first page, then the parameter is not used (to have the same behavior as with thread). Tested PHP 7.4. + PHP 8 core bootstrap5 theme and custom theme with custom forum templates Important Note:: Updating/Fixing postoptions are/will be separated issues (more than one). It needs some changes but they are not related to this issue. So now just changed links, nothing more. Enhancement Note: $_GET['p'] could be replaced by saving the actual page in post data (like thread works - that information should be available) but it is too complicated now for me and there is a bigger risk that something will not work. Free do it this way if you have time. --- e107_plugins/forum/forum_post.php | 11 ++++++++++- .../forum/shortcodes/batch/view_shortcodes.php | 10 +++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php index c520747ef..5f9297ce1 100644 --- a/e107_plugins/forum/forum_post.php +++ b/e107_plugins/forum/forum_post.php @@ -1585,7 +1585,16 @@ class forum_post_handler // $url = e107::getUrl()->create('forum/thread/post', "id={$this->data['post_id']}", 'encode=0&full=1'); // XXX what data is available, find thread name - $url = e107::url('forum','topic',$this->data); // ."&f=post"; + $page= (varset($_GET['p']) ? (int)$_GET['p'] : 1); + if($page > 1) + { + $url = e107::url('forum','topic',$this->data)."?p=".$page; + } + else { + $url = e107::url('forum','topic',$this->data); + } + + //$url = e107::url('forum','topic',$this->data); // ."&f=post"; $this->redirect($url); diff --git a/e107_plugins/forum/shortcodes/batch/view_shortcodes.php b/e107_plugins/forum/shortcodes/batch/view_shortcodes.php index 350b7f71d..b1323e60d 100644 --- a/e107_plugins/forum/shortcodes/batch/view_shortcodes.php +++ b/e107_plugins/forum/shortcodes/batch/view_shortcodes.php @@ -672,7 +672,8 @@ class plugin_forum_view_shortcodes extends e_shortcode if(USER && !empty($this->postInfo['post_user']) && $this->postInfo['post_user'] == USERID && $this->var['thread_active']) { - $qry = array('f' => 'edit', 'id' => $this->postInfo['post_thread'], 'post' => $this->postInfo['post_id']); + $page= (varset($_GET['p']) ? (int)$_GET['p'] : 1); + $qry = array('f' => 'edit', 'id' => $this->postInfo['post_thread'], 'post' => $this->postInfo['post_id'], 'p' => $page); $editURL = e107::url('forum', 'post', null, array('query' => $qry)); return "" . IMAGE_edit . ' '; @@ -912,6 +913,7 @@ class plugin_forum_view_shortcodes extends e_shortcode $tp = e107::getParser(); $threadID = !empty($this->postInfo['post_thread']) ? $this->postInfo['post_thread'] : 0; $postID = !empty($this->postInfo['post_id']) ? $this->postInfo['post_id'] : 0; + $page= (varset($_GET['p']) ? (int)$_GET['p'] : 1); // {EMAILITEM} {PRINTITEM} {REPORTIMG}{EDITIMG}{QUOTEIMG} $text = '
@@ -944,7 +946,8 @@ class plugin_forum_view_shortcodes extends e_shortcode { - $url = e107::url('forum', 'post') . "?f=edit&id=" . $threadID . "&post=" . $postID; + //$url = e107::url('forum', 'post') . "?f=edit&id=" . $threadID . "&post=" . $postID; + $url = e107::url('forum', 'post') . "?f=edit&id=" . $threadID . "&post=" . $postID . "&p=".$page; //$url = e107::getUrl()->create('forum/thread/edit', array('id' => $threadID, 'post'=>$postID)); $text .= "
  • " . LAN_EDIT . " " . $tp->toGlyph('fa-edit') . "
  • "; @@ -981,7 +984,8 @@ class plugin_forum_view_shortcodes extends e_shortcode if((USER && isset($this->postInfo['post_user']) && $this->postInfo['post_user'] != USERID && $this->var['thread_active'])) { - $url = e107::url('forum', 'post') . "?f=edit&id=" . $threadID . "&post=" . $postID; + //$url = e107::url('forum', 'post') . "?f=edit&id=" . $threadID . "&post=" . $postID; + $url = e107::url('forum', 'post') . "?f=edit&id=" . $threadID . "&post=" . $postID . "&p=".$page; // $url = e107::getUrl()->create('forum/thread/edit', array('id' => $threadID, 'post'=>$postID)); $text .= "
  • " . LAN_EDIT . " " . $tp->toGlyph('fa-edit') . "
  • ";