[LON-CAPA-cvs] cvs: loncom /enrollment Autoupdate.pl /interface loncommon.pm loncreateuser.pm lonuserutils.pm /lonnet/perl lonnet.pm

raeburn raeburn@source.lon-capa.org
Mon, 09 Mar 2009 05:25:50 -0000


This is a MIME encoded message

--raeburn1236576350
Content-Type: text/plain

raeburn		Mon Mar  9 05:25:50 2009 EDT

  Modified files:              
    /loncom/interface	lonuserutils.pm loncreateuser.pm loncommon.pm 
    /loncom/lonnet/perl	lonnet.pm 
    /loncom/enrollment	Autoupdate.pl 
  Log:
  Setting Institutional Affiliation(s).
  - institutional affiliation saved as inststatus in user's environment.db is a colon-separated list of escaped affiliations.
  
  - Domain Coordinators in user's domain (have mau priv.) can modify institutional status of a user via "Modify User" or "Upload List of Users".
  
  
--raeburn1236576350
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20090309052550.txt"

Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.83 loncom/interface/lonuserutils.pm:1.84
--- loncom/interface/lonuserutils.pm:1.83	Thu Mar  5 23:58:00 2009
+++ loncom/interface/lonuserutils.pm	Mon Mar  9 05:25:40 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Utility functions for managing LON-CAPA user accounts
 #
-# $Id: lonuserutils.pm,v 1.83 2009/03/05 23:58:00 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.84 2009/03/09 05:25:40 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -86,7 +86,7 @@
 sub modifyuserrole {
     my ($context,$setting,$changeauth,$cid,$udom,$uname,$uid,$umode,$upass,
         $first,$middle,$last,$gene,$sec,$forceid,$desiredhome,$email,$role,
-        $end,$start,$checkid) = @_;
+        $end,$start,$checkid,$inststatus) = @_;
     my ($scope,$userresult,$authresult,$roleresult,$idresult);
     if ($setting eq 'course' || $context eq 'course') {
         $scope = '/'.$cid;
@@ -124,7 +124,7 @@
     $userresult =
         &Apache::lonnet::modifyuser($udom,$uname,$uid,$umode,$upass,$first,
                                     $middle,$last,$gene,$forceid,$desiredhome,
-                                    $email,$role,$start,$end);
+                                    $email,$inststatus);
     if ($userresult eq 'ok') {
         if ($role ne '') {
             $role =~ s/_/\//g;
@@ -408,10 +408,13 @@
          domain   => 'The optional domain field was not specified.',
          continue => 'Continue adding users?',
          );
+    if (($mode eq 'upload') && ($context eq 'domain')) {
+        $alert{'inststatus'} = &mt('The optional affiliation field was not specified'); 
+    }
     my $function_name = <<"END";
 $setsections_js
 
-function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail,foundrole,founddomain) {
+function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail,foundrole,founddomain,foundinststatus) {
 END
     my ($authnum,%can_assign) =  &Apache::loncommon::get_assignable_auth($domain);
     my $auth_checks;
@@ -538,6 +541,20 @@
         }
         message+='$alert{'domain'}';
     }
+END
+        if (($mode eq 'upload') && ($context eq 'domain')) {
+            $optional_checks .= (<<END);
+
+    if (foundinststatus==0) {
+        if (message!='') {
+            message+='\\n';
+        }
+        message+='$alert{'inststatus'}';
+    }
+END
+        }
+        $optional_checks .= (<<END);
+
     if (message!='') {
         message+= '\\n$alert{'continue'}';
         if (confirm(message)) {
@@ -568,6 +585,7 @@
     var foundemail=0;
     var foundrole=0;
     var founddomain=0;
+    var foundinststatus=0;
     var tw;
     for (i=0;i<=vf.nfields.value;i++) {
         tw=eval('vf.f'+i+'.selectedIndex');
@@ -579,8 +597,9 @@
         if (tw==10) { foundemail=1; }
         if (tw==11) { foundrole=1; }
         if (tw==12) { founddomain=1; }
+        if (tw==13) { foundinststatus=1; }
     }
-    verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail,foundrole,founddomain);
+    verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail,foundrole,founddomain,foundinststatus);
 }
 
 //
