[LON-CAPA-cvs] cvs: loncom /interface selfenroll.pm

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Thu, 17 Jul 2008 20:08:17 -0000


raeburn		Thu Jul 17 16:08:17 2008 EDT

  Modified files:              
    /loncom/interface	selfenroll.pm 
  Log:
  - lonnet::userenvironment() takes items to be retrieved (last arg) as an array, not a ref to an array.
  - institutional status types allowed to self-enroll stored in an escape form, need to unescape before 
     creating string to display which types are permitted to self-enroll. 
  
  
Index: loncom/interface/selfenroll.pm
diff -u loncom/interface/selfenroll.pm:1.12 loncom/interface/selfenroll.pm:1.13
--- loncom/interface/selfenroll.pm:1.12	Thu Jul 17 08:22:28 2008
+++ loncom/interface/selfenroll.pm	Thu Jul 17 16:08:17 2008
@@ -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 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 @@
         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 @@
                     }
                     $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;
                 }
             }
         }