--- loncom/auth/lonroles.pm 2013/06/04 22:20:31 1.288
+++ loncom/auth/lonroles.pm 2014/05/04 21:49:05 1.302
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.288 2013/06/04 22:20:31 raeburn Exp $
+# $Id: lonroles.pm,v 1.302 2014/05/04 21:49:05 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -288,7 +288,7 @@ sub handler {
"request.role.domain" => $env{'user.domain'}});
# Check if user is a DC trying to enter a course or author space and needs privs to be created
if ($numdc > 0) {
- foreach my $envkey (keys %env) {
+ foreach my $envkey (keys(%env)) {
# Is this an ad-hoc Coordinator role?
if (my ($ccrole,$domain,$coursenum) =
($envkey =~ m-^form\.(cc|co)\./($match_domain)/($match_courseid)$-)) {
@@ -358,7 +358,7 @@ sub handler {
}
}
- foreach $envkey (keys %env) {
+ foreach $envkey (keys(%env)) {
next if ($envkey!~/^user\.role\./);
my ($where,$trolecode,$role,$tstatus,$tend,$tstart);
&Apache::lonnet::role_status($envkey,$update,$refresh,$now,\$role,\$where,
@@ -532,6 +532,7 @@ ENDENTERKEY
my ($feeds,$syllabus_time);
&Apache::lonrss::advertisefeeds($cnum,$cdom,undef,\$feeds);
&Apache::lonnet::appenv({'request.course.feeds' => $feeds});
+ &Apache::lonnet::get_numsuppfiles($cnum,$cdom,1);
unless ($env{'course.'.$cdom.'_'.$cnum.'.updatedsyllabus'}) {
unless (($env{'course.'.$cdom.'_'.$cnum.'.externalsyllabus'}) ||
($env{'course.'.$cdom.'_'.$cnum.'.uploadedsyllabus'})) {
@@ -544,13 +545,14 @@ ENDENTERKEY
}
}
if (($env{'form.orgurl'}) &&
- ($env{'form.orgurl'}!~/^\/adm\/flip/)) {
+ ($env{'form.orgurl'}!~/^\/adm\/flip/) &&
+ ($env{'form.orgurl'} ne '/adm/roles')) {
my $dest=$env{'form.orgurl'};
if ($env{'form.symb'}) {
if ($dest =~ /\?/) {
$dest .= '&';
} else {
- $dest .= '?'
+ $dest .= '?';
}
$dest .= 'symb='.$env{'form.symb'};
}
@@ -589,13 +591,8 @@ ENDENTERKEY
} else {
# Check to see if the user is a CC entering a course
# for the first time
- my (undef, undef, $role, $courseid) = split(/\./, $envkey);
- if (substr($courseid, 0, 1) eq '/') {
- $courseid = substr($courseid, 1);
- }
- $courseid =~ s/\//_/;
if ((($role eq 'cc') || ($role eq 'co'))
- && ($env{'course.' . $courseid .'.course.helper.not.run'})) {
+ && ($env{'course.'.$cdom.'_'.$cnum.'.course.helper.not.run'})) {
$furl = "/adm/helper/course.initialization.helper";
# Send the user to the course they selected
} elsif ($env{'request.course.id'}) {
@@ -647,7 +644,7 @@ ENDENTERKEY
}
}
&redirect_user($r, &mt('Entering [_1]',
- $env{'course.'.$courseid.'.description'}),
+ $env{'course.'.$cdom.'_'.$cnum.'.description'}),
$dest, $msg);
return OK;
}
@@ -657,25 +654,36 @@ ENDENTERKEY
$env{'request.course.id'}.'/'
.$env{'request.course.sec'})
) {
- my $startpage = &courseloadpage($courseid);
+ my $startpage = &courseloadpage($env{'request.course.id'});
unless ($startpage eq 'firstres') {
$msg = &mt('Entering [_1] ...',
- $env{'course.'.$courseid.'.description'});
+ $env{'course.'.$env{'request.course.id'}.'.description'});
&redirect_user($r, &mt('New in course'),
'/adm/whatsnew?refpage=start', $msg);
return OK;
}
}
}
-# Are we allowed to look at the first resource?
- if ($furl !~ m|^/adm/|) {
-# Guess not ...
- $furl=&Apache::lonpageflip::first_accessible_resource();
- }
+ # Are we allowed to look at the first resource?
+ if ($furl =~ m{^(/adm/wrapper|)/ext/}) {
+ # If it's an external resource,
+ # strip off the symb argument and possible query
+ my ($exturl,$symb) = ($furl =~ m{^(.+)(?:\?|\&)symb=(.+)$});
+ # Unencode $symb
+ $symb = &unescape($symb);
+ # Then check for permission
+ if (!&Apache::lonnet::allowed('bre',$exturl,$symb)) {
+ $furl = &Apache::lonpageflip::first_accessible_resource();
+ }
+ # For other resources just check for permission
+ } elsif (!&Apache::lonnet::allowed('bre',$furl)) {
+ $furl = &Apache::lonpageflip::first_accessible_resource();
+ }
+
$msg = &mt('Entering [_1] ...',
- $env{'course.'.$courseid.'.description'});
+ $env{'course.'.$cdom.'_'.$cnum.'.description'});
&redirect_user($r, &mt('Entering [_1]',
- $env{'course.'.$courseid.'.description'}),
+ $env{'course.'.$cdom.'_'.$cnum.'.description'}),
$furl, $msg);
}
return OK;
@@ -738,7 +746,12 @@ ENDENTERKEY
my $swinfo=&Apache::lonmenu::rawconfig();
my $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum});
- my $funcs = &get_roles_functions($showcount);
+ my %domdefs=&Apache::lonnet::get_domain_defaults($env{'user.domain'});
+ my $cattype = 'std';
+ if ($domdefs{'catauth'}) {
+ $cattype = $domdefs{'catauth'};
+ }
+ my $funcs = &get_roles_functions($showcount,$cattype);
$standby=~s/\n/\\n/g;
my $noscript='
'.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').'
'.&mt('As this is not the case, most functionality in the system will be unavailable.').'
';
@@ -881,17 +894,19 @@ ENDHEADER
\%sortrole,\%roleclass,\%futureroles,\%timezones,$loncaparev);
$refresh = $now;
&Apache::lonnet::appenv({'user.refresh.time' => $refresh});
- unless ($env{'user.adv'}) {
+ if ((($cattype eq 'std') || ($cattype eq 'domonly')) && (!$env{'user.adv'})) {
if ($countactive > 0) {
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
$r->print(
'
'
- .&mt('[_1]Visit the [_2]Course/Community Catalog[_3]'
- .' to view all [_4] LON-CAPA courses and communities.'
+ .&mt('[_1]Visit the [_2]Course/Community Catalog[_3][_4]'
+ .' to view all [_5] LON-CAPA courses and communities.'
,''
,''
- ,'',$domdesc)
+ ,''
+ ,''
+ ,'"'.$domdesc.'"')
.'
'
.&mt('If a course or community is [_1]not[_2] in your list of current courses and communities below,'
.' you may be able to enroll if self-enrollment is permitted.'
@@ -908,8 +923,7 @@ ENDHEADER
} else {
$r->print('
'.&mt('The [_1]Course/Community Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created, as well as any communities in the domain.','','',$domdesc).'
');
- $r->print(&mt('You can search for courses and communities which permit self-enrollment, if you would like to enroll in one.').'
'.&mt('The [_1]Course/Community Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created, as well as any communities in the domain.','','',$domdesc).'
');
+ $r->print(&mt('You can search for courses and communities which permit self-enrollment, if you would like to enroll in one.').'
'.&mt('Author role request').'
';
if ($status eq 'approval') {
- $output .= &mt('A request for authoring space submitted on [_1] is awaiting approval',
+ $output .= &mt('A request for Authoring Space submitted on [_1] is awaiting approval',
&Apache::lonlocal::locallocaltime($timestamp));
} elsif ($status eq 'approved') {
my %roleshash =