@@ -602,6 +621,7 @@
 // 10 = email address
 // 11 = role
 // 12 = domain
+// 13 = inststatus
 
 function flip(vf,tf) {
    var nw=eval('vf.f'+tf+'.selectedIndex');
@@ -666,6 +686,7 @@
     var foundsec=0;
     var foundrole=0;
     var founddomain=0;
+    var foundinststatus=0;
     var tw;
     for (i=0;i<=vf.nfields.value;i++) {
         tw=eval('vf.f'+i+'.selectedIndex');
@@ -676,8 +697,9 @@
         if (i==8 && tw!=0) { foundpwd=1; }
         if (i==9 && tw!=0) { foundrole=1; }
         if (i==10 && tw!=0) { founddomain=1; }
+        if (i==13 && tw!=0) { foundinstatus=1; }
     }
-    verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec,foundrole,founddomain);
+    verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec,foundrole,founddomain,foundinststatus);
 }
 
 function flip(vf,tf) {
@@ -864,6 +886,7 @@
                                'email_choice' => 'scalar',
                                'role_choice' => 'scalar',
                                'domain_choice' => 'scalar',
+                               'inststatus_choice' => 'scalar',
                              };
     my $defdom = $env{'request.role.domain'};
     if ($context eq 'course') {
@@ -895,7 +918,8 @@
              ['ipwd', &mt('Initial Password'),$env{'form.ipwd_choice'}],
              ['email',&mt('E-mail Address'),   $env{'form.email_choice'}],
              ['role',&mt('Role'),             $env{'form.role_choice'}],
-             ['domain',&mt('Domain'),         $env{'form.domain_choice'}]);
+             ['domain',&mt('Domain'),         $env{'form.domain_choice'}],
+             ['inststatus',&mt('Affiliation'), $env{'form.inststatus_choice'}]);
         if ($env{'form.upfile_associate'} eq 'reverse') {
             &Apache::loncommon::csv_print_samples($r,\@records);
             $i=&Apache::loncommon::csv_print_select_table($r,\@records,
@@ -3447,7 +3471,8 @@
                                                 'ipwd_choice' => 'scalar',
                                                 'email_choice' => 'scalar',
                                                 'role_choice'  => 'scalar',
-                                                'domain_choice' => 'scalar'});
+                                                'domain_choice' => 'scalar',
+                                                'inststatus_choice' => 'scalar'});
     #
     my ($startdate,$enddate) = &get_dates_from_form();
     if ($env{'form.makedatesdefault'}) {
@@ -3530,6 +3555,7 @@
                     'permanentemail','id');
     my %canmodify;
     if (&Apache::lonnet::allowed('mau',$domain)) {
+        push(@userinfo,'inststatus');
         foreach my $field (@userinfo) {
             $canmodify{$field} = 1;
         }
@@ -3717,7 +3743,15 @@
                     if (defined($fields{'email'})) {
                         if (defined($entries{$fields{'email'}})) {
                             $email=$entries{$fields{'email'}};
-                            unless ($email=~/^[^\@]+\@[^\@]+$/) { $email=''; }                        }
+                            unless ($email=~/^[^\@]+\@[^\@]+$/) { $email=''; }
+                        }
+                    }
+                    # determine affiliation
+                    my $inststatus='';
+                    if (defined($fields{'inststatus'})) {
+                        if (defined($entries{$fields{'inststatus'}})) {
+                            $inststatus=$entries{$fields{'inststatus'}};
+                        }
                     }
                     # determine user password
                     my $password = $genpwd;
@@ -3800,7 +3834,7 @@
                                 }
                             }
                             my @newinfo = (\$fname,\$mname,\$lname,\$gen,\$email,\$id);
