--- loncom/lonnet/perl/lonnet.pm 2009/09/13 03:13:38 1.1027 +++ loncom/lonnet/perl/lonnet.pm 2009/09/16 05:59:49 1.1028 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.1027 2009/09/13 03:13:38 raeburn Exp $ +# $Id: lonnet.pm,v 1.1028 2009/09/16 05:59:49 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -6445,14 +6445,39 @@ sub createcourse { $course_owner,$crstype,$cnum,$context,$category)=@_; $url=&declutter($url); my $cid=''; - unless (&allowed('ccc',$udom)) { - if ($context eq 'requestcourses') { - unless (&usertools_access($course_owner,$udom,$category,undef,$context)) { - return 'refused'; + if ($context eq 'requestcourses') { + my $can_create = 0; + my ($ownername,$ownerdom) = split(':',$course_owner); + if ($udom eq $ownerdom) { + if (&usertools_access($ownername,$ownerdom,$category,undef, + $context)) { + $can_create = 1; + } + } else { + my %userenv = &userenvironment($ownerdom,$ownername,'reqcrsotherdom.'. + $category); + if ($userenv{'reqcrsotherdom.'.$category} ne '') { + my @curr = split(',',$userenv{'reqcrsotherdom.'.$category}); + if (@curr > 0) { + my @options = qw(approval validate autolimit); + my $optregex = join('|',@options); + if (grep(/^\Q$udom\E:($optregex)(=?\d*)$/,@curr)) { + $can_create = 1; + } + } + } + } + if ($can_create) { + unless ($ownername eq $env{'user.name'} && $ownerdom eq $env{'user.domain'}) { + unless (&allowed('ccc',$udom)) { + return 'refused'; + } } } else { return 'refused'; } + } elsif (!&allowed('ccc',$udom)) { + return 'refused'; } # --------------------------------------------------------------- Get Unique ID my $uname;