--- loncom/interface/selfenroll.pm 2008/07/17 12:22:28 1.12 +++ loncom/interface/selfenroll.pm 2008/07/17 20:08:17 1.13 @@ -1,7 +1,7 @@ # The LearningOnline Network # Allow users to self-enroll in a course # -# $Id: selfenroll.pm,v 1.12 2008/07/17 12:22:28 raeburn Exp $ +# $Id: selfenroll.pm,v 1.13 2008/07/17 20:08:17 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -453,14 +453,12 @@ sub process_self_enroll { sub user_can_selfenroll { my ($udom,$uname,$domenrolltypes) = @_; my $selfenroll = 0; - my @info = ['inststatus']; - my %userhash = &Apache::lonnet::userenvironment($udom,$uname,@info); + my %userhash = &Apache::lonnet::userenvironment($udom,$uname,'inststatus'); my @inststatuses; if ($userhash{'inststatus'} eq '') { push(@inststatuses,'other'); } else { - my @esc_statuses = split(/:/,$userhash{'inststatus'}); - @inststatuses = map { &unescape($_); } (@esc_statuses); + @inststatuses = split(':',$userhash{'inststatus'}); } foreach my $type (@inststatuses) { if (ref($domenrolltypes) eq 'ARRAY') { @@ -508,12 +506,13 @@ sub get_selfenroll_filters { if ($selfdom =~ /^$match_domain$/) { if (&Apache::lonnet::domain($selfdom) ne '') { my @types = split(/,/,$type_str); + my @unesc_types = map { &unescape($_); } @types; my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($selfdom); if (ref($usertypes) eq 'HASH') { my $anytype = 1; foreach my $key (keys(%{$usertypes})) { - if (!grep(/^\Q$key\E$/,@types)) { + if (!grep(/^\Q$key\E$/,@unesc_types)) { $anytype = 0; last; } @@ -525,13 +524,16 @@ sub get_selfenroll_filters { } $usertypes->{'any'} = &mt('Any users'); $usertypes->{'other'} = &mt('Others'); + my @showtypes; if ($anytype) { @{$enrolltypes{$selfdom}} = ('any'); + @showtypes = ('any'); } else { @{$enrolltypes{$selfdom}} = @types; + @showtypes = @unesc_types; } @{$longtypes{$selfdom}} = - map {$usertypes->{$_}} @{$enrolltypes{$selfdom}} + map {$usertypes->{$_}} @showtypes; } } }