Diff for /loncom/interface/loncreateuser.pm between versions 1.162 and 1.163

version 1.162, 2007/07/30 00:31:27 version 1.163, 2007/07/30 22:44:04
Line 1755  END Line 1755  END
     } # End of foreach (keys(%env))      } # End of foreach (keys(%env))
 # Flush the course logs so reverse user roles immediately updated  # Flush the course logs so reverse user roles immediately updated
     &Apache::lonnet::flushcourselogs();      &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");      $r->print('<form name="userupdate" method="post" />'."\n");
     foreach my $item ('srchby','srchin','srchtype','srchterm','srchdomain','ccuname','ccdomain') {      foreach my $item ('srchby','srchin','srchtype','srchterm','srchdomain','ccuname','ccdomain') {
         $r->print('<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n");          $r->print('<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n");
Line 2136  sub handler { Line 2136  sub handler {
            if ($env{'form.phase'} eq 'get_user_info') {             if ($env{'form.phase'} eq 'get_user_info') {
                my ($state,$response,$forcenewuser,$results) =                  my ($state,$response,$forcenewuser,$results) = 
                    &user_search_result($srch);                     &user_search_result($srch);
                print STDERR "Got $state,$response,$forcenewuser\n";  
                if ($state eq 'select') {                 if ($state eq 'select') {
                    &print_user_selection_page($r,$response,$srch,$results);                     &print_user_selection_page($r,$response,$srch,$results);
                } elsif ($state eq 'modify') {                 } elsif ($state eq 'modify') {
Line 2183  sub handler { Line 2182  sub handler {
 #-------------------------------------------------- functions for &phase_two  #-------------------------------------------------- functions for &phase_two
 sub user_search_result {  sub user_search_result {
     my ($srch) = @_;      my ($srch) = @_;
     my @alldomains = sort(&Apache::lonnet::all_domains());  
     my %allhomes;      my %allhomes;
     my %inst_matches;      my %inst_matches;
     my %srch_results;      my %srch_results;
Line 2203  sub user_search_result { Line 2201  sub user_search_result {
     }      }
     if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'instd')) {      if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'instd')) {
         if (($srch->{'srchdomain'} eq '') ||           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.')              $response = &mt('You must specify a valid domain when searching in a domain or institutional directory.')
         }          }
     }      }
Line 2220  sub user_search_result { Line 2218  sub user_search_result {
         }          }
     }      }
     if ($response ne '') {      if ($response ne '') {
         return ($state,$response);          return ($state,'<span class="LC_warning">'.$response.'</span>');
     }      }
     if ($srch->{'srchby'} eq 'uname') {      if ($srch->{'srchby'} eq 'uname') {
         if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'crs')) {          if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'crs')) {
Line 2345  sub directorysrch_check { Line 2343  sub directorysrch_check {
                                              ['directorysrch'],$srch->{'srchdomain'});                                               ['directorysrch'],$srch->{'srchdomain'});
     if (ref($dom_inst_srch{'directorysrch'}) eq 'HASH') {      if (ref($dom_inst_srch{'directorysrch'}) eq 'HASH') {
         if (!$dom_inst_srch{'directorysrch'}{'available'}) {          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 ($dom_inst_srch{'directorysrch'}{'localonly'}) {
             if ($env{'request.role.domain'} ne $srch->{'srchdomain'}) {              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'});              my @usertypes = split(/:/,$env{'environment.inststatus'});
             if (!@usertypes) {              if (!@usertypes) {
Line 2445  sub build_search_response { Line 2443  sub build_search_response {
             $state = 'modify';              $state = 'modify';
             $response = &mt("$single{$srch->{'srchtype'}} was found for this $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'});              $response = &mt("$single{$srch->{'srchtype'}} was found for this $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'});
         } else {          } 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') {              if ($srch->{'srchin'} ne 'alc') {
                 $forcenewuser = 1;                  $forcenewuser = 1;
                 my $cansrchinst = 0;                   my $cansrchinst = 0; 
Line 2467  sub build_search_response { Line 2465  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 />';
             }              }
         }          }
     }      }

Removed from v.1.162  
changed lines
  Added in v.1.163


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>