--- loncom/auth/lonroles.pm 2013/08/12 20:51:29 1.269.2.12
+++ loncom/auth/lonroles.pm 2014/02/24 02:24:16 1.269.2.16
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.269.2.12 2013/08/12 20:51:29 raeburn Exp $
+# $Id: lonroles.pm,v 1.269.2.16 2014/02/24 02:24:16 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -294,7 +294,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)$-)) {
@@ -364,7 +364,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,
@@ -551,13 +551,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'};
}
@@ -596,13 +597,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'}) {
@@ -654,7 +650,7 @@ ENDENTERKEY
}
}
&redirect_user($r, &mt('Entering [_1]',
- $env{'course.'.$courseid.'.description'}),
+ $env{'course.'.$env{'request.course.id'}.'.description'}),
$dest, $msg);
return OK;
}
@@ -664,10 +660,10 @@ 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;
@@ -680,9 +676,9 @@ ENDENTERKEY
$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;
@@ -746,7 +742,6 @@ 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 $standby=&mt('Role selected. Please stand by.');
$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.').'
';
@@ -895,11 +890,13 @@ ENDHEADER
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.'
@@ -1608,24 +1605,6 @@ sub build_roletext {
return ($roletext,$roletext_end);
}
-sub check_needs_switchserver {
- my ($possiblerole) = @_;
- my $needs_switchserver;
- my ($role,$where) = split(/\./,$possiblerole,2);
- my (undef,$tdom,$twho) = split(/\//,$where);
- my ($server_status,$home);
- if (($role eq 'ca') || ($role eq 'aa')) {
- ($server_status,$home) = &check_author_homeserver($twho,$tdom);
- } else {
- ($server_status,$home) = &check_author_homeserver($env{'user.name'},
- $env{'user.domain'});
- }
- if ($server_status eq 'switchserver') {
- $needs_switchserver = 1;
- }
- return $needs_switchserver;
-}
-
sub check_author_homeserver {
my ($uname,$udom)=@_;
if (($uname eq '') || ($udom eq '')) {
@@ -1691,7 +1670,7 @@ sub adhoc_course_role {
}
}
if ($setprivs) {
- if ($env{'form.switchrole'} =~ m-^(in|ta|ep|ad|st|cr)([\w/]*)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
+ if ($env{'form.switchrole'} =~ m-^(in|ta|ep|ad|st|cr)(.*?)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
my $role = $1;
my $custom_role = $2;
my $usec = $3;
@@ -2237,7 +2216,8 @@ sub update_session_roles {
my $status_in_env =
&curr_role_status($currstart,$currend,$refresh,$update);
my ($rolekey) = ($envkey =~ /^user\.role\.(.+)$/);
- my ($role,$rest)=split(/\./,$rolekey,2);
+ my ($role,$rest)=split(m{\./},$rolekey,2);
+ $rest = '/'.$rest;
if (&Apache::lonnet::delenv($envkey,undef,[$role])) {
if ($status_in_env eq 'active') {
if ($role eq 'gr') {
@@ -2746,7 +2726,7 @@ sub get_roles_functions {
}
}
if (&Apache::loncommon::designparm('login.coursecatalog',$env{'user.domain'})) {
- push(@links,['/adm/coursecatalog','ccat-22x22',&mt('Course Catalog')]);
+ push(@links,['/adm/coursecatalog','ccat-22x22',&mt('Course catalog')]);
}
my $funcs = &Apache::lonhtmlcommon::start_funclist();
foreach my $link (@links) {
@@ -2766,7 +2746,7 @@ sub get_queued {
$env{'user.name'},'^status:');
foreach my $key (keys(%statusinfo)) {
next unless (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending'));
- (undef,my($cdom,$cnum)) = split(':',$key);
+ (undef,my($cdom,$cnum)) = split(/:/,$key);
my $requestkey = $cdom.'_'.$cnum;
if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {
my %history = &Apache::lonnet::restore($requestkey,'courserequests',