Page 1 of 1

Redirect page after moving topic

Posted: Fri Jun 28, 2013 10:02 pm
by theallzaz
When a moderator try to move a topic, he receive the message below, right?

The selected topic has been moved successfully.
Return to the previous page
Return to the forum last visited
Go to the new forum


Furthermore, if he does not click on any of the options, the moderator is automatically redirected to "Return to the previous page" after 3 seconds. There is a way to make Return to the forum last visited by default? Because I have a plugin and for bug reasons i am trying to make this by default. I found the code of that page, in root/includes/mcp/mcp_main.php

Code: Select all

		$message = $user->lang[$success_msg];
		$message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id") . '">', '</a>');
		$message .= '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>');
		$message .= '<br /><br />' . sprintf($user->lang['RETURN_NEW_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$to_forum_id") . '">', '</a>');
I tried to reverse the order of them, but the only thing that changed was the "screen", because the user continued being redirected to the Return to the forum last visited.

Anyone know if there is a way to change this?

Thank you

Re: Redirect page after moving topic

Posted: Fri Jun 28, 2013 10:31 pm
by Brf
The order of the links in the message is irrelevant. The redirect is in the meta statement.

Re: Redirect page after moving topic

Posted: Fri Jun 28, 2013 11:18 pm
by theallzaz
Brf wrote:The order of the links in the message is irrelevant. The redirect is in the meta statement.
I don't understand about phpBB coding, but do you know what file i need to edit? Do you know what code can change the default action?

Re: Redirect page after moving topic

Posted: Sat Jun 29, 2013 1:08 am
by Tom
Well, if it makes you feel any better, you're looking in the right place. :)

To change the redirect to point to the forum last visited instead of the "previous page", open /includes/mcp/mcp_main.php and find the following code:

Code: Select all

    $redirect = request_var('redirect', "index.$phpEx");
    $redirect = reapply_sid($redirect);

    if (!$success_msg)
    {
        redirect($redirect);
    }
    else
    {
        meta_refresh(3, $redirect);

        $message = $user->lang[$success_msg];
        $message .= '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>');
        $message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id") . '">', '</a>'); 
Replace it with this:

Code: Select all

    $old_redirect = request_var('redirect', "index.$phpEx");
    $old_redirect = reapply_sid($redirect);
    $redirect = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id");

    if (!$success_msg)
    {
        redirect($redirect);
    }
    else
    {
        meta_refresh(3, $redirect);

        $message = $user->lang[$success_msg];
        $message .= '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $old_redirect . '">', '</a>');
        $message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect . '">', '</a>'); 
And that's it! I've tested it on a local installation of phpBB and it appears to produce the desired behavior.

Re: Redirect page after moving topic

Posted: Sat Jun 29, 2013 3:27 am
by Brf
Yes. The redirect in the meta, immediately before the code that was posted already.

Re: Redirect page after moving topic

Posted: Sat Jun 29, 2013 10:25 am
by Tom
Well, he seemed a bit confused as to where exactly he should edit the code, so I just wanted to help make it clear. ;)

Re: Redirect page after moving topic

Posted: Sat Jun 29, 2013 2:12 pm
by Brf
Yeah. I would have posted the code myself, but I do not have access to code from my iPad ;)