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

raeburn raeburn@source.lon-capa.org
Fri, 05 Mar 2010 06:37:43 -0000


This is a MIME encoded message

--raeburn1267771063
Content-Type: text/plain

raeburn		Fri Mar  5 06:37:43 2010 EDT

  Modified files:              
    /loncom/interface	loncreateuser.pm 
  Log:
  Bug 6025
    - New subroutine &display_userinfo() used to generate display of 
      user information and user settings.
    - Use affiliation descriptions when displaying institutional statuses.
    - Check whether affliation should be shown uses 
      lonuserutils::can_modify_userinfo().
  
  
--raeburn1267771063
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20100305063743.txt"

Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.333 loncom/interface/loncreateuser.pm:1.334
--- loncom/interface/loncreateuser.pm:1.333	Wed Jan 20 09:49:54 2010
+++ loncom/interface/loncreateuser.pm	Fri Mar  5 06:37:43 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.333 2010/01/20 09:49:54 wenzelju Exp $
+# $Id: loncreateuser.pm,v 1.334 2010/03/05 06:37:43 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2063,9 +2063,22 @@
                 if ($canmodify_status{'inststatus'}) {
                     $shown = &pick_inst_statuses($userenv{'inststatus'},$usertypes,$types);
                 } else {
-                    $shown .= $userenv{'inststatus'};
                     if ($userenv{'inststatus'} eq '') {
                         $hiderow = 1;
+                    } else {
+                        my @showitems;
+                        foreach my $item ( map { &unescape($_); } split(':',$userenv{'inststatus'})) {
+                            if (exists($usertypes->{$item})) {
+                                push(@showitems,$usertypes->{$item});
+                            } else {
+                                push(@showitems,$item);
+                            }
+                        }
+                        if (@showitems) {
+                            $shown = join(', ',@showitems);
+                        } else {
+                            $hiderow = 1;
+                        }
                     }
                 }
                 if (!$hiderow) {
@@ -2283,10 +2296,14 @@
     $r->print('<h3>'.&mt('User [_1] in domain [_2]',
 			 $env{'form.ccuname'}, $env{'form.ccdomain'}).'</h3>');
     my (%alerts,%rulematch,%inst_results,%curr_rules);
+    my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
     my @usertools = ('aboutme','blog','portfolio');
     my @requestcourses = ('official','unofficial','community');
     my ($othertitle,$usertypes,$types) = 
         &Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});