-                            for (my $i=0; $i<@userinfo; $i++) {
+                            for (my $i=0; $i<@newinfo; $i++) {
                                 if (${$newinfo[$i]} ne '') {
                                     if (!$canmodify{$userinfo[$i]}) {
                                         ${$newinfo[$i]} = '';
@@ -3849,7 +3883,7 @@
                                      $fname,$mname,$lname,$gen,$sec,$enddate,
                                      $startdate,$env{'form.forceid'},
                                      $desiredhost,$email,'manual','',$cid,
-                                     '',$context);
+                                     '',$context,$inststatus);
                             $userresult = $roleresult;
                         } else {
                             if ($role ne '') { 
@@ -3869,7 +3903,7 @@
                                                     $mname,$lname,$gen,$sec,
                                                     $env{'form.forceid'},$desiredhost,
                                                     $email,$role,$enddate,
-                                                    $startdate,$checkid);
+                                                    $startdate,$checkid,$inststatus);
                                             }
                                         } elsif (@secs > 0) {
                                             $singlesec = $secs[0];
@@ -3884,7 +3918,8 @@
                                                     $id,$amode,$password,$fname,
                                                     $mname,$lname,$gen,$singlesec,
                                                     $env{'form.forceid'},$desiredhost,
-                                                    $email,$role,$enddate,$startdate,$checkid);
+                                                    $email,$role,$enddate,$startdate,
+                                                    $checkid,$inststatus);
                             }
                         }
                         if ($multiple) {
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.285 loncom/interface/loncreateuser.pm:1.286
--- loncom/interface/loncreateuser.pm:1.285	Sun Mar  8 20:26:32 2009
+++ loncom/interface/loncreateuser.pm	Mon Mar  9 05:25:40 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.285 2009/03/08 20:26:32 weissno Exp $
+# $Id: loncreateuser.pm,v 1.286 2009/03/09 05:25:40 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1524,16 +1524,19 @@
 
 sub personal_data_display {
     my ($ccuname,$ccdomain,$newuser,$context,$inst_results,$rolesarray) = @_;
-    my ($output,$showforceid,%userenv,%canmodify);
+    my ($output,$showforceid,%userenv,%canmodify,%canmodify_status);
     my @userinfo = ('firstname','middlename','lastname','generation',
                     'permanentemail','id');
     my $rowcount = 0;
     my $editable = 0;
+    %canmodify_status = 
+        &Apache::lonuserutils::can_modify_userinfo($context,$ccdomain,
+                                                   ['inststatus'],$rolesarray);
     if (!$newuser) {
         # Get the users information
         %userenv = &Apache::lonnet::get('environment',
                    ['firstname','middlename','lastname','generation',
-                    'permanentemail','id'],$ccdomain,$ccuname);
+                    'permanentemail','id','inststatus'],$ccdomain,$ccuname);
         %canmodify =
             &Apache::lonuserutils::can_modify_userinfo($context,$ccdomain,
                                                        \@userinfo,$rolesarray);
@@ -1549,7 +1552,8 @@
                 'generation'     => "Generation",
                 'permanentemail' => "Permanent e-mail address",
                 'id'             => "Student/Employee ID",
-                'lg'             => "Login Data"
+                'lg'             => "Login Data",
+                'inststatus'     => "Affiliation",
     );
     my %textboxsize = (
                        firstname      => '15',
@@ -1613,6 +1617,30 @@
             $rowcount ++;
         }
     }
+    if (($canmodify_status{'inststatus'}) || ($context ne 'selfcreate')) {
+        my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($ccdomain);
+        if (ref($types) eq 'ARRAY') {
+            if (@{$types} > 0) {
+                my ($hiderow,$shown);
+                if ($canmodify_status{'inststatus'}) {
+                    $shown = &pick_inst_statuses($userenv{'inststatus'},$usertypes,$types);
+                } else {
+                    $shown .= $userenv{'inststatus'};
+                    if ($userenv{'inststatus'} eq '') {
+                        $hiderow = 1;
+                    }
+                }
+                if (!$hiderow) {
+                    my $row = &Apache::lonhtmlcommon::row_title(&mt('Affliations'),undef,'LC_oddrow_value')."\n".
+                              $shown.&Apache::lonhtmlcommon::row_closure(1); 
+                    if ($context eq 'selfcreate') {
+                        $rowcount ++;
+                    }
+                    $output .= $row;
+                }
+            }
+        }
+    }
     $output .= &Apache::lonhtmlcommon::end_pick_box();
     if (wantarray) {
         if ($context eq 'selfcreate') {
@@ -1625,6 +1653,48 @@
     }
 }
 
