--- loncom/interface/selfenroll.pm 2008/05/14 20:06:51 1.3 +++ loncom/interface/selfenroll.pm 2008/07/10 00:19:56 1.8 @@ -1,7 +1,7 @@ # The LearningOnline Network # Allow users to self-enroll in a course # -# $Id: selfenroll.pm,v 1.3 2008/05/14 20:06:51 raeburn Exp $ +# $Id: selfenroll.pm,v 1.8 2008/07/10 00:19:56 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -92,9 +92,6 @@ sub handler { foreach my $key (keys(%env)) { if ($key =~ m-^user\.role\.st\./$cdom/$cnum/?(\w*)$-) { my $sec = $1; - if ($sec eq '') { - $sec = &mt('none'); - } my ($start,$end) = split(/\./,$env{$key}); my $status = 'active'; if (($end) && ($end<=$now)) { @@ -106,6 +103,9 @@ sub handler { if ($status eq 'active' || $status eq 'future') { $curr_role{'status'} = $status; $curr_role{'section'} = $sec; + if ($curr_role{'section'} eq '') { + $curr_role{'section'} = &mt('none'); + } $curr_role{'start'} = &Apache::lonlocal::locallocaltime($start); $curr_role{'role'} = 'st./'.$cdom.'/'.$cnum; if ($sec ne '') { @@ -171,7 +171,7 @@ END $r->print('
  • '.&mt('Otherwise:').'
    '); my $count = 0; foreach my $type ('sso','login','email') { - if ($count> 0) { + if (($count > 0) && ($count <@cancreate)) { $r->print(' , '.&mt('or').'
    '); } if (grep(/^$type$/,@cancreate)) { @@ -280,9 +280,12 @@ sub process_self_enroll { my %userhash = &Apache::lonnet::userenvironment($udom,$uname,@info); my ($enrolltypes,$longtypes,$alldoms) = &get_selfenroll_filters($selfenroll_types,$udom); - my @inststatuses = &unescape(split(/:/,$userhash{'inststatus'})); - if (@inststatuses == 0) { - push(@inststatuses,'other'); + my @inststatuses; + if ($userhash{'inststatus'} eq '') { + push(@inststatuses,'other'); + } else { + my @esc_statuses = split(/:/,$userhash{'inststatus'}); + @inststatuses = map { &unescape($_); } (@esc_statuses); } my $selfenroll = 0; if ($alldoms) { @@ -310,7 +313,7 @@ sub process_self_enroll { my ($registered,$instsec,$message) = &check_registered($cdom,$cnum); $usec = $instsec; if (!$registered) { - $r->print(&mt('Self-enrollment is restricted to officially registered students.').'
    '); + $r->print(&mt('Self-enrollment is restricted to students officially registered for this course.').'
    '); if ($message) { $r->print($message); } else { @@ -321,7 +324,8 @@ 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, 'manual',undef,$cdom.'_'.$cnum,$selfenroll); + undef,undef,$usec,$selfenroll_access_end,$selfenroll_access_start, + 'manual',undef,$cdom.'_'.$cnum,$selfenroll); if ($enrollresult eq 'ok') { my (%userroles,%newrole,%newgroups); my $role = 'st'; @@ -335,7 +339,7 @@ sub process_self_enroll { $area); &Apache::lonnet::set_userprivs(\%userroles,\%newrole,%newgroups); $userroles{'user.role.'.$spec} = $selfenroll_access_start.'.'.$selfenroll_access_end; - &Apache::lonnet::appenv(\%userroles,[$role]); + &Apache::lonnet::appenv(\%userroles,[$role,'cm']); if ($selfenroll_access_end && $selfenroll_access_end <= $now) { $r->print(&mt('The end date for access to this course for users who self-enroll has passed.').'
    '.&mt('Consequently, although a new role was created for you in the course, it is an inactive role which does not provide access to the course.')); } else { @@ -431,7 +435,7 @@ sub print_selfenroll_types { } } } else { - $output = &mt('Self-enrollment in this course is only available to users in the following domains (with the following status): ').'