--- loncom/publisher/lonunauthorized.pm 2011/11/13 01:07:09 1.11 +++ loncom/publisher/lonunauthorized.pm 2018/11/26 13:07:41 1.17.2.1 @@ -1,7 +1,7 @@ # The LearningOnline Network # Unauthorized to access construction space # -# $Id: lonunauthorized.pm,v 1.11 2011/11/13 01:07:09 raeburn Exp $ +# $Id: lonunauthorized.pm,v 1.17.2.1 2018/11/26 13:07:41 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -32,7 +32,6 @@ use strict; use Apache::Constants qw(:common); use Apache::loncommon; use Apache::lonnet; -use Apache::loncacc; use Apache::lonlocal; use LONCAPA(); use HTML::Entities(); @@ -49,15 +48,15 @@ sub handler { my ($ownername,$ownerdomain,$ownerhome); if ($env{'request.editurl'} ne '') { ($ownername,$ownerdomain,$ownerhome) = - &Apache::loncacc::constructaccess($env{'request.editurl'}); + &Apache::lonnet::constructaccess($env{'request.editurl'}); } # Breadcrumbs &Apache::lonhtmlcommon::clear_breadcrumbs(); if ($env{'request.role'} =~ /^(au|ca|aa)/) { &Apache::lonhtmlcommon::add_breadcrumb({ - 'text' => 'Construction Space', - 'href' => &Apache::loncommon::authorspace(), + 'text' => 'Authoring Space', + 'href' => &Apache::loncommon::authorspace($env{'request.editurl'}), }); } elsif (($env{'request.course.id'}) && (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) { @@ -68,7 +67,7 @@ sub handler { } # print header - $r->print(&Apache::loncommon::start_page("Failed Access to Construction Space", + $r->print(&Apache::loncommon::start_page("Failed Access to Authoring Space", undef, {'domain' => $ownerdomain,}). &Apache::lonhtmlcommon::breadcrumbs()); @@ -86,7 +85,7 @@ sub handler { my $switchlink = '/adm/switchserver?otherserver='.$ownerhome. '&origurl='.&HTML::Entities::encode($env{'request.editurl'},'<>&"'); $r->print('

'. - &mt('The construction space for this resource is located on a different server: [_1]', + &mt('The Authoring Space for this resource is located on a different server: [_1]', ''.&Apache::lonnet::hostname($ownerhome).''). '

'. '

'. @@ -103,7 +102,8 @@ sub handler { if ($ENV{'REDIRECT_URL'} =~ m{^/adm/([^/]+)}) { my $action = $1; my ($option,$filename,$filename1,$filename2,$decompress, - $qualifiedfilename); + $qualifiedfilename,$warning); + my %deniedactions = &get_denied_action_text(); if ($ENV{'REDIRECT_QUERY_STRING'} ne '') { foreach my $pair (split(/&/,$ENV{'REDIRECT_QUERY_STRING'})) { my ($name,$value) = split(/=/,$pair); @@ -122,7 +122,7 @@ sub handler { $option = 'decompress'; } elsif ($name eq 'qualifiedfilename') { $qualifiedfilename = $value; - } elsif ($name = 'versionone') { + } elsif ($name eq 'versionone') { if ($value eq 'priv') { $option = 'cstr'; } @@ -131,11 +131,11 @@ sub handler { $option = 'cstr'; } } elsif ($name eq 'filetwo') { - $option = $value; + $option = $value; } } if (($action eq 'upload') || ($action eq 'testbank')) { - if (($filename1 ne '') && ($filename ne '')) { + if (($filename1 ne '') && ($filename2 ne '')) { $filename = $filename1.$filename2; } } elsif ($action eq 'cfile') { @@ -145,8 +145,6 @@ sub handler { $filename = $qualifiedfilename; } } - my %deniedactions = &get_denied_action_text(); - my $warning; if ($option eq 'decompress') { $warning = $deniedactions{$option}; } else { @@ -155,7 +153,7 @@ sub handler { if ($warning) { if (($action eq 'diff') && ($option ne 'cstr')) { $r->print('

'. - $deniedactions{$action}.'

' + $deniedactions{$action}.'

'. &mt('You do not have privileges to view the published resource').' '. ''.$filename.''. '

'); @@ -174,13 +172,40 @@ sub handler { &mt('You are not permitted to take this action.'). '

'); } + } elsif (($action eq 'upload') || ($action eq 'testbank')) { + $filename1 = $env{'form.filename1'}; + $filename2 = $env{'form.filename2'}; + if (($filename1 ne '') && ($filename2 ne '')) { + $filename = $filename1.$filename2; + } + $warning = $deniedactions{$action}; + if ($warning) { + if ($filename =~ m{^/priv/.+\.\d+\.[^.]+$}) { + $r->print('

'. + &mt('There is a problem with the filename').' '. + ''.$filename.'

'. + '

'. + &mt('The suggested filename may not include the pattern ".number.extension" as LON-CAPA reserves that pattern for its internal versioning mechanism.'). + '

'); + } else { + $r->print('

'. + $deniedactions{$action}.'

'. + &mt('You do not have authoring privileges for this resource').' '. + ''.$filename.''. + '

'); + } + } else { + $r->print('

'. + &mt('You are not permitted to take this action.'). + '

'); + } } } elsif ($r->uri =~ m{priv/.+\.\d+\.[^.]+$}) { $r->print('

'. &mt('There is a problem with the filename').' '. ''.$r->uri.'

'. '

'. - &mt('You may be attempting to edit a versioned file (files in construction space may not include a version number before the extension).'). + &mt('You may be attempting to edit a versioned file (files in Authoring Space may not include a version number before the extension).'). '

'); } else { $r->print('

'. @@ -192,7 +217,7 @@ sub handler { &mt('There is a problem with the filename').' '. ''.$env{'request.editurl'}.'

'. '

'. - &mt('You may be attempting to edit a versioned file (files in construction space may not include a version number before the extension).'). + &mt('You may be attempting to edit a versioned file (files in Authoring Space may not include a version number before the extension).'). '

'); } else { $r->print('

'