In order to retrun the user to the nodem where she clicked "Sign In..", there must be a query parameter destination passed in the l()-function in php_template_flat_login().

This is what is needed:

...
$nid = arg(1);
if (!$user->uid) {
$message= '

  • '.l(t('Sign in..'),'user/login', array('attributes' => array('rel'=>'nofollow'), 'query' => ('destination=node/'.$nid)) ).'
  • '.l(t('New password'), 'user/password', array('attributes' => array('rel'=>'nofollow'))).'
  • '.l(t('Sign up'), 'user/register', array('attributes' => array('rel'=>'nofollow')) ).'

';
}
...