--- loncom/publisher/lonunauthorized.pm 2013/06/04 22:20:16 1.16 +++ loncom/publisher/lonunauthorized.pm 2018/11/26 03:49:04 1.19 @@ -1,7 +1,7 @@ # The LearningOnline Network # Unauthorized to access construction space # -# $Id: lonunauthorized.pm,v 1.16 2013/06/04 22:20:16 raeburn Exp $ +# $Id: lonunauthorized.pm,v 1.19 2018/11/26 03:49:04 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -85,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).''). '
'. ''); } + } 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(''. @@ -191,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('' @@ -203,15 +229,51 @@ sub handler { my $realownerhome= &Apache::lonnet::homeserver($realownername,$realownerdom); unless ($realownerhome eq 'no_host') { - my $plainname=&Apache::loncommon::plainname($realownername,$realownerdom); - my $user=$realownername.':'.$realownerdom; - my $userlink=&Apache::loncommon::aboutmewrapper( - $plainname.' ('.$user.')' - ,$realownername - ,$realownerdom); - $r->print('
' - .&mt('Contact [_1] for access.',$userlink) - .'
'); + if (&Apache::lonnet::is_course($realownerdom,$realownername)) { + my $ccrole = 'cc'; + my %crsenv = &Apache::lonnet::coursedescription("$realownerdom/$realownername",{one_time => 1}); + my $cdesc = $crsenv{'description'}; + my $crstype = $crsenv{'type'}; + if ($crstype eq 'Community') { + $ccrole = 'co'; + } + my $rolename = $crsenv{$ccrole.'.plaintext'}; + if ($rolename eq '') { + $rolename = &Apache::lonnet::plaintext($ccrole,$crstype,$realownerdom.'_'.$realownername,1); + } + my $allowed = &Apache::lonnet::allowed('mdc',$realownerdom.'_'.$realownername); + if (!$allowed) { + my %roleshash = &Apache::lonnet::get_my_roles('','','userroles',['active'], + [$ccrole],[$realownerdom]); + if (exists($roleshash{$realownername.':'.$realownerdom.':'.$ccrole})) { + $r->print(&mt('[_1]Switch role[_2] for access', + '&"'). + '&orgurl='.&HTML::Entities::encode($env{'request.editurl'},'<>&"'). + '">','')); + } else { + if ($crstype eq 'Community') { + $r->print('' + .&mt('Contact a [_1] in the community ([_2]) for access.',$rolename,$cdesc) + .'
'); + } else { + $r->print('' + .&mt('Contact a [_1] in the course ([_2]) for access.',$rolename,$cdesc) + .'
'); + } + } + } + } else { + my $plainname=&Apache::loncommon::plainname($realownername,$realownerdom); + my $user=$realownername.':'.$realownerdom; + my $userlink=&Apache::loncommon::aboutmewrapper( + $plainname.' ('.$user.')' + ,$realownername + ,$realownerdom); + $r->print('' + .&mt('Contact [_1] for access.',$userlink) + .'
'); + } } } $r->print(&Apache::loncommon::end_page());