--- loncom/interface/lonrequestcourse.pm 2009/08/19 20:12:04 1.18 +++ loncom/interface/lonrequestcourse.pm 2009/08/20 21:15:37 1.19 @@ -1,7 +1,7 @@ # The LearningOnline Network # Request a course # -# $Id: lonrequestcourse.pm,v 1.18 2009/08/19 20:12:04 raeburn Exp $ +# $Id: lonrequestcourse.pm,v 1.19 2009/08/20 21:15:37 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -429,6 +429,8 @@ sub check_can_request { my ($dom,$can_request) = @_; my $canreq = 0; my ($types,$typename) = &course_types(); + my @options = ('approval','validate','autolimit'); + my $optregex = join('|',@options); if ((ref($can_request) eq 'HASH') && (ref($types) eq 'ARRAY')) { foreach my $type (@{$types}) { if (&Apache::lonnet::usertools_access($env{'user.name'}, @@ -444,7 +446,7 @@ sub check_can_request { if (@curr > 0) { $canreq ++; unless ($dom eq $env{'user.domain'}) { - if (grep(/^\Q$dom\E$/,@curr)) { + if (grep(/^\Q$dom\E:($optregex)(=?\d*)$/,@curr)) { $can_request->{$type} = 1; } } @@ -1749,17 +1751,47 @@ sub coursecode_form { sub get_course_dom { my $codedom = &Apache::lonnet::default_login_domain(); + if ($env{'form.showdom'} ne '') { + if (&Apache::lonnet::domain($env{'form.showdom'}) ne '') { + return $env{'form.showdom'}; + } + } if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne 'public')) { + my ($types,$typename) = &course_types(); + if (ref($types) eq 'ARRAY') { + foreach my $type (@{$types}) { + if (&Apache::lonnet::usertools_access($env{'user.name'}, + $env{'user.domain'},$type, + undef,'requestcourses')) { + return $env{'user.domain'}; + } + } + my @possible_doms; + foreach my $type (@{$types}) { + my $dom_str = $env{'environment.reqcrsotherdom.'.$type}; + if ($dom_str ne '') { + my @domains = split(',',$dom_str); + foreach my $entry (@domains) { + my ($extdom,$extopt) = split(':',$entry); + if ($extdom eq $env{'request.role.domain'}) { + return $extdom; + } + unless(grep(/^\Q$extdom\E$/,@possible_doms)) { + push(@possible_doms,$extdom); + } + } + } + } + if (@possible_doms) { + @possible_doms = sort(@possible_doms); + return $possible_doms[0]; + } + } $codedom = $env{'user.domain'}; if ($env{'request.role.domain'} ne '') { $codedom = $env{'request.role.domain'}; } } - if ($env{'form.showdom'} ne '') { - if (&Apache::lonnet::domain($env{'form.showdom'}) ne '') { - $codedom = $env{'form.showdom'}; - } - } return $codedom; } @@ -1962,9 +1994,9 @@ sub print_request_outcome { my $val = &get_processtype($dom,$crstype,\@inststatuses,\%domconfig); if ($val eq '') { if ($crstype eq 'official') { - $output = &mt('You are not permitted to request creation of official courses'); + $output = &mt('You are not permitted to request creation of official courses.'); } elsif ($crstype eq 'unofficial') { - $output = &mt('You are not permitted to request creation of unofficial courses'); + $output = &mt('You are not permitted to request creation of unofficial courses.'); } elsif ($crstype eq 'community') { $output = &mt('You are not permitted to request creation of communities'); } else { @@ -2114,7 +2146,7 @@ sub print_request_outcome { ¬ification_information($disposition,$req_notifylist,$cnum,$now); } if ($validationerror ne '') { - $output .= ''.&mt('An error occurred validating your request with institutional data sources: {_1].',$validationerror).'

'; + $output .= ''.&mt('An error occurred validating your request with institutional data sources: [_1].',$validationerror).'

'; } } return $output; @@ -2161,7 +2193,7 @@ sub get_processtype { my ($dom,$crstype,$inststatuses,$domconfig) = @_; return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH')); my (%userenv,%settings,$val); - my @options = ('autolimit','validate','approve'); + my @options = ('autolimit','validate','approval'); if ($dom eq $env{'user.domain'}) { %userenv = &Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'}, @@ -2227,11 +2259,17 @@ sub get_processtype { } else { %userenv = &Apache::lonnet::userenvironment($env{'user.domain'}, $env{'user.name'},'reqcrsotherdom.'.$env{'form.crstype'}); - if ($userenv{'reqcrsotherdom'}) { - my @doms = split(',',$userenv{'reqcrsotherdom'}); - my $optregex = join('|',@options); - if (grep(/^\Q$dom\E:($optregex=?\d*)/,@doms)) { - $val = $1; + if ($userenv{'reqcrsotherdom.'.$crstype}) { + my @doms = split(',',$userenv{'reqcrsotherdom.'.$crstype}); + my $optregex = join('|',@options); + foreach my $item (@doms) { + my ($extdom,$extopt) = split(':',$item); + if ($extdom eq $dom) { + if ($extopt =~ /^($optregex)(=?\d*)$/) { + $val = $1.$2; + } + last; + } } @{$inststatuses} = ('_external_'); }