I have a custom
attachnew page for uploading a user picture. After uploading I want the user to return to the list of user pictures, not to the user page.
I have set
redirectto but that (obviously?) fails. I also need to pass a custom template as url param:
template=UserPictureView.
AC
I have updated
Upload.pm with a piece of code from
Save.pm. This function
_getRedirectUrl could be better placed in a central place, and perhaps made accessible in
Func.pm:
sub _getRedirectUrl {
my $session = shift;
my $query = $session->{cgiQuery};
my $redirecturl = $query->param( 'redirectto' );
return '' unless $redirecturl;
if( $redirecturl =~ /^$TWiki::regex{linkProtocolPattern}\:\/\//o ) {
# assuming URL
if ($TWiki::cfg{AllowRedirectUrl}) {
return $redirecturl;
} else {
return '';
}
}
# assuming 'web.topic' or 'topic'
my ( $w, $t ) = $session->normalizeWebTopicName( $session->{webName}, $redirecturl );
$redirecturl = $session->getScriptUrl( 1, 'view', $w, $t );
}
AC
For
Michael's objection to this redundant copying, see
Item3580.
AC