PDA

View Full Version : Which of these code changes are 'safe'/correct?


Razasharp
03-13-2006, 10:36 PM
I am trying to change the page a user is sent to after replying to a thread.

With help from members Merk and Andreas I have located the bit of the newreply.php file which I need to change, in particular this bit:

$vbulletin->url = 'showthread.php?' . $vbulletin->session->vars['sessionurl'] . "p=$newpost[postid]#post$newpost[postid]";

which is half way ish down this bit of code:


if (strtolower($vbulletin->userinfo['lang_charset']) == 'iso-8859-1')
{
$vbulletin->userinfo['lang_charset'] = 'windows-1252';
}

$db->close();
@header('Content-Type: text/html' . iif($vbulletin->userinfo['lang_charset'] != '', '; charset=' . $vbulletin->userinfo['lang_charset']));
echo "<!-- postbit ok --><!-- time " . TIMENOW . " -->" . process_replacement_vars($postbits);
// ################################################## ###########################
// ################################################## ###########################
// ################################################## ###########################
}
else
{
if ($newpost['visible'] OR can_moderate($foruminfo['forumid'], 'canmoderateposts'))
{
if ($threadview < $threadinfo['lastpost'])
{
$vbulletin->url = 'showthread.php?' . $vbulletin->session->vars['sessionurl'] . "p=$newpost[postid]&amp;posted=1#post$newpost[postid]";
}
else
{
$vbulletin->url = 'showthread.php?' . $vbulletin->session->vars['sessionurl'] . "p=$newpost[postid]#post$newpost[postid]";
}
$forceredirect = false;
}
else
{
$forceredirect = true;
$vbulletin->url = 'forumdisplay.php?' . $vbulletin->session->vars['sessionurl'] . "f=$foruminfo[forumid]";
}

($hook = vBulletinHook::fetch_hook('newreply_post_complete' )) ? eval($hook) : false;
eval(print_standard_redirect('redirect_postthanks' , true, $forceredirect));
}

} // end if

}


As you can see the hook is located towards the bottom and I created a plug-in for that location and simply entered:

$vbulletin->url = 'my own url';

in the php code bit and it works fine.

However I am worried about the other bits of code in the original file above the hook location, so am wondering whether I need to add any of that in my plug-in? Or will what I have done only effect the line I want it to?

Sorry if its obvious!

Paul M
03-13-2006, 10:43 PM
The other code is simply building different urls depending on certain conditions - if you always want it to go to your url then you don't need to worry.

Razasharp
03-13-2006, 10:53 PM
Thanks Paul.... I'm not so sure now - I thought it just went to the last post regardless? But thinking about it, what happens if someones replying to a thread but in the meantime it gets locked, they hit reply and don't have the permissions so then what? Will it 'break' that bit of code? :-/

merk
03-14-2006, 12:07 AM
The code dealing with $vbulletin->url has nothing to do with closed threads.

The logic is as follows:

Is the thread visible (not moderated) or is the user a moderator?

YES! --> Go to that post if its 'after' your last read post in that thread, otherwise go to the newest unread post

NO! --> The thread went into the moderation queue and the user cant see the thread again, so redirect to the forum.

I see no reason modifying your url wont change anything.

Razasharp
03-14-2006, 12:37 AM
I see no reason modifying your url wont change anything.


Thanks Merk.. So you give my code change a thumps up ?
Sorry to double check every last detail - I just dont want to break anything :bunny:

merk
03-14-2006, 12:57 AM
The only way you'll learn is when you break something. Ive had a few 'oh shit looks like im rolling back to last nights backup' moments :)

Looks fine.

Razasharp
03-14-2006, 01:28 AM
lol don't say that you'll give me a heart attack!

Thanks for checking it over :) (Im sure I'll get to the 'oh shit' stage one day too!)