Nice hack.
But I can suggest, instead of checking your forum path to replace /forum/private.php just use private.php$session[sessionurl_q] and system will do it for you.
I mean code must look like
Code:
<if condition="$bbuserinfo['pmunread']">
<td class="alt2" valign="top" nowrap="nowrap">
<a href="private.php$session[sessionurl_q]"><img src="$stylevar[imgdir_misc]/newpm.gif" alt="You have a new PM" border="0"></a>
</td>
</if>