version 1.11, 2011/11/13 01:07:09
|
version 1.19, 2018/11/26 03:49:04
|
Line 32 use strict;
|
Line 32 use strict;
|
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
use Apache::loncommon; |
use Apache::loncommon; |
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::loncacc; |
|
use Apache::lonlocal; |
use Apache::lonlocal; |
use LONCAPA(); |
use LONCAPA(); |
use HTML::Entities(); |
use HTML::Entities(); |
Line 49 sub handler {
|
Line 48 sub handler {
|
my ($ownername,$ownerdomain,$ownerhome); |
my ($ownername,$ownerdomain,$ownerhome); |
if ($env{'request.editurl'} ne '') { |
if ($env{'request.editurl'} ne '') { |
($ownername,$ownerdomain,$ownerhome) = |
($ownername,$ownerdomain,$ownerhome) = |
&Apache::loncacc::constructaccess($env{'request.editurl'}); |
&Apache::lonnet::constructaccess($env{'request.editurl'}); |
} |
} |
|
|
# Breadcrumbs |
# Breadcrumbs |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
if ($env{'request.role'} =~ /^(au|ca|aa)/) { |
if ($env{'request.role'} =~ /^(au|ca|aa)/) { |
&Apache::lonhtmlcommon::add_breadcrumb({ |
&Apache::lonhtmlcommon::add_breadcrumb({ |
'text' => 'Construction Space', |
'text' => 'Authoring Space', |
'href' => &Apache::loncommon::authorspace(), |
'href' => &Apache::loncommon::authorspace($env{'request.editurl'}), |
}); |
}); |
} elsif (($env{'request.course.id'}) && |
} elsif (($env{'request.course.id'}) && |
(&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) { |
(&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) { |
Line 68 sub handler {
|
Line 67 sub handler {
|
} |
} |
|
|
# print header |
# 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, |
undef, |
{'domain' => $ownerdomain,}). |
{'domain' => $ownerdomain,}). |
&Apache::lonhtmlcommon::breadcrumbs()); |
&Apache::lonhtmlcommon::breadcrumbs()); |
Line 86 sub handler {
|
Line 85 sub handler {
|
my $switchlink = '/adm/switchserver?otherserver='.$ownerhome. |
my $switchlink = '/adm/switchserver?otherserver='.$ownerhome. |
'&origurl='.&HTML::Entities::encode($env{'request.editurl'},'<>&"'); |
'&origurl='.&HTML::Entities::encode($env{'request.editurl'},'<>&"'); |
$r->print('<p class="LC_warning">'. |
$r->print('<p class="LC_warning">'. |
&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]', |
'<b><tt>'.&Apache::lonnet::hostname($ownerhome).'</b></tt>'). |
'<b><tt>'.&Apache::lonnet::hostname($ownerhome).'</b></tt>'). |
'</p>'. |
'</p>'. |
'<p class="LC_error"><a href="'.$switchlink.'">'. |
'<p class="LC_error"><a href="'.$switchlink.'">'. |
Line 103 sub handler {
|
Line 102 sub handler {
|
if ($ENV{'REDIRECT_URL'} =~ m{^/adm/([^/]+)}) { |
if ($ENV{'REDIRECT_URL'} =~ m{^/adm/([^/]+)}) { |
my $action = $1; |
my $action = $1; |
my ($option,$filename,$filename1,$filename2,$decompress, |
my ($option,$filename,$filename1,$filename2,$decompress, |
$qualifiedfilename); |
$qualifiedfilename,$warning); |
|
my %deniedactions = &get_denied_action_text(); |
if ($ENV{'REDIRECT_QUERY_STRING'} ne '') { |
if ($ENV{'REDIRECT_QUERY_STRING'} ne '') { |
foreach my $pair (split(/&/,$ENV{'REDIRECT_QUERY_STRING'})) { |
foreach my $pair (split(/&/,$ENV{'REDIRECT_QUERY_STRING'})) { |
my ($name,$value) = split(/=/,$pair); |
my ($name,$value) = split(/=/,$pair); |
Line 122 sub handler {
|
Line 122 sub handler {
|
$option = 'decompress'; |
$option = 'decompress'; |
} elsif ($name eq 'qualifiedfilename') { |
} elsif ($name eq 'qualifiedfilename') { |
$qualifiedfilename = $value; |
$qualifiedfilename = $value; |
} elsif ($name = 'versionone') { |
} elsif ($name eq 'versionone') { |
if ($value eq 'priv') { |
if ($value eq 'priv') { |
$option = 'cstr'; |
$option = 'cstr'; |
} |
} |
Line 131 sub handler {
|
Line 131 sub handler {
|
$option = 'cstr'; |
$option = 'cstr'; |
} |
} |
} elsif ($name eq 'filetwo') { |
} elsif ($name eq 'filetwo') { |
$option = $value; |
$option = $value; |
} |
} |
} |
} |
if (($action eq 'upload') || ($action eq 'testbank')) { |
if (($action eq 'upload') || ($action eq 'testbank')) { |
if (($filename1 ne '') && ($filename ne '')) { |
if (($filename1 ne '') && ($filename2 ne '')) { |
$filename = $filename1.$filename2; |
$filename = $filename1.$filename2; |
} |
} |
} elsif ($action eq 'cfile') { |
} elsif ($action eq 'cfile') { |
Line 145 sub handler {
|
Line 145 sub handler {
|
$filename = $qualifiedfilename; |
$filename = $qualifiedfilename; |
} |
} |
} |
} |
my %deniedactions = &get_denied_action_text(); |
|
my $warning; |
|
if ($option eq 'decompress') { |
if ($option eq 'decompress') { |
$warning = $deniedactions{$option}; |
$warning = $deniedactions{$option}; |
} else { |
} else { |
Line 155 sub handler {
|
Line 153 sub handler {
|
if ($warning) { |
if ($warning) { |
if (($action eq 'diff') && ($option ne 'cstr')) { |
if (($action eq 'diff') && ($option ne 'cstr')) { |
$r->print('<p class="LC_error">'. |
$r->print('<p class="LC_error">'. |
$deniedactions{$action}.'</p><p class="LC_warning">' |
$deniedactions{$action}.'</p><p class="LC_warning">'. |
&mt('You do not have privileges to view the published resource').' '. |
&mt('You do not have privileges to view the published resource').' '. |
'<span class="LC_filename">'.$filename.'</span>'. |
'<span class="LC_filename">'.$filename.'</span>'. |
'</p>'); |
'</p>'); |
Line 174 sub handler {
|
Line 172 sub handler {
|
&mt('You are not permitted to take this action.'). |
&mt('You are not permitted to take this action.'). |
'</p>'); |
'</p>'); |
} |
} |
|
} 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('<p class="LC_error">'. |
|
&mt('There is a problem with the filename').' '. |
|
'<span class="LC_filename">'.$filename.'</span></p>'. |
|
'<p class="LC_warning">'. |
|
&mt('The suggested filename may not include the pattern ".number.extension" as LON-CAPA reserves that pattern for its internal versioning mechanism.'). |
|
'</p>'); |
|
} else { |
|
$r->print('<p class="LC_error">'. |
|
$deniedactions{$action}.'</p><p class="LC_warning">'. |
|
&mt('You do not have authoring privileges for this resource').' '. |
|
'<span class="LC_filename">'.$filename.'</span>'. |
|
'</p>'); |
|
} |
|
} else { |
|
$r->print('<p class="LC_error">'. |
|
&mt('You are not permitted to take this action.'). |
|
'</p>'); |
|
} |
} |
} |
} elsif ($r->uri =~ m{priv/.+\.\d+\.[^.]+$}) { |
} elsif ($r->uri =~ m{priv/.+\.\d+\.[^.]+$}) { |
$r->print('<p class="LC_error">'. |
$r->print('<p class="LC_error">'. |
&mt('There is a problem with the filename').' '. |
&mt('There is a problem with the filename').' '. |
'<span class="LC_filename">'.$r->uri.'</span></p>'. |
'<span class="LC_filename">'.$r->uri.'</span></p>'. |
'<p class="LC_warning">'. |
'<p class="LC_warning">'. |
&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).'). |
'</p>'); |
'</p>'); |
} else { |
} else { |
$r->print('<p class="LC_error">'. |
$r->print('<p class="LC_error">'. |
Line 192 sub handler {
|
Line 217 sub handler {
|
&mt('There is a problem with the filename').' '. |
&mt('There is a problem with the filename').' '. |
'<span class="LC_filename">'.$env{'request.editurl'}.'</span></p>'. |
'<span class="LC_filename">'.$env{'request.editurl'}.'</span></p>'. |
'<p class="LC_warning">'. |
'<p class="LC_warning">'. |
&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).'). |
'</p>'); |
'</p>'); |
} else { |
} else { |
$r->print('<p class="LC_error">' |
$r->print('<p class="LC_error">' |
Line 204 sub handler {
|
Line 229 sub handler {
|
my $realownerhome= |
my $realownerhome= |
&Apache::lonnet::homeserver($realownername,$realownerdom); |
&Apache::lonnet::homeserver($realownername,$realownerdom); |
unless ($realownerhome eq 'no_host') { |
unless ($realownerhome eq 'no_host') { |
my $plainname=&Apache::loncommon::plainname($realownername,$realownerdom); |
if (&Apache::lonnet::is_course($realownerdom,$realownername)) { |
my $user=$realownername.':'.$realownerdom; |
my $ccrole = 'cc'; |
my $userlink=&Apache::loncommon::aboutmewrapper( |
my %crsenv = &Apache::lonnet::coursedescription("$realownerdom/$realownername",{one_time => 1}); |
$plainname.' ('.$user.')' |
my $cdesc = $crsenv{'description'}; |
,$realownername |
my $crstype = $crsenv{'type'}; |
,$realownerdom); |
if ($crstype eq 'Community') { |
$r->print('<p>' |
$ccrole = 'co'; |
.&mt('Contact [_1] for access.',$userlink) |
} |
.'</p>'); |
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', |
|
'<a href="/adm/roles?selectrole=1&'. |
|
&HTML::Entities::encode($ccrole."./$realownerdom/$realownername".'=1','<>&"'). |
|
'&orgurl='.&HTML::Entities::encode($env{'request.editurl'},'<>&"'). |
|
'">','<a/>')); |
|
} else { |
|
if ($crstype eq 'Community') { |
|
$r->print('<p>' |
|
.&mt('Contact a [_1] in the community ([_2]) for access.',$rolename,$cdesc) |
|
.'</p>'); |
|
} else { |
|
$r->print('<p>' |
|
.&mt('Contact a [_1] in the course ([_2]) for access.',$rolename,$cdesc) |
|
.'</p>'); |
|
} |
|
} |
|
} |
|
} else { |
|
my $plainname=&Apache::loncommon::plainname($realownername,$realownerdom); |
|
my $user=$realownername.':'.$realownerdom; |
|
my $userlink=&Apache::loncommon::aboutmewrapper( |
|
$plainname.' ('.$user.')' |
|
,$realownername |
|
,$realownerdom); |
|
$r->print('<p>' |
|
.&mt('Contact [_1] for access.',$userlink) |
|
.'</p>'); |
|
} |
} |
} |
} |
} |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |