Index: Viewfile.pm =================================================================== --- Viewfile.pm (revision 4825) +++ Viewfile.pm (working copy) @@ -46,9 +46,12 @@ return unless TWiki::UI::webExists( $webName, $topic ); - my $topRev = TWiki::Store::getRevisionNumber( $webName, $topic, $fileName ); + if ( ! $rev ) { $rev = TWiki::Store::getRevisionNumber( $webName, $topic, $fileName ); }; - if( ( $rev ) && ( $rev ne $topRev ) ) { + my $wikiUserName = &TWiki::userToWikiName( $query->remote_user() ); + my $viewAccessOK = &TWiki::Func::checkAccessPermission( "view", $wikiUserName, undef , $topic, $webName ); + + if( $viewAccessOK ) { my $fileContent = TWiki::Store::readAttachmentVersion( $webName, $topic, $fileName, $rev ); if( $fileContent ) { my $mimeType = _suffixToMimeType( $fileName ); @@ -59,16 +62,10 @@ } else { # If no file content we'll try and show pub content, should there be a warning FIXME } - } - - # this should actually kick off a document conversion - # (.doc, .xls... to .html) and show the html file. - # Convert only if html file does not yet exist - # for now, show the original document: - - my $pubUrlPath = &TWiki::getPubUrlPath(); - my $host = $TWiki::urlHost; - TWiki::UI::redirect( "$host$pubUrlPath/$webName/$topic/$fileName" ); + } else { + TWiki::UI::oops( $webName, $topic, "accessview" ); + return; + }; } sub _suffixToMimeType {