+sub pick_inst_statuses {
+    my ($curr,$usertypes,$types) = @_;
+    my ($output,$rem,@currtypes);
+    if ($curr ne '') {
+        @currtypes = map { &unescape($_); } split(/:/,$curr);
+    }
+    my $numinrow = 2;
+    if (ref($types) eq 'ARRAY') {
+        $output = '<table>';
+        my $lastcolspan; 
+        for (my $i=0; $i<@{$types}; $i++) {
+            if (defined($usertypes->{$types->[$i]})) {
+                my $rem = $i%($numinrow);
+                if ($rem == 0) {
+                    if ($i<@{$types}-1) {
+                        if ($i > 0) { 
+                            $output .= '</tr>';
+                        }
+                        $output .= '<tr>';
+                    }
+                } elsif ($i==@{$types}-1) {
+                    my $colsleft = $numinrow - $rem;
+                    if ($colsleft > 1) {
+                        $lastcolspan = ' colspan="'.$colsleft.'"';
+                    }
+                }
+                my $check = ' ';
+                if (grep(/^\Q$types->[$i]\E$/,@currtypes)) {
+                    $check = ' checked="checked" ';
+                }
+                $output .= '<td class="LC_left_item"'.$lastcolspan.'>'.
+                           '<span class="LC_nobreak"><label>'.
+                           '<input type="checkbox" name="inststatus" '.
+                           'value="'.$types->[$i].'"'.$check.'/>'.
+                           $usertypes->{$types->[$i]}.'</label></span></td>';
+            }
+        }
+        $output .= '</tr></table>';
+    }
+    return $output;
+}
+
 sub selfcreate_canmodify {
     my ($context,$dom,$userinfo,$inst_results,$rolesarray) = @_;
     if (ref($inst_results) eq 'HASH') {
@@ -1774,6 +1844,8 @@
     my (%alerts,%rulematch,%inst_results,%curr_rules);
     my @usertools = ('aboutme','blog','portfolio');
     my @requestcourses = ('official','unofficial');
+    my ($othertitle,$usertypes,$types) = 
+        &Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});
     if ($env{'form.makeuser'}) {
 	$r->print('<h3>'.&mt('Creating new account.').'</h3>');
         # Check for the authentication mode and password
@@ -1856,6 +1928,13 @@
                 $changed{$item} = &tool_admin($item,$newcustom{$item},
                                               \%changeHash,'requestcourses');
             }
+            if (exists($env{'form.inststatus'})) {
+                my @inststatuses = &Apache::loncommon::get_env_multiple('form.inststatus');
+                if (@inststatuses > 0) {
+                    $changeHash{'inststatus'} = join(',',@inststatuses);
+                    $changed{'inststatus'} = $changeHash{'inststatus'};
+                }
+            }
             if (keys(%changed)) {
                 $changeHash{'firstname'}  = $env{'form.cfirstname'};
                 $changeHash{'middlename'} = $env{'form.cmiddlename'};
@@ -2024,12 +2103,13 @@
                 }
             }
         }
-        my ($quotachanged,$oldportfolioquota,$newportfolioquota,
-            $inststatus,$oldisdefault,$newisdefault,$olddefquotatext,
-            $newdefquotatext,%oldaccess,%oldaccesstext,%newaccess,%newaccesstext);
+        my ($quotachanged,$oldportfolioquota,$newportfolioquota,$oldinststatus,
+            $inststatus,$newinststatus,$oldisdefault,$newisdefault,$olddefquotatext,
+            $newdefquotatext,%oldaccess,%oldaccesstext,%newaccess,%newaccesstext,
+            $oldinststatuses,$newinststatuses);
         my ($defquota,$settingstatus) = 
             &Apache::loncommon::default_quota($env{'form.ccdomain'},$inststatus);
-        my ($showquota,$showtools,$showrequestcourses);
+        my ($showquota,$showtools,$showrequestcourses,$showinststatus);
         if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
             $showquota = 1;
         }
@@ -2039,7 +2119,46 @@
         if (&Apache::lonnet::allowed('ccc',$env{'form.ccdomain'})) {
             $showrequestcourses = 1;
         }
+        if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) {
+            $showinststatus = 1;
+        }
         my (%changeHash,%changed);
+        $oldinststatus = $userenv{'inststatus'};
+        if ($oldinststatus eq '') {
+            $oldinststatuses = $othertitle; 
+        } else {
+            if (ref($usertypes) eq 'HASH') {
+                $oldinststatuses = join(', ',map{ $usertypes->{ &unescape($_) }; } (split(/:/,$userenv{'inststatus'})));
+            } else {
+                $oldinststatuses = join(', ',map{ &unescape($_); } (split(/:/,$userenv{'inststatus'})));
+            }
+        }
+        $changeHash{'inststatus'} = $userenv{'inststatus'};
+        my %canmodify_inststatus = &Apache::lonuserutils::can_modify_userinfo($context,$env{'form.ccdomain'},['inststatus'],\@userroles);
+        if ($canmodify_inststatus{'inststatus'}) {
+            if (exists($env{'form.inststatus'})) {
+                my @inststatuses = &Apache::loncommon::get_env_multiple('form.inststatus');
+                if (@inststatuses > 0) {
+                    $newinststatus = join(':',map { &escape($_); } @inststatuses);
+                    $changeHash{'inststatus'} = $newinststatus;
+                    if ($newinststatus ne $oldinststatus) {
+                        $changed{'inststatus'} = $newinststatus;
+                    }
+                    if (ref($usertypes) eq 'HASH') {
+                        $newinststatuses = join(', ',map{ $usertypes->{$_}; } (@inststatuses)); 
+                    } else {
+                        $newinststatuses = join(', ',map{ $usertypes->{$_}; } (@inststatuses));
+                    }
+                } else {
+                    $newinststatus = '';
+                    $changeHash{'inststatus'} = $newinststatus;
+                    $newinststatuses = $othertitle;
+                    if ($newinststatus ne $oldinststatus) {
+                        $changed{'inststatus'} = $changeHash{'inststatus'};
+                    }
+                }
+            }
+        }
         $changeHash{'portfolioquota'} = $userenv{'portfolioquota'};
         if ($userenv{'portfolioquota'} ne '') {
             $oldportfolioquota = $userenv{'portfolioquota'};
@@ -2171,6 +2290,7 @@
                              'portfolio'  => 'Portfolio Availability',
                              'official'   => 'Can Request Official Courses',
                              'unofficial' => 'Can Request Unofficial Courses',
+                             'inststatus' => "Affiliation",
                              'prvs'       => 'Previous Value:',
                              'chto'       => 'Changed To:'
 						   );
@@ -2186,6 +2306,10 @@
     <th>$lt{'id'}</th>
     <th>$lt{'mail'}</th>
 END
