--- loncom/interface/selfenroll.pm 2016/08/04 14:17:39 1.27.2.4 +++ loncom/interface/selfenroll.pm 2021/05/04 18:47:36 1.36 @@ -1,7 +1,7 @@ # The LearningOnline Network # Allow users to self-enroll in a course # -# $Id: selfenroll.pm,v 1.27.2.4 2016/08/04 14:17:39 raeburn Exp $ +# $Id: selfenroll.pm,v 1.36 2021/05/04 18:47:36 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -350,8 +350,7 @@ sub enrollment_limit_check { sub page_header { my ($r,$courseid,$js,$desc) = @_; my $start_page = - &Apache::loncommon::start_page('Self-enroll in a LON-CAPA course',$js, - {'no_inline_link' => 1,}); + &Apache::loncommon::start_page('Self-enroll in a LON-CAPA course',$js); $r->print($start_page); &Apache::lonhtmlcommon::clear_breadcrumbs(); &Apache::createaccount::selfenroll_crumbs($r,$courseid,$desc); @@ -439,8 +438,9 @@ sub process_self_enroll { if ($selfenroll_section eq 'none') { $usec = ''; } + my $instcid; if ($selfenroll_registered) { - my ($registered,$instsec,$message) = &check_registered($cdom,$cnum); + my ($registered,$instsec,$instcid,$message) = &check_registered($cdom,$cnum); $usec = $instsec; if (!$registered) { $r->print('

'.&mt('Self-enrollment unavailable').'

'. @@ -455,7 +455,7 @@ sub process_self_enroll { } if ($selfenroll_approval) { my $outcome = - &store_selfenroll_request($udom,$uname,$usec,$cdom,$cnum, + &store_selfenroll_request($r,$udom,$uname,$usec,$cdom,$cnum, $selfenroll_notifylist,$owner, $selfenroll_approval,$crstype,$lonhost,$handle); $r->print($outcome); @@ -463,7 +463,7 @@ sub process_self_enroll { my $enrollresult = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef, undef,undef,$usec,$selfenroll_access_end,$selfenroll_access_start, - 'selfenroll',undef,$cdom.'_'.$cnum,$selfenroll); + 'selfenroll',undef,$cdom.'_'.$cnum,$selfenroll,'selfenroll','',$instcid); if ($enrollresult eq 'ok') { my (%userroles,%newrole,%newgroups); my $role = 'st'; @@ -535,7 +535,7 @@ sub user_can_selfenroll { } sub store_selfenroll_request { - my ($udom,$uname,$usec,$cdom,$cnum,$selfenroll_notifylist,$owner, + my ($r,$udom,$uname,$usec,$cdom,$cnum,$selfenroll_notifylist,$owner, $selfenroll_approval,$crstype,$lonhost,$handle) = @_; my $namespace = 'selfenrollrequests'; my $output; @@ -551,7 +551,7 @@ sub store_selfenroll_request { } if ($status eq 'pending') { my $token = $info{$cdom.'_'.$cnum}{'token'}; - my ($statusupdate,$pendingform) = &pending_selfenrollment_form($cdom,$cnum,$crstype,$token,$lonhost); + my ($statusupdate,$pendingform) = &pending_selfenrollment_form($r,$cdom,$cnum,$crstype,$token,$lonhost); if ($statusupdate eq 'pending') { $output .= $pendingform; } @@ -589,7 +589,7 @@ sub store_selfenroll_request { } $output = &mt('Your request for self-enrollment has been recorded.').'
'; if ($status eq 'pending') { - my ($statusupdate,$pendingform) = &pending_selfenrollment_form($cdom,$cnum,$crstype,$token,$lonhost); + my ($statusupdate,$pendingform) = &pending_selfenrollment_form($r,$cdom,$cnum,$crstype,$token,$lonhost); if ($statusupdate eq 'request') { $status = $statusupdate; } else { @@ -630,7 +630,7 @@ sub store_selfenroll_request { } sub pending_selfenrollment_form { - my ($cdom,$cnum,$crstype,$token,$lonhost) = @_; + my ($r,$cdom,$cnum,$crstype,$token,$lonhost) = @_; my ($status,$output); my $coursetype = &Apache::lonuserutils::get_extended_type($cdom,$cnum,$crstype); my %postvalues = ( @@ -664,9 +664,12 @@ sub pending_selfenrollment_form { if ($buttontext eq '') { $buttontext = &mt('Complete my enrollment'); } + my $hostname = &Apache::lonnet::hostname($lonhost); my $protocol = $Apache::lonnet::protocol{$lonhost}; $protocol = 'http' if ($protocol ne 'https'); - my $enroller = $protocol.'://'.&Apache::lonnet::hostname($lonhost).'/cgi-bin/enrollqueued.pl'; + my $alias = &Apache::lonnet::use_proxy_alias($r,$lonhost); + $hostname = $alias if ($alias ne ''); + my $enroller = $protocol.'://'.$hostname.'/cgi-bin/enrollqueued.pl'; $output .= ''."\n". ''."\n". ''."\n". @@ -786,7 +789,7 @@ sub print_selfenroll_types { sub check_registered { my ($cdom,$cnum) = @_; - my ($registered,$instsec,$message); + my ($registered,$instsec,$instcid,$message); my %settings = &Apache::lonnet::get('environment',['internal.coursecode', 'internal.sectionnums', 'internal.crosslistings'],$cdom,$cnum); @@ -806,6 +809,7 @@ sub check_registered { if (defined($enrolled{$env{'user.name'}})) { $registered = 1; $instsec = $LC_code{$class}; + $instcid = $class; last; } } @@ -818,7 +822,7 @@ sub check_registered { } else { $message = &mt('As no institutional course sections are currently associated with this course, your registration status is undetermined.'); } - return ($registered,$instsec,$message); + return ($registered,$instsec,$instcid,$message); } 1;