--- loncom/interface/loncreateuser.pm	2008/07/16 12:32:11	1.249.2.4
+++ loncom/interface/loncreateuser.pm	2008/08/27 22:00:11	1.249.2.7
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.249.2.4 2008/07/16 12:32:11 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.249.2.7 2008/08/27 22:00:11 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -967,7 +967,7 @@ sub display_existing_roles {
                 if (defined($coursedata{'description'})) {
                     $carea=$coursedata{'description'}.
                         '<br />'.&mt('Domain').': '.$coursedom.('&nbsp;'x8).
-     &Apache::loncommon::syllabuswrapper('Syllabus',$coursedir,$coursedom);
+     &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$coursedir,$coursedom);
                     $sortkey.="\0".$coursedata{'description'};
                     $class=$coursedata{'type'};
                 } else {
@@ -1397,30 +1397,22 @@ sub modify_login_block {
 
 sub personal_data_display {
     my ($ccuname,$ccdomain,$newuser,$context,$inst_results,$rolesarray) = @_;
-    my ($output,$showforceid,%userenv,%canmodify,@inststatuses);
+    my ($output,$showforceid,%userenv,%canmodify);
     my @userinfo = ('firstname','middlename','lastname','generation',
                     'permanentemail','id');
     my $rowcount = 0;
     my $editable = 0;
-    if ($context eq 'selfcreate') {
-        if (ref($inst_results) eq 'HASH') {
-            @inststatuses = &get_inststatuses($inst_results);
-            if (@inststatuses == 0) {
-                @inststatuses = ('default');
-            }
-            $rolesarray = \@inststatuses;
-        }
-    }
     if (!$newuser) {
         # Get the users information
         %userenv = &Apache::lonnet::get('environment',
                    ['firstname','middlename','lastname','generation',
                     'permanentemail','id'],$ccdomain,$ccuname);
-    }
-    if ((!$newuser) || ($context eq 'selfcreate')) {
         %canmodify =
             &Apache::lonuserutils::can_modify_userinfo($context,$ccdomain,
                                                        \@userinfo,$rolesarray);
+    } elsif ($context eq 'selfcreate') {
+        %canmodify = &selfcreate_canmodify($context,$ccdomain,\@userinfo,
+                                           $inst_results,$rolesarray);
     }
     my %lt=&Apache::lonlocal::texthash(
                 'pd'             => "Personal Data",
@@ -1429,7 +1421,7 @@ sub personal_data_display {
                 'lastname'       => "Last Name",
                 'generation'     => "Generation",
                 'permanentemail' => "Permanent e-mail address",
-                'id'             => "ID/Student Number",
+                'id'             => "Student/Employee ID",
                 'lg'             => "Login Data"
     );
     my %textboxsize = (
@@ -1506,6 +1498,21 @@ sub personal_data_display {
     }
 }
 
+sub selfcreate_canmodify {
+    my ($context,$dom,$userinfo,$inst_results,$rolesarray) = @_;
+    if (ref($inst_results) eq 'HASH') {
+        my @inststatuses = &get_inststatuses($inst_results);
+        if (@inststatuses == 0) {
+            @inststatuses = ('default');
+        }
+        $rolesarray = \@inststatuses;
+    }
+    my %canmodify =
+        &Apache::lonuserutils::can_modify_userinfo($context,$dom,$userinfo,
+                                                   $rolesarray);
+    return %canmodify;
+}
+
 sub get_inststatuses {
     my ($insthashref) = @_;
     my @inststatuses = ();
@@ -1840,7 +1847,7 @@ sub update_user_data {
                 $env{'form.c'.$item} = $userenv{$item};
             }
         }
-        # Check to see if we can change the ID/student number
+        # Check to see if we can change the Student/Employee ID
         my $forceid = $env{'form.forceid'};
         my $recurseid = $env{'form.recurseid'};
         my (%alerts,%rulematch,%idinst_results,%curr_rules,%got_rules);
@@ -1851,7 +1858,10 @@ sub update_user_data {
             (!$forceid)) {
             if ($env{'form.cid'} ne $uidhash{$env{'form.ccuname'}}) {
                 $env{'form.cid'} = $userenv{'id'};
-                $no_forceid_alert = &mt('New student/employeeID does not match existing ID for this user.').'<br />'.&mt('Change is not permitted without checking the \'Force ID change\' checkbox on the previous page.').'<br />'."\n";        
+                $no_forceid_alert = &mt('New Student/Employee ID does not match existing ID for this user.')
+                                    .'<br />'
+                                    .&mt("Change is not permitted without checking the 'Force ID change' checkbox on the previous page.")
+                                    .'<br />'."\n";        
             }
         }
         if ($env{'form.cid'} ne $userenv{'id'}) {
@@ -1965,7 +1975,7 @@ sub update_user_data {
                              'mddl' => "middle",
                              'lst'  => "last",
 			     'gen'  => "generation",
-                             'id'   => "ID/Student number",
+                             'id'   => "Student/Employee ID",
                              'mail' => "permanent e-mail",
                              'disk' => "disk space allocated to portfolio files",
                              'prvs' => "Previous",
@@ -2048,7 +2058,7 @@ END
             # They did not want to change the users name or quota but we can
             # still tell them what the name and quota are 
 	    my %lt=&Apache::lonlocal::texthash(
-                           'id'   => "ID/Student number",
+                           'id'   => "Student/Employee ID",
                            'mail' => "Permanent e-mail",
                            'disk' => "Disk space allocated to user's portfolio files",
 					       );
@@ -2091,8 +2101,10 @@ END
             $r->print('<span class="LC_cusr_emph">'.$rolestr.'</span><br />'.
                       &mt('Contact your <a href="[_1]">helpdesk</a> for more information.',"javascript:helpMenu('display')").'<br />');
         }
-        $r->print($no_forceid_alert.
-                  &Apache::lonuserutils::print_namespacing_alerts($env{'form.ccdomain'},\%alerts,\%curr_rules));
+        $r->print('<span class="LC_warning">'
+                  .$no_forceid_alert
+                  .&Apache::lonuserutils::print_namespacing_alerts($env{'form.ccdomain'},\%alerts,\%curr_rules)
+                  .'</span>');
     }
     if ($env{'form.action'} eq 'singlestudent') {
         &enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser,$context);
@@ -3597,9 +3609,9 @@ sub visible_in_cat {
                    dc_chgcat => 'Ask a domain coordinator to change the category assigned to the course, as the one currently assigned is no longer used in the domain',
                    dc_addcat => 'Ask a domain coordinator to assign a category to the course.',
     );
-    $visactions{'unhide'} = &mt('Use [_1]Set course environment[_2] to change the "Exclude from course catalog" setting.','<a href="/adm/parmset?action=crsenv">','</a>');
-    $visactions{'chgcat'} = &mt('Use [_1]Set course environment[_2] to change the category assigned to the course, as the one currently assigned is no longer used in the domain.','<a href="/adm/parmset?action=crsenv">','</a>');
-    $visactions{'addcat'} = &mt('Use [_1]Set course environment[_2] to assign a category to the course.','<a href="/adm/parmset?action=crsenv">','</a>');
+    $visactions{'unhide'} = &mt('Use [_1]Set course environment[_2] to change the "Exclude from course catalog" setting.','"<a href="/adm/parmset?action=crsenv">','</a>"');
+    $visactions{'chgcat'} = &mt('Use [_1]Set course environment[_2] to change the category assigned to the course, as the one currently assigned is no longer used in the domain.','"<a href="/adm/parmset?action=crsenv">','</a>"');
+    $visactions{'addcat'} = &mt('Use [_1]Set course environment[_2] to assign a category to the course.','"<a href="/adm/parmset?action=crsenv">','</a>"');
     if (ref($domconf{'coursecategories'}) eq 'HASH') {
         if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
             $settable{'togglecats'} = 1;
@@ -3609,11 +3621,11 @@ sub visible_in_cat {
         }
         $cathash = $domconf{'coursecategories'}{'cats'};
     }
-    if ($settable{'togglecats'} && $settable{'categories'}) {
+    if ($settable{'togglecats'} && $settable{'categorize'}) {
         $cansetvis = &mt('You are able to both assign a course category and choose to exclude this course from the catalog.');
     } elsif ($settable{'togglecats'}) {
         $cansetvis = &mt('You are able to choose to exclude this course from the catalog, but only a Domain Coordinator may assign a course category.');
-    } elsif ($settable{'categories'}) {
+    } elsif ($settable{'categorize'}) {
         $cansetvis = &mt('You may assign a course category, but only a Domain Coordinator may choose to exclude this course from the catalog.');
     } else {
         $cansetvis = &mt('Only a Domain Coordinator may assign a course category or choose to exclude this course from the catalog.');
@@ -3667,7 +3679,7 @@ sub visible_in_cat {
                         }
                     }
                     if (!$matched) {
-                        if ($settable{'categories'}) {
+                        if ($settable{'categorize'}) {
                             push(@vismsgs,'chgcat');
                         } else {
                             push(@vismsgs,'dc_chgcat');
@@ -3680,7 +3692,7 @@ sub visible_in_cat {
         if (ref($cathash) eq 'HASH') {
             if ((keys(%{$cathash}) > 1) ||
                 (keys(%{$cathash}) == 1) && ($cathash->{'instcode::0'} eq '')) {
-                if ($settable{'categories'}) {
+                if ($settable{'categorize'}) {
                     push(@vismsgs,'addcat');
                 } else {
                     push(@vismsgs,'dc_addcat');
@@ -3738,13 +3750,14 @@ sub selfenroll_inst_types {
                 $output .= '</tr><tr>';
             }
             if (defined($usertypes->{$type})) {
+                my $esc_type = &escape($type);
                 $output .= '<td><span class="LC_nobreak"><label><input type = "checkbox" value="'.
-                           $type.'" ';
+                           $esc_type.'" ';
                 if (ref($currinsttypes) eq 'ARRAY') {
                     if (@{$currinsttypes} > 0) {
                         if (grep(/^any$/,@{$currinsttypes})) {
                             $output .= 'checked="checked"';
-                        } elsif (grep(/^\Q$type\E$/,@{$currinsttypes})) {
+                        } elsif (grep(/^\Q$esc_type\E$/,@{$currinsttypes})) {
                             $output .= 'checked="checked"';
                         }
                     } else {
@@ -4734,8 +4747,9 @@ sub update_selfenroll_config {
                             my $othervalue = 'any';
                             if ((ref($types) eq 'ARRAY') && (ref($usertypes) eq 'HASH')) {
                                 if (@{$types} > 0) {
+                                    my @esc_types = map { &escape($_); } @{$types};
                                     $othervalue = 'other';
-                                    $typestr = join(',',(@{$types},$othervalue));
+                                    $typestr = join(',',(@esc_types,$othervalue));
                                 }
                                 $typestr = $othervalue;
                             } else {