[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm
raeburn
raeburn@source.lon-capa.org
Sat, 05 Sep 2009 20:44:01 -0000
raeburn Sat Sep 5 20:44:01 2009 EDT
Modified files:
/loncom/lonnet/perl lonnet.pm
Log:
Course Requests
- If course request is being processed immediately allow course owner to
add standard course roles and custom roles (defined by owner).
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1025 loncom/lonnet/perl/lonnet.pm:1.1026
--- loncom/lonnet/perl/lonnet.pm:1.1025 Thu Sep 3 21:23:36 2009
+++ loncom/lonnet/perl/lonnet.pm Sat Sep 5 20:44:01 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.1025 2009/09/03 21:23:36 raeburn Exp $
+# $Id: lonnet.pm,v 1.1026 2009/09/05 20:44:01 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -6058,10 +6058,27 @@
my $cwosec=$url;
$cwosec=~s/^\/($match_domain)\/($match_courseid)\/.*/$1\/$2/;
unless (&allowed('ccr',$cwosec)) {
- &logthis('Refused custom assignrole: '.
- $udom.' '.$uname.' '.$url.' '.$role.' '.$end.' '.$start.' by '.
- $env{'user.name'}.' at '.$env{'user.domain'});
- return 'refused';
+ my $refused = 1;
+ if ($context eq 'requestcourses') {
+ if (($env{'user.name'} ne '') && ($env{'user.domain'} ne '')) {
+ if ($role =~ m{^cr/($match_domain)/($match_username)/([^/]+)$}) {
+ if (($1 eq $env{'user.domain'}) && ($2 eq $env{'user.name'})) {
+ my ($cdom,$cnum) = ($cwosec =~ m{^/?($match_domain)/($match_courseid)$});
+ my %crsenv = &userenvironment($cdom,$cnum,('internal.courseowner'));
+ if ($crsenv{'internal.courseowner'} eq
+ $env{'user.name'}.':'.$env{'user.domain'}) {
+ $refused = '';
+ }
+ }
+ }
+ }
+ }
+ if ($refused) {
+ &logthis('Refused custom assignrole: '.
+ $udom.' '.$uname.' '.$url.' '.$role.' '.$end.' '.$start.
+ ' by '.$env{'user.name'}.' at '.$env{'user.domain'});
+ return 'refused';
+ }
}
$mrole='cr';
} elsif ($role =~ /^gr\//) {
@@ -6090,8 +6107,9 @@
if (($selfenroll == 1) && ($role eq 'st') && ($udom eq $env{'user.domain'}) && ($uname eq $env{'user.name'})) {
$refused = '';
} elsif ($context eq 'requestcourses') {
- if (($role eq 'cc') && ($env{'user.name'} ne '' && $env{'user.domain'} ne '')) {
- my ($cdom,$cnum) = ($cwosec =~ m{^/($match_domain)/($match_courseid)$});
+ my @possroles = ('st','ta','ep','in','cc');
+ if ((grep(/^\Q$role\E$/,@possroles)) && ($env{'user.name'} ne '' && $env{'user.domain'} ne '')) {
+ my ($cdom,$cnum) = ($cwosec =~ m{^/?($match_domain)/($match_courseid)$});
my %crsenv = &userenvironment($cdom,$cnum,('internal.courseowner'));
if ($crsenv{'internal.courseowner'} eq
$env{'user.name'}.':'.$env{'user.domain'}) {