+    my %canmodify_status =
+        &Apache::lonuserutils::can_modify_userinfo($context,$env{'form.ccdomain'},
+                                                   ['inststatus']);
     if ($env{'form.makeuser'}) {
 	$r->print('<h3>'.&mt('Creating new account.').'</h3>');
         # Check for the authentication mode and password
@@ -2346,49 +2363,50 @@
 	$r->print(&mt('Generating user').': '.$result);
         $uhome = &Apache::lonnet::homeserver($env{'form.ccuname'},
                                                $env{'form.ccdomain'});
-        my (%changeHash,%newcustom,%changed);
+        my (%changeHash,%newcustom,%changed,%changedinfo);
         if ($uhome ne 'no_host') {
-            if ($env{'form.customquota'} == 1) {
-                if ($env{'form.portfolioquota'} eq '') {
-                    $newcustom{'quota'} = 0;
-                } else {
-                    $newcustom{'quota'} = $env{'form.portfolioquota'};
-                    $newcustom{'quota'} =~ s/[^\d\.]//g;
+            if ($context eq 'domain') {
+                if ($env{'form.customquota'} == 1) {
+                    if ($env{'form.portfolioquota'} eq '') {
+                        $newcustom{'quota'} = 0;
+                    } else {
+                        $newcustom{'quota'} = $env{'form.portfolioquota'};
+                        $newcustom{'quota'} =~ s/[^\d\.]//g;
+                    }
+                    $changed{'quota'} = &quota_admin($newcustom{'quota'},\%changeHash);
                 }
-                $changed{'quota'} = &quota_admin($newcustom{'quota'},\%changeHash);
-            }
-            foreach my $item (@usertools) {
-                if ($env{'form.custom'.$item} == 1) {
-                    $newcustom{$item} = $env{'form.tools_'.$item};
-                    $changed{$item} = &tool_admin($item,$newcustom{$item},
-                                                 \%changeHash,'tools');
+                foreach my $item (@usertools) {
+                    if ($env{'form.custom'.$item} == 1) {
+                        $newcustom{$item} = $env{'form.tools_'.$item};
+                        $changed{$item} = &tool_admin($item,$newcustom{$item},
+                                                     \%changeHash,'tools');
+                    }
                 }
-            }
-            foreach my $item (@requestcourses) {
-                $newcustom{$item} = $env{'form.crsreq_'.$item};
-                if ($env{'form.crsreq_'.$item} eq 'autolimit') {
-                    $newcustom{$item} .= '=';
-                    unless ($env{'form.crsreq_'.$item.'_limit'} =~ /\D/) {
-                        $newcustom{$item} .= $env{'form.crsreq_'.$item.'_limit'};
+                foreach my $item (@requestcourses) {
+                    $newcustom{$item} = $env{'form.crsreq_'.$item};
+                    if ($env{'form.crsreq_'.$item} eq 'autolimit') {
+                        $newcustom{$item} .= '=';
+                        unless ($env{'form.crsreq_'.$item.'_limit'} =~ /\D/) {
+                            $newcustom{$item} .= $env{'form.crsreq_'.$item.'_limit'};
+                        }
                     }
+                    $changed{$item} = &tool_admin($item,$newcustom{$item},
+                                                  \%changeHash,'requestcourses');
                 }
-                $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 ($canmodify_status{'inststatus'}) {
+                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'};
-                $changeHash{'lastname'}   = $env{'form.clastname'};
-                $changeHash{'generation'} = $env{'form.cgeneration'};
-                $changeHash{'id'}         = $env{'form.cid'};
-                $changeHash{'permanentemail'} = $env{'form.cpermanentemail'};
+                foreach my $item (@userinfo) {
+                    $changeHash{$item}  = $env{'form.c'.$item};
+                }
                 my $chgresult =
                      &Apache::lonnet::put('environment',\%changeHash,
                                           $env{'form.ccdomain'},$env{'form.ccuname'});
@@ -2417,7 +2435,7 @@
 	}
     }
     ##
-    my (@userroles,%userupdate,$cnum,$cdom,$crstype,$namechanged);
+    my (@userroles,%userupdate,$cnum,$cdom,$crstype,%namechanged);
     if ($context eq 'course') {
         ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity();
         $crstype = &Apache::loncommon::course_type($cdom.'_'.$cnum);
@@ -2507,7 +2525,6 @@
                 push(@longroles,&Apache::lonnet::plaintext($role,$crstype)); 
             }
         }
-        my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
         my %canmodify = &Apache::lonuserutils::can_modify_userinfo($context,$env{'form.ccdomain'},\@userinfo,\@userroles);
         foreach my $item (@userinfo) {
             # Strip leading and trailing whitespace
@@ -2554,40 +2571,46 @@
             }
         }
         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,$showinststatus,$showreqotherdom);
+            $newinststatus,$oldisdefault,$newisdefault,%oldsettings,
+            %oldsettingstext,%newsettings,%newsettingstext,@disporder);
+        @disporder = ('inststatus');
+        if ($env{'request.role.domain'} eq $env{'form.ccdomain'}) {
+            push(@disporder,'requestcourses');
+        } else {
+            push(@disporder,'reqcrsotherdom');
+        }
+        push(@disporder,('quota','tools'));
+        my ($defquota,my $settingstatus) = 
+            &Apache::loncommon::default_quota($env{'form.ccdomain'},$oldinststatus);
+        my %canshow;
         if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
-            $showquota = 1;
+            $canshow{'quota'} = 1;
         }
         if (&Apache::lonnet::allowed('mut',$env{'form.ccdomain'})) {
-            $showtools = 1;
+            $canshow{'tools'} = 1;
         }
         if (&Apache::lonnet::allowed('ccc',$env{'form.ccdomain'})) {
-            $showrequestcourses = 1;
+            $canshow{'requestcourses'} = 1;
         } elsif (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
-            $showreqotherdom = 1;
+            $canshow{'reqcrsotherdom'} = 1;
         }
         if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) {
-            $showinststatus = 1;
+            $canshow{'inststatus'} = 1;
         }
         my (%changeHash,%changed);
         $oldinststatus = $userenv{'inststatus'};
         if ($oldinststatus eq '') {
-            $oldinststatuses = $othertitle; 
+            $oldsettings{'inststatus'} = $othertitle; 
         } else {
             if (ref($usertypes) eq 'HASH') {
-                $oldinststatuses = join(', ',map{ $usertypes->{ &unescape($_) }; } (split(/:/,$userenv{'inststatus'})));
+                $oldsettings{'inststatus'} = join(', ',map{ $usertypes->{ &unescape($_) }; } (split(/:/,$userenv{'inststatus'})));
             } else {
-                $oldinststatuses = join(', ',map{ &unescape($_); } (split(/:/,$userenv{'inststatus'})));
+                $oldsettings{'inststatus'} = 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 ($canmodify_status{'inststatus'}) {
+            $canshow{'inststatus'} = 1;
             if (exists($env{'form.inststatus'})) {
                 my @inststatuses = &Apache::loncommon::get_env_multiple('form.inststatus');
                 if (@inststatuses > 0) {
@@ -2597,78 +2620,81 @@
                         $changed{'inststatus'} = $newinststatus;
                     }
                     if (ref($usertypes) eq 'HASH') {
-                        $newinststatuses = join(', ',map{ $usertypes->{$_}; } (@inststatuses)); 
+                        $newsettings{'inststatus'} = 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'};
+                        $newsettings{'inststatus'} = join(', ',map{ $usertypes->{$_}; } (@inststatuses));
                     }
                 }
+            } else {
+                $newinststatus = '';
+                $changeHash{'inststatus'} = $newinststatus;
+                $newsettings{'inststatus'} = $othertitle;
+                if ($newinststatus ne $oldinststatus) {
+                    $changed{'inststatus'} = $changeHash{'inststatus'};
+                }
             }
+        } elsif ($context ne 'selfcreate') {
+            $canshow{'inststatus'} = 1;
         }
         $changeHash{'portfolioquota'} = $userenv{'portfolioquota'};
-        if ($userenv{'portfolioquota'} ne '') {
-            $oldportfolioquota = $userenv{'portfolioquota'};
-            if ($env{'form.customquota'} == 1) {
-                if ($env{'form.portfolioquota'} eq '') {
-                    $newportfolioquota = 0;
+        if ($context eq 'domain') {
+            if ($userenv{'portfolioquota'} ne '') {
+                $oldportfolioquota = $userenv{'portfolioquota'};
+                if ($env{'form.customquota'} == 1) {
+                    if ($env{'form.portfolioquota'} eq '') {
+                        $newportfolioquota = 0;
+                    } else {
+                        $newportfolioquota = $env{'form.portfolioquota'};
+                        $newportfolioquota =~ s/[^\d\.]//g;
+                    }
+                    if ($newportfolioquota != $oldportfolioquota) {
+                        $changed{'quota'} = &quota_admin($newportfolioquota,\%changeHash);
+                    }
                 } else {
-                    $newportfolioquota = $env{'form.portfolioquota'};
-                    $newportfolioquota =~ s/[^\d\.]//g;
-                }
-                if ($newportfolioquota != $oldportfolioquota) {
-                    $changed{'quota'} = &quota_admin($newportfolioquota,\%changeHash);
+                    $changed{'quota'} = &quota_admin('',\%changeHash);
+                    $newportfolioquota = $defquota;
+                    $newisdefault = 1;
                 }
             } else {
-                $changed{'quota'} = &quota_admin('',\%changeHash);
-                $newportfolioquota = $defquota;
-                $newisdefault = 1;
-            }
-        } else {
-            $oldisdefault = 1;
-            $oldportfolioquota = $defquota;
-            if ($env{'form.customquota'} == 1) {
-                if ($env{'form.portfolioquota'} eq '') {
-                    $newportfolioquota = 0;
+                $oldisdefault = 1;
+                $oldportfolioquota = $defquota;
+                if ($env{'form.customquota'} == 1) {
+                    if ($env{'form.portfolioquota'} eq '') {
+                        $newportfolioquota = 0;
+                    } else {
+                        $newportfolioquota = $env{'form.portfolioquota'};
+                        $newportfolioquota =~ s/[^\d\.]//g;
+                    }
+                    $changed{'quota'} = &quota_admin($newportfolioquota,\%changeHash);
                 } else {
-                    $newportfolioquota = $env{'form.portfolioquota'};
-                    $newportfolioquota =~ s/[^\d\.]//g;
+                    $newportfolioquota = $defquota;
+                    $newisdefault = 1;
                 }
-                $changed{'quota'} = &quota_admin($newportfolioquota,\%changeHash);
+            }
+            if ($oldisdefault) {
+                $oldsettingstext{'quota'} = &get_defaultquota_text($settingstatus);
+            }
+            if ($newisdefault) {
+                $newsettingstext{'quota'} = &get_defaultquota_text($settingstatus);
+            }
+            &tool_changes('tools',\@usertools,\%oldsettings,\%oldsettingstext,\%userenv,
+                          \%changeHash,\%changed,\%newsettings,\%newsettingstext);
+            if ($env{'form.ccdomain'} eq $env{'request.role.domain'}) {
+                &tool_changes('requestcourses',\@requestcourses,\%oldsettings,\%oldsettingstext,
+                              \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
             } else {
-                $newportfolioquota = $defquota;
-                $newisdefault = 1;
+                &tool_changes('reqcrsotherdom',\@requestcourses,\%oldsettings,\%oldsettingstext,
+                              \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
             }
         }
-        if ($oldisdefault) {
-            $olddefquotatext = &get_defaultquota_text($settingstatus);
-        }
-        if ($newisdefault) {
-            $newdefquotatext = &get_defaultquota_text($settingstatus);
-        }
-        &tool_changes('tools',\@usertools,\%oldaccess,\%oldaccesstext,\%userenv,
-                      \%changeHash,\%changed,\%newaccess,\%newaccesstext);
-        if ($env{'form.ccdomain'} eq $env{'request.role.domain'}) {
-            &tool_changes('requestcourses',\@requestcourses,\%oldaccess,\%oldaccesstext,
-                          \%userenv,\%changeHash,\%changed,\%newaccess,\%newaccesstext);
-        } else {
-            &tool_changes('reqcrsotherdom',\@requestcourses,\%oldaccess,\%oldaccesstext,
-                          \%userenv,\%changeHash,\%changed,\%newaccess,\%newaccesstext);
-        }
-        if ($env{'form.cfirstname'}  ne $userenv{'firstname'}  ||
-            $env{'form.cmiddlename'} ne $userenv{'middlename'} ||
-            $env{'form.clastname'}   ne $userenv{'lastname'}   ||
-            $env{'form.cgeneration'} ne $userenv{'generation'} ||
-            $env{'form.cid'} ne $userenv{'id'}                 ||
-            $env{'form.cpermanentemail'} ne $userenv{'permanentemail'} ) {
-            $namechanged = 1;
+        foreach my $item (@userinfo) {
+            if ($env{'form.c'.$item} ne $userenv{$item}) {
+                $namechanged{$item} = 1;
+            }
         }
-        if (($namechanged) || (keys(%changed) > 0)) {
+        $oldsettings{'quota'} = $oldportfolioquota.' Mb';
+        $newsettings{'quota'} = $newportfolioquota.' Mb';
+        if ((keys(%namechanged) > 0) || (keys(%changed) > 0)) {
             $changeHash{'firstname'}  = $env{'form.cfirstname'};
             $changeHash{'middlename'} = $env{'form.cmiddlename'};
             $changeHash{'lastname'}   = $env{'form.clastname'};
@@ -2714,7 +2740,7 @@
                     }
                 }
             }
-            if ($namechanged) {
+            if (keys(%namechanged) > 0) {
             # Make the change
                 $namechgresult =
                     &Apache::lonnet::modifyuser($env{'form.ccdomain'},
@@ -2730,139 +2756,13 @@
                                id         => $env{'form.cid'},
                              );
             }
-            if (($namechanged && $namechgresult eq 'ok') || 
+            if (((keys(%namechanged) > 0) && $namechgresult eq 'ok') || 
                 ((keys(%changed) > 0) && $chgresult eq 'ok')) {
             # Tell the user we changed the name
-		my %lt=&Apache::lonlocal::texthash(
-                             'uic'        => 'User Information Changed',
-                             'frst'       => 'First Name',
-                             'mddl'       => 'Middle Name',
-                             'lst'        => 'Last Name',
-                             'gen'        => 'Generation',
-                             'id'         => 'Student/Employee ID',
-                             'mail'       => 'Permanent e-mail address',
-                             'disk'       => 'Disk space allocated to portfolio files',
-                             'blog'       => 'Blog Availability',
-                             'aboutme'    => 'Personal Information Page Availability',
-                             'portfolio'  => 'Portfolio Availability',
-                             'official'   => 'Can Request Official Courses',
-                             'unofficial' => 'Can Request Unofficial Courses',
-                             'community'  => 'Can Request Communities',
-                             'inststatus' => "Affiliation",
-                             'prvs'       => 'Previous Value:',
-                             'chto'       => 'Changed To:'
-						   );
-                $r->print('<h4>'.$lt{'uic'}.'</h4>'.
-                          &Apache::loncommon::start_data_table().
-                          &Apache::loncommon::start_data_table_header_row());
-                $r->print(<<"END");
-    <th>&nbsp;</th>
-    <th>$lt{'frst'}</th>
-    <th>$lt{'mddl'}</th>
-    <th>$lt{'lst'}</th>
-    <th>$lt{'gen'}</th>
-    <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("
-    <th>$lt{$item}</th>\n");
-                    }
-                } elsif ($showreqotherdom) {
-                    foreach my $item (@requestcourses) {
-                        $r->print("
-    <th>$lt{$item}</th>\n");
-                    }
-                }
-                if ($showquota) {
-                    $r->print("
-    <th>$lt{'disk'}</th>\n");
-                }
-                if ($showtools) {
-                    foreach my $item (@usertools) {
-                        $r->print("
-    <th>$lt{$item}</th>\n");
-                    }
-                }
-                $r->print(&Apache::loncommon::end_data_table_header_row().
-                          &Apache::loncommon::start_data_table_row());
-                $r->print(<<"END");
-    <td><b>$lt{'prvs'}</b></td>
-    <td>$userenv{'firstname'}  </td>
-    <td>$userenv{'middlename'} </td>
-    <td>$userenv{'lastname'}   </td>
-    <td>$userenv{'generation'} </td>
-    <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("
-    <td>$oldaccess{$item} $oldaccesstext{$item}</td>\n");
-                    }
-                } elsif ($showreqotherdom) {
-                    foreach my $item (@requestcourses) {
-                        $r->print("
-    <td>$oldaccess{$item} $oldaccesstext{$item}</td>\n");
-                    }
-                }
-                if ($showquota) {
-                    $r->print("
-    <td>$oldportfolioquota Mb $olddefquotatext </td>\n");
-                }
-                if ($showtools) {
-                    foreach my $item (@usertools) {
-                        $r->print("
-    <td>$oldaccess{$item} $oldaccesstext{$item} </td>\n");
-                    }
-                }
-                $r->print(&Apache::loncommon::end_data_table_row().
-                          &Apache::loncommon::start_data_table_row());
-                $r->print(<<"END");
-    <td><span class="LC_nobreak"><b>$lt{'chto'}</b></span></td>
-    <td>$env{'form.cfirstname'}  </td>
-    <td>$env{'form.cmiddlename'} </td>
-    <td>$env{'form.clastname'}   </td>
-    <td>$env{'form.cgeneration'} </td>
-    <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("
-    <td>$newaccess{$item} $newaccesstext{$item} </td>\n");
-                    }
-                } elsif ($showreqotherdom) {
-                    foreach my $item (@requestcourses) {
-                        $r->print("
-    <td>$newaccess{$item} $newaccesstext{$item} </td>\n");
-                    }
-                }
-                if ($showquota) {
-                    $r->print("
-    <td>$newportfolioquota Mb $newdefquotatext </td>\n");
-                }
-                if ($showtools) {
-                    foreach my $item (@usertools) {
-                        $r->print("
-    <td>$newaccess{$item} $newaccesstext{$item} </td>\n");
-                    }
-                }
-                $r->print(&Apache::loncommon::end_data_table_row().
-                          &Apache::loncommon::end_data_table().'<br />');
+                &display_userinfo($r,1,\@disporder,\%canshow,\@requestcourses,
+                                  \@usertools,\%userenv,\%changed,\%namechanged,
+                                  \%oldsettings, \%oldsettingstext,\%newsettings,
+                                  \%newsettingstext);
                 if ($env{'form.cid'} ne $userenv{'id'}) {
                     &Apache::lonnet::idput($env{'form.ccdomain'},
                          ($env{'form.ccuname'} => $env{'form.cid'}));
@@ -2888,54 +2788,13 @@
                       $env{'form.ccuname'}.' '.&mt('in domain').' '.
                       $env{'form.ccdomain'}.'</span><br />');
             }
-        }  else { # End of if ($env ... ) logic
+        } else { # End of if ($env ... ) logic
             # They did not want to change the users name, quota, tool availability,
             # or ability to request creation of courses, 
             # but we can still tell them what the name and quota and availabilities are  
-	    my %lt=&Apache::lonlocal::texthash(
-                           'id'         => "Student/Employee ID",
-                           'mail'       => "Permanent e-mail address",
-                           'disk'       => "Disk space allocated to user's portfolio files",
-                           'blog'       => "Blog Availability",
-                           'aboutme'    => "Personal Information Page Availability",
-                           'portfolio'  => "Portfolio Availability",
-                           'official'   => "Can Request Official Courses",
-                           'unofficial' => "Can Request Unofficial Courses",
-                           'community'  => "Can Request Communities",
-                           'inststatus' => "Affiliation",
-					       );
-            $r->print(<<"END");
-<h4>$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} $userenv{'generation'}
-END
-            if ($userenv{'permanentemail'} ne '') {
-                $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}.' '.
-                              $newaccesstext{$item}.']'."\n");
-                }
-            } elsif ($showreqotherdom) {
-                foreach my $item (@requestcourses) {
-                    $r->print('<br />['.$lt{$item}.': '.$newaccess{$item}.' '.
-                              $newaccesstext{$item}.']'."\n");
-                }
-            }
-            if ($showtools) {
-                foreach my $item (@usertools) {
-                    $r->print('<br />['.$lt{$item}.': '.$newaccess{$item}.' '.
-                              $newaccesstext{$item}.']'."\n");
-                }
-            }
-            if ($showquota) {
-                $r->print('<br />['.$lt{'disk'}.': '.$oldportfolioquota.' Mb '.
-                          $olddefquotatext.']');
-            }
-            $r->print('</h4>');
+            &display_userinfo($r,undef,\@disporder,\%canshow,\@requestcourses,
+                              \@usertools,\%userenv,\%changed,\%namechanged,\%oldsettings,
+                              \%oldsettingstext,\%newsettings,\%newsettingstext);
         }
         if (@mod_disallowed) {
             my ($rolestr,$contextname);
@@ -2982,7 +2841,7 @@
         $r->print('</a></p>');
     } else {
         my @rolechanges = &update_roles($r,$context);
-        if ($namechanged) {
+        if (keys(%namechanged) > 0) {
             if ($context eq 'course') {
                 if (@userroles > 0) {
                     if ((@rolechanges == 0) || 
@@ -3011,6 +2870,136 @@
     $r->print(&Apache::loncommon::end_page());
 }
 
+sub display_userinfo {
+    my ($r,$changed,$order,$canshow,$requestcourses,$usertools,$userenv,
+        $changedhash,$namechangedhash,$oldsetting,$oldsettingtext,
+        $newsetting,$newsettingtext) = @_;
+    return unless (ref($order) eq 'ARRAY' &&
+                   ref($canshow) eq 'HASH' && 
+                   ref($requestcourses) eq 'ARRAY' && 
+                   ref($usertools) eq 'ARRAY' && 
+                   ref($userenv) eq 'HASH' &&
+                   ref($changedhash) eq 'HASH' &&
+                   ref($oldsetting) eq 'HASH' &&
+                   ref($oldsettingtext) eq 'HASH' &&
+                   ref($newsetting) eq 'HASH' &&
+                   ref($newsettingtext) eq 'HASH');
+    my %lt=&Apache::lonlocal::texthash(
+         'ui'             => 'User Information (unchanged)',
+         'uic'            => 'User Information Changed',
+         'firstname'      => 'First Name',
+         'middlename'     => 'Middle Name',
+         'lastname'       => 'Last Name',
+         'generation'     => 'Generation',
+         'id'             => 'Student/Employee ID',
+         'permanentemail' => 'Permanent e-mail address',
+         'quota'          => 'Disk space allocated to portfolio files',
+         'blog'           => 'Blog Availability',
+         'aboutme'        => 'Personal Information Page Availability',
+         'portfolio'      => 'Portfolio Availability',
+         'official'       => 'Can Request Official Courses',
+         'unofficial'     => 'Can Request Unofficial Courses',
+         'community'      => 'Can Request Communities',
+         'inststatus'     => "Affiliation",
+         'prvs'           => 'Previous Value:',
+         'chto'           => 'Changed To:'
+    );
+    my $title = $lt{'ui'}; 
+    if ($changed) {
+        $title = $lt{'uic'};
+    }
+    $r->print('<h4>'.$title.'</h4>'.
+              &Apache::loncommon::start_data_table().
+              &Apache::loncommon::start_data_table_header_row());
+    if ($changed) {
+        $r->print("<th>&nbsp;</th>\n");
+    }
+    my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
+    foreach my $item (@userinfo) {
+        $r->print("<th>$lt{$item}</th>\n");
+    }
+    foreach my $entry (@{$order}) {
+        if ($canshow->{$entry}) {
+            if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom')) {
+                foreach my $item (@{$requestcourses}) {
+                    $r->print("<th>$lt{$item}</th>\n");
+                }
+            } elsif ($entry eq 'tools') {
+                foreach my $item (@{$usertools}) {
+                    $r->print("<th>$lt{$item}</th>\n");
+                }
+            } else {
+                $r->print("<th>$lt{$entry}</th>\n");
+            }
+        }
+    }
+    $r->print(&Apache::loncommon::end_data_table_header_row().
+             &Apache::loncommon::start_data_table_row());
+    if ($changed) {
+        $r->print('<td><b>'.$lt{'prvs'}.'</b></td>'."\n");
+    }
+    foreach my $item (@userinfo) {
+        $r->print('<td>'.$userenv->{$item}.' </td>'."\n");
+    }
+    foreach my $entry (@{$order}) {
+        if ($canshow->{$entry}) {
+            if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom')) {
+                foreach my $item (@{$requestcourses}) {
+                    $r->print("<td>$oldsetting->{$item} $oldsettingtext->{$item}</td>\n");
+                }
+            } elsif ($entry eq 'tools') {
+                foreach my $item (@{$usertools}) {
+                    $r->print("<td>$oldsetting->{$item} $oldsettingtext->{$item}</td>\n");
+                }
+            } else {
+                $r->print("<td>$oldsetting->{$entry} $oldsettingtext->{$entry} </td>\n");
+            }
+        }
+    }
+    $r->print(&Apache::loncommon::end_data_table_row());
+    if ($changed) {
+        $r->print(&Apache::loncommon::start_data_table_row().
+                  '<td><span class="LC_nobreak"><b>'.$lt{'chto'}.'</b></span></td>'."\n");
+        foreach my $item (@userinfo) {
+            my $value = $env{'form.c'.$item};
+            if ($namechangedhash->{$item}) {
+                $value = '<span class="LC_cusr_emph">'.$value.'</span>';
+            }
+            $r->print("<td>$value </td>\n");
+        }
+        foreach my $entry (@{$order}) {
+            if ($canshow->{$entry}) {
+                if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom')) {
+                    foreach my $item (@{$requestcourses}) {
+                        my $value = $newsetting->{$item}.' '.$newsettingtext->{$item};
+                        if ($changedhash->{$item}) {
+                            $value = '<span class="LC_cusr_emph">'.$value.'</span>';
+                        }
+                        $r->print("<td>$value </td>\n");
+                    }
+                } elsif ($entry eq 'tools') {
+                    foreach my $item (@{$usertools}) {
+                        my $value = $newsetting->{$item}.' '.$newsettingtext->{$item};
+                        if ($changedhash->{$item}) {
+                            $value = '<span class="LC_cusr_emph">'.$value.'</span>';
+                        }
+                        $r->print("<td>$value </td>\n");
+                    }
+                } else {
+                    my $value = $newsetting->{$entry}.' '.$newsettingtext->{$entry};
+                    if ($changedhash->{$entry}) {
+                        $value = '<span class="LC_cusr_emph">'.$value.'</span>';
+                    }
+                    $r->print("<td>$value </td>\n");
+                }
+            }
+        }
+        $r->print(&Apache::loncommon::end_data_table_row());
+    }
+    $r->print(&Apache::loncommon::end_data_table().'<br />');
+    return;
+}
+
 sub tool_changes {
     my ($context,$usertools,$oldaccess,$oldaccesstext,$userenv,$changeHash,
         $changed,$newaccess,$newaccesstext) = @_;
@@ -6592,7 +6581,7 @@
     }
     if ($courseowner ne '') {
         if ($courseowner eq $env{'user.name'}.':'.$env{'user.domain'}) {
-                return 1;
+            return 1;
         }
     }
     return;

--raeburn1267771063--