--- loncom/interface/loncreateuser.pm	2007/07/30 00:31:27	1.162
+++ loncom/interface/loncreateuser.pm	2007/08/02 01:02:56	1.166
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.162 2007/07/30 00:31:27 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.166 2007/08/02 01:02:56 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -204,7 +204,7 @@ sub print_username_entry_form {
     my ($jsback,$elements) = &crumb_utilities();
 
     my $jscript = &Apache::loncommon::studentbrowser_javascript()."\n".
-        '<script type"text/javascript">'."\n".
+        '<script type="text/javascript">'."\n".
         &Apache::lonhtmlcommon::set_form_elements($elements->{$formtoset}).
         '</script>'."\n";
 
@@ -216,7 +216,7 @@ sub print_username_entry_form {
 				       $jscript,{'add_entries' => \%loaditems,});
    &Apache::lonhtmlcommon::add_breadcrumb
      ({href=>"javascript:backPage(document.crtuser)",
-       text=>"User/custom role search",
+       text=>"User modify/custom role",
        faq=>282,bug=>'Instructor Interface',});
 
     my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management');
@@ -232,6 +232,7 @@ sub print_username_entry_form {
                     'ecrp' => "Edit Custom Role Privileges",
                     'nr'   => "Name of Role",
                     'cre'  => "Custom Role Editor",
+                    'mod'  => "to add/modify roles",
 				       );
     my $help = &Apache::loncommon::help_open_menu(undef,undef,282,'Instructor Interface');
     my $helpsiur=&Apache::loncommon::help_open_topic('Course_Change_Privileges');
@@ -244,7 +245,7 @@ sub print_username_entry_form {
 $start_page
 $crumbs
 <h2>$lt{siur}$helpsiur</h2>
-<h3>$lt{'srch'} $sellink</h3>
+<h3>$lt{'srch'} $sellink $lt{'mod'}</h3>
 $response");
     $r->print(&entry_form($defdom,$srch,$forcenewuser));
     if (&Apache::lonnet::allowed('mcr','/')) {
@@ -328,7 +329,7 @@ $jsback
 ENDSCRIPT
 
     my %lt=&Apache::lonlocal::texthash(
-                                       'srch'           => "User Search",
+                                       'srch'           => "User Search to add/modify roles of",
                                        'username'       => "username",
                                        'domain'         => "domain",
                                        'lastname'       => "last name",
@@ -338,7 +339,7 @@ ENDSCRIPT
     $r->print(&Apache::loncommon::start_page('Create Users, Change User Privileges',$jscript));
     &Apache::lonhtmlcommon::add_breadcrumb
         ({href=>"javascript:backPage(document.usersrchform,'','')",
-          text=>"User/custom role search",
+          text=>"User modify/custom role edit",
           faq=>282,bug=>'Instructor Interface',},
          {href=>"javascript:backPage(document.usersrchform,'get_user_info','select')",
           text=>"Select User",
@@ -346,7 +347,7 @@ ENDSCRIPT
     $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management'));
     $r->print("<b>$lt{'srch'}</b><br />");
     $r->print(&entry_form($srch->{'srchdomain'},$srch));
-    $r->print('<h3>'.&mt('Select a user').'</h3>');
+    $r->print('<h3>'.&mt('Select a user to add/modify roles of').'</h3>');
     $r->print('<form name="usersrchform" method="post">'.
               &Apache::loncommon::start_data_table()."\n".
               &Apache::loncommon::start_data_table_header_row()."\n".
@@ -630,7 +631,7 @@ ENDSECCODE
 				       $js,{'add_entries' => \%loaditem,});
     &Apache::lonhtmlcommon::add_breadcrumb
      ({href=>"javascript:backPage(document.cu)",
-       text=>"User/custom role search",
+       text=>"User modify/custom role edit",
        faq=>282,bug=>'Instructor Interface',});
 
     if ($env{'form.phase'} eq 'userpicked') {
@@ -1230,7 +1231,7 @@ sub update_user_data {
     $r->print(&Apache::loncommon::start_page($title,$jscript));
     &Apache::lonhtmlcommon::add_breadcrumb
        ({href=>"javascript:backPage(document.userupdate)",
-         text=>"User/custom role search",
+         text=>"User modify/custom role edit",
          faq=>282,bug=>'Instructor Interface',});
     if ($env{'form.prevphase'} eq 'userpicked') {
         &Apache::lonhtmlcommon::add_breadcrumb
@@ -1307,15 +1308,13 @@ sub update_user_data {
 	    $r->print($error.&mt('Invalid login mode or password').$end);    
 	    return;
     }
+
+
+    $r->print('<h2>'.&mt('User [_1] in domain [_2]',
+			 $env{'form.ccuname'}, $env{'form.ccdomain'}).'</h2>');
+
     if ($env{'form.makeuser'}) {
-        # Create a new user
-	my %lt=&Apache::lonlocal::texthash(
-                    'cru'  => "Creating user",                    
-                    'id'   => "in domain"
-					   );
-	$r->print(<<ENDNEWUSERHEAD);
-<h3>$lt{'cru'} "$env{'form.ccuname'}" $lt{'id'} "$env{'form.ccdomain'}"</h3>
-ENDNEWUSERHEAD
+	$r->print('<h3>'.&mt('Creating new account.').'</h3>');
         # Check for the authentication mode and password
         if (! $amode || ! $genpwd) {
 	    $r->print($error.&mt('Invalid login mode or password').$end);    
@@ -1348,13 +1347,6 @@ ENDNEWUSERHEAD
     } elsif (($env{'form.login'} ne 'nochange') &&
              ($env{'form.login'} ne ''        )) {
 	# Modify user privileges
-    my %lt=&Apache::lonlocal::texthash(
-                    'usr'  => "User",                    
-                    'id'   => "in domain"
-				       );
-	$r->print(<<ENDMODIFYUSERHEAD);
-<h2>$lt{'usr'} "$env{'form.ccuname'}" $lt{'id'} "$env{'form.ccdomain'}"</h2>
-ENDMODIFYUSERHEAD
         if (! $amode || ! $genpwd) {
 	    $r->print($error.'Invalid login mode or password'.$end);    
 	    return;
@@ -1518,16 +1510,11 @@ END
             # They did not want to change the users name but we can
             # still tell them what the name is
 	    my %lt=&Apache::lonlocal::texthash(
-                           'usr'  => "User",                    
-                           'id'   => "in domain",
-                           'gen'  => "Generation",
                            'mail' => "Permanent e-mail",
                            'disk' => "Disk space allocated to user's portfolio files",
 					       );
             $r->print(<<"END");
-<h2>$lt{'usr'} "$env{'form.ccuname'}" $lt{'id'} "$env{'form.ccdomain'}"</h2>
-<h4>$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} </h4>
-<h4>$lt{'gen'}: $userenv{'generation'}</h4>
+<h4>$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} $userenv{'generation'}</h4>
 <h4>$lt{'mail'}: $userenv{'permanentemail'}</h4>
 END
             if ($putresult eq 'ok') {
@@ -1755,7 +1742,7 @@ END
     } # End of foreach (keys(%env))
 # Flush the course logs so reverse user roles immediately updated
     &Apache::lonnet::flushcourselogs();
-    $r->print('<p><a href="/adm/createuser">Create/Modify Another User</a></p>');
+    $r->print('<p><a href="/adm/createuser">'.&mt('Create/Modify Another User').'</a></p>');
     $r->print('<form name="userupdate" method="post" />'."\n");
     foreach my $item ('srchby','srchin','srchtype','srchterm','srchdomain','ccuname','ccdomain') {
         $r->print('<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n");
@@ -1897,7 +1884,7 @@ sub custom_role_editor {
     $r->print(&Apache::loncommon::start_page('Custom Role Editor',$head_script));
    &Apache::lonhtmlcommon::add_breadcrumb
      ({href=>"javascript:backPage(document.form1,'','')",
-       text=>"User/custom role search",
+       text=>"User modify/custom role edit",
        faq=>282,bug=>'Instructor Interface',},
       {href=>"javascript:backPage(document.form1,'','')",
          text=>"Edit custom role",
@@ -2037,7 +2024,7 @@ sub set_custom_role {
     $r->print(&Apache::loncommon::start_page('Save Custom Role'),$jscript);
     &Apache::lonhtmlcommon::add_breadcrumb
         ({href=>"javascript:backPage(document.customresult,'','')",
-          text=>"User/custom role search",
+          text=>"User modify/custom role edit",
           faq=>282,bug=>'Instructor Interface',},
          {href=>"javascript:backPage(document.customresult,'selected_custom_edit','')",
           text=>"Edit custom role",
@@ -2136,7 +2123,6 @@ sub handler {
            if ($env{'form.phase'} eq 'get_user_info') {
                my ($state,$response,$forcenewuser,$results) = 
                    &user_search_result($srch);
-               print STDERR "Got $state,$response,$forcenewuser\n";
                if ($state eq 'select') {
                    &print_user_selection_page($r,$response,$srch,$results);
                } elsif ($state eq 'modify') {
@@ -2183,7 +2169,6 @@ sub handler {
 #-------------------------------------------------- functions for &phase_two
 sub user_search_result {
     my ($srch) = @_;
-    my @alldomains = sort(&Apache::lonnet::all_domains());
     my %allhomes;
     my %inst_matches;
     my %srch_results;
@@ -2203,7 +2188,7 @@ sub user_search_result {
     }
     if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'instd')) {
         if (($srch->{'srchdomain'} eq '') || 
-            (!(grep/^\Q$srch->{'srchdomain'}\E$/,@alldomains))) {
+	    ! (&Apache::lonnet::domain($srch->{'srchdomain'}))) {
             $response = &mt('You must specify a valid domain when searching in a domain or institutional directory.')
         }
     }
@@ -2220,7 +2205,7 @@ sub user_search_result {
         }
     }
     if ($response ne '') {
-        return ($state,$response);
+        return ($state,'<span class="LC_warning">'.$response.'</span>');
     }
     if ($srch->{'srchby'} eq 'uname') {
         if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'crs')) {
@@ -2345,11 +2330,11 @@ sub directorysrch_check {
                                              ['directorysrch'],$srch->{'srchdomain'});
     if (ref($dom_inst_srch{'directorysrch'}) eq 'HASH') {
         if (!$dom_inst_srch{'directorysrch'}{'available'}) {
-            return &mt('Directory search unavailable in domain: [_1]',$srch->{'srchdomain'}); 
+            return &mt('Institutional directory search unavailable in domain: [_1]',$srch->{'srchdomain'}); 
         }
         if ($dom_inst_srch{'directorysrch'}{'localonly'}) {
             if ($env{'request.role.domain'} ne $srch->{'srchdomain'}) {
-                return &mt('Directory search in domain: [_1] is only allowed for users with a current role in the domain.',$srch->{'srchdomain'}); 
+                return &mt('Insitutional directory search in domain: [_1] is only allowed for users with a current role in the domain.',$srch->{'srchdomain'}); 
             }
             my @usertypes = split(/:/,$env{'environment.inststatus'});
             if (!@usertypes) {
@@ -2445,7 +2430,7 @@ sub build_search_response {
             $state = 'modify';
             $response = &mt("$single{$srch->{'srchtype'}} was found for this $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'});
         } else {
-            $response = &mt("$nomatch{$srch->{'srchtype'}} found for this $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'});
+            $response = '<span class="LC_warning">'.&mt("$nomatch{$srch->{'srchtype'}} found for this $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'}).'</span>';
             if ($srch->{'srchin'} ne 'alc') {
                 $forcenewuser = 1;
                 my $cansrchinst = 0; 
@@ -2467,7 +2452,7 @@ sub build_search_response {
                         }
                     }
                 }
-                $response .= '<br />'.&mt("To add as a new user:").'<ul><li>'.&mt("Enter the proposed username in the <i>'Search for'</i> box").'</li><li>'.&mt("Set <i>'Make new user if no match found</i>' to <b>Yes</b>").'</li><li>'.&mt("Click <i>'Search'</i>").'</li></ul>'.&mt("Note: you can only create new users in the domain of your current role -".$env{'request.role.domain'}).'<br /><br />';
+                $response .= '<br />'.&mt("To add as a new user:").'<ul><li>'.&mt("Enter the proposed username in the <i>'Search for'</i> box").'</li><li>'.&mt("Set <i>'Make new user if no match found</i>' to <b>Yes</b>").'</li><li>'.&mt("Click <i>'Search'</i>").'</li></ul>'.&mt("Note: you can only create new users in the domain of your current role - [_1]",$env{'request.role.domain'}).'<br /><br />';
             }
         }
     }