+                if ($showinststatus) {
+                    $r->print("
+    <th>$lt{'inststatus'}</th>\n");
+                }
                 if ($showrequestcourses) {
                     foreach my $item (@requestcourses) {
                         $r->print("
@@ -2213,6 +2337,10 @@
     <td>$userenv{'id'}</td>
     <td>$userenv{'permanentemail'} </td>
 END
+                if ($showinststatus) {
+                    $r->print("
+    <td>$oldinststatuses</td>\n");
+                }  
                 if ($showrequestcourses) {
                     foreach my $item (@requestcourses) {
                         $r->print("
@@ -2240,6 +2368,10 @@
     <td>$env{'form.cid'} </td>
     <td>$env{'form.cpermanentemail'} </td>
 END
+                if ($showinststatus) {
+                    $r->print("
+    <td>$newinststatuses</td>\n");
+                }
                 if ($showrequestcourses) {
                     foreach my $item (@requestcourses) {
                         $r->print("
@@ -2296,6 +2428,7 @@
                            'portfolio'  => "Portfolio Availability",
                            'official'   => "Can Request Official Courses",
                            'unofficial' => "Can Request Unofficial Course",
+                           'inststatus' => "Affiliation",
 					       );
             $r->print(<<"END");
 <h4>$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} $userenv{'generation'}
@@ -2304,6 +2437,9 @@
                 $r->print('<br />['.$lt{'mail'}.': '.
                           $userenv{'permanentemail'}.']');
             }
+            if ($showinststatus) {
+                $r->print('<br />['.$lt{'inststatus'}.': '.$oldinststatuses.']');
+            }
             if ($showrequestcourses) {
                 foreach my $item (@requestcourses) {
                     $r->print('<br />['.$lt{$item}.': '.$newaccess{$item}.' '.
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.764 loncom/interface/loncommon.pm:1.765
--- loncom/interface/loncommon.pm:1.764	Sun Mar  8 21:49:33 2009
+++ loncom/interface/loncommon.pm	Mon Mar  9 05:25:40 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.764 2009/03/08 21:49:33 weissno Exp $
+# $Id: loncommon.pm,v 1.765 2009/03/09 05:25:40 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -7044,7 +7044,7 @@
                                             ['quotas'],$udom);
     if (ref($quotahash{'quotas'}) eq 'HASH') {
         if ($inststatus ne '') {
-            my @statuses = split(/:/,$inststatus);
+            my @statuses = map { &unescape($_); } split(/:/,$inststatus);
             foreach my $item (@statuses) {
                 if (ref($quotahash{'quotas'}{'defaultquota'}) eq 'HASH') {
                     if ($quotahash{'quotas'}{'defaultquota'}{$item} ne '') {
@@ -7510,6 +7510,7 @@
                         middlename => 'Middle Name',
                         generation => 'Generation',
                         gen => 'Generation',
+                        inststatus => 'Affiliation',
                    );
     return %fieldtitles;
 }
@@ -10020,6 +10021,12 @@
                 &Apache::lonnet::usertools_access($username,$domain,$tool,'reload');
         }
 
+        foreach my $crstype ('official','unofficial') {
+            $userenv{'canrequest.'.$crstype} =
+                &Apache::lonnet::usertools_access($username,$domain,$crstype,
+                                                  'reload','requestcourses');
+        }
+
 	$env{'user.environment'} = "$lonids/$cookie.id";
 	
 	if (tie(my %disk_env,'GDBM_File',"$lonids/$cookie.id",
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.989 loncom/lonnet/perl/lonnet.pm:1.990
--- loncom/lonnet/perl/lonnet.pm:1.989	Mon Mar  9 03:49:17 2009
+++ loncom/lonnet/perl/lonnet.pm	Mon Mar  9 05:25:44 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.989 2009/03/09 03:49:17 raeburn Exp $
+# $Id: lonnet.pm,v 1.990 2009/03/09 05:25:44 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -5951,7 +5951,7 @@
 sub modifystudent {
     my ($udom,$uname,$uid,$umode,$upass,$first,$middle,$last,$gene,$usec,
         $end,$start,$forceid,$desiredhome,$email,$type,$locktype,$cid,
-        $selfenroll,$context)=@_;
+        $selfenroll,$context,$inststatus)=@_;
     if (!$cid) {
 	unless ($cid=$env{'request.course.id'}) {
 	    return 'not_in_class';
@@ -5960,7 +5960,7 @@
 # --------------------------------------------------------------- Make the user
     my $reply=&modifyuser
 	($udom,$uname,$uid,$umode,$upass,$first,$middle,$last,$gene,$forceid,
-         $desiredhome,$email);
+         $desiredhome,$email,$inststatus);
     unless ($reply eq 'ok') { return $reply; }
     # This will cause &modify_student_enrollment to get the uid from the
     # students environment
Index: loncom/enrollment/Autoupdate.pl
diff -u loncom/enrollment/Autoupdate.pl:1.12 loncom/enrollment/Autoupdate.pl:1.13
--- loncom/enrollment/Autoupdate.pl:1.12	Sun Feb  1 20:10:26 2009
+++ loncom/enrollment/Autoupdate.pl	Mon Mar  9 05:25:49 2009
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 #
 # Automated Userinfo update script
-# $Id: Autoupdate.pl,v 1.12 2009/02/01 20:10:26 raeburn Exp $
+# $Id: Autoupdate.pl,v 1.13 2009/03/09 05:25:49 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -82,7 +82,7 @@
                     (my $insttypechg,@inststatuses) = 
                        &affiliations_check(\%userhash,$instusers{$uname});
                     if ($insttypechg) {
-                        my $inststatusstr = join(':',&escape(@inststatuses));
+                        my $inststatusstr = join(':',map { &escape($_) } (@inststatuses));
                         my %statushash = ( inststatus => $inststatusstr );
                         my $statusres = &Apache::lonnet::put('environment',\%statushash,$dom,$uname);
                     }

--raeburn1236576350--