[LON-CAPA-cvs] cvs: loncom(version_2_10_X) /lonnet/perl lonnet.pm

raeburn raeburn@source.lon-capa.org
Tue, 18 May 2010 04:22:01 -0000


raeburn		Tue May 18 04:22:01 2010 EDT

  Modified files:              (Branch: version_2_10_X)
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - Backport 1.1058, 1.1059, 1.1060.
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1056 loncom/lonnet/perl/lonnet.pm:1.1056.4.1
--- loncom/lonnet/perl/lonnet.pm:1.1056	Wed Mar 17 20:22:06 2010
+++ loncom/lonnet/perl/lonnet.pm	Tue May 18 04:22:00 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1056 2010/03/17 20:22:06 raeburn Exp $
+# $Id: lonnet.pm,v 1.1056.4.1 2010/05/18 04:22:00 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4624,7 +4624,7 @@
                 my (%allgroups,%allroles); 
                 my ($start,$end,$role,$sec,$group);
                 foreach my $envkey (%env) {
-                    if ($envkey =~ m-^user\.role\.(gr|cc|in|ta|ep|st)\./($match_domain)/($match_courseid)/?([^/]*)$-) {
+                    if ($envkey =~ m-^user\.role\.(gr|cc|co|in|ta|ep|ad|st)\./($match_domain)/($match_courseid)/?([^/]*)$-) {
                         my $cid = $2.'_'.$3; 
                         if ($1 eq 'gr') {
                             $group = $4;
@@ -6524,12 +6524,18 @@
     my ($udom,    $uname, $uid,
         $umode,   $upass, $first,
         $middle,  $last,  $gene,
-        $forceid, $desiredhome, $email, $inststatus)=@_;
+        $forceid, $desiredhome, $email, $inststatus, $candelete)=@_;
     $udom= &LONCAPA::clean_domain($udom);
     $uname=&LONCAPA::clean_username($uname);
+    my $showcandelete = 'none';
+    if (ref($candelete) eq 'ARRAY') {
+        if (@{$candelete} > 0) {
+            $showcandelete = join(', ',@{$candelete});
+        }
+    }
     &logthis('Call to modify user '.$udom.', '.$uname.', '.$uid.', '.
              $umode.', '.$first.', '.$middle.', '.
-	     $last.', '.$gene.'(forceid: '.$forceid.')'.
+             $last.', '.$gene.'(forceid: '.$forceid.'; candelete: '.$showcandelete.')'.
              (defined($desiredhome) ? ' desiredhome = '.$desiredhome :
                                      ' desiredhome not specified'). 
              ' by '.$env{'user.name'}.' at '.$env{'user.domain'}.
@@ -6593,10 +6599,33 @@
     } else {
         %names = @tmp;
     }
-#
-# Make sure to not trash student environment if instructor does not bother
-# to supply name and email information
-#
+# If name, email and/or uid are blank (e.g., because an uploaded file
+# of users did not contain them), do not overwrite existing values
+# unless field is in $candelete array ref.  
+#
+
+    my @fields = ('firstname','middlename','lastname','generation',
+                  'permanentemail','id');
+    my %newvalues;
+    if (ref($candelete) eq 'ARRAY') {
+        foreach my $field (@fields) {
+            if (grep(/^\Q$field\E$/,@{$candelete})) {
+                if ($field eq 'firstname') {
+                    $names{$field} = $first;
+                } elsif ($field eq 'middlename') {
+                    $names{$field} = $middle;
+                } elsif ($field eq 'lastname') {
+                    $names{$field} = $last;
+                } elsif ($field eq 'generation') { 
+                    $names{$field} = $gene;
+                } elsif ($field eq 'permanentemail') {
+                    $names{$field} = $email;
+                } elsif ($field eq 'id') {
+                    $names{$field}  = $uid;
+                }
+            }
+        }
+    }
     if ($first)  { $names{'firstname'}  = $first; }
     if (defined($middle)) { $names{'middlename'} = $middle; }
     if ($last)   { $names{'lastname'}   = $last; }
@@ -10323,9 +10352,16 @@
 
 =item *
 
-modifyuser($udom,$uname,$uid,$umode,$upass,$first,$middle,$last,$gene,
-           $forceid,$desiredhome,$email,$inststatus) : 
-modify user
+modifyuser($udom,$uname,$uid,$umode,$upass,$first,$middle,$last, $gene,
+           $forceid,$desiredhome,$email,$inststatus,$candelete) :
+
+will update user information (firstname,middlename,lastname,generation,
+permanentemail), and if forceid is true, student/employee ID also.
+A user's institutional affiliation(s) can also be updated.
+User information fields will not be overwritten with empty entries 
+unless the field is included in the $candelete array reference.
+This array is included when a single user is modified via "Manage Users",
+or when Autoupdate.pl is run by cron in a domain.
 
 =item *