Diff for /loncom/interface/loncreateuser.pm between versions 1.180 and 1.184

version 1.180, 2007/08/31 03:21:27 version 1.184, 2007/09/12 23:26:25
Line 699  ENDFORMINFO Line 699  ENDFORMINFO
         if (($instsrch->{'srchterm'} ne '') && ($instsrch->{'srchdomain'} ne '')) {          if (($instsrch->{'srchterm'} ne '') && ($instsrch->{'srchdomain'} ne '')) {
             $newuser = $instsrch->{'srchterm'}.':'.$instsrch->{'srchdomain'};              $newuser = $instsrch->{'srchterm'}.':'.$instsrch->{'srchdomain'};
         }          }
         my (%dirsrch_results,%inst_results);          my (%dirsrch_results,%inst_results,$dirsrchres);
         if ($newuser) {          if ($newuser) {
             if (&directorysrch_check($instsrch) eq 'ok') {              if (&directorysrch_check($instsrch) eq 'ok') {
                 %dirsrch_results = &Apache::lonnet::inst_directory_query($instsrch);                  ($dirsrchres,%dirsrch_results) = &Apache::lonnet::inst_directory_query($instsrch);
                 if (ref($dirsrch_results{$newuser}) eq 'HASH') {                   if ($dirsrchres eq 'ok') {
                     %inst_results = %{$dirsrch_results{$newuser}};                      if (ref($dirsrch_results{$newuser}) eq 'HASH') { 
                           %inst_results = %{$dirsrch_results{$newuser}};
                       }
                 }                  }
             }              }
         }          }
Line 1357  sub update_user_data { Line 1359  sub update_user_data {
     ($env{'form.ccdomain'},$env{'form.ccuname'},$env{'form.cstid'},      ($env{'form.ccdomain'},$env{'form.ccuname'},$env{'form.cstid'},
              $amode,$genpwd,$env{'form.cfirst'},               $amode,$genpwd,$env{'form.cfirst'},
              $env{'form.cmiddle'},$env{'form.clast'},$env{'form.cgen'},               $env{'form.cmiddle'},$env{'form.clast'},$env{'form.cgen'},
              undef,$desiredhost               undef,$desiredhost,$env{'form.cemail'}
      );       );
  $r->print(&mt('Generating user').': '.$result);   $r->print(&mt('Generating user').': '.$result);
         my $home = &Apache::lonnet::homeserver($env{'form.ccuname'},          my $home = &Apache::lonnet::homeserver($env{'form.ccuname'},
Line 2211  sub user_search_result { Line 2213  sub user_search_result {
     my %allhomes;      my %allhomes;
     my %inst_matches;      my %inst_matches;
     my %srch_results;      my %srch_results;
     my ($response,$currstate,$forcenewuser);      my ($response,$currstate,$forcenewuser,$dirsrchres);
     $srch->{'srchterm'} =~ s/^\s+//;      $srch->{'srchterm'} =~ s/\s+/ /g;
     $srch->{'srchterm'} =~ s/\s+$//;  
   
     if ($srch->{'srchby'} !~ /^(uname|lastname|lastfirst)$/) {      if ($srch->{'srchby'} !~ /^(uname|lastname|lastfirst)$/) {
         $response = &mt('Invalid search.');          $response = &mt('Invalid search.');
     }      }
Line 2227  sub user_search_result { Line 2227  sub user_search_result {
     if ($srch->{'srchterm'} eq '') {      if ($srch->{'srchterm'} eq '') {
         $response = &mt('You must enter a search term.');          $response = &mt('You must enter a search term.');
     }      }
       if ($srch->{'srchterm'} =~ /^\s+$/) {
           $response = &mt('Your search term must contain more than just spaces.');
       }
     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 '') || 
     ! (&Apache::lonnet::domain($srch->{'srchdomain'}))) {      ! (&Apache::lonnet::domain($srch->{'srchdomain'}))) {
Line 2324  sub user_search_result { Line 2327  sub user_search_result {
         } elsif ($srch->{'srchin'} eq 'alc') {          } elsif ($srch->{'srchin'} eq 'alc') {
             $currstate = 'query';              $currstate = 'query';
         } elsif ($srch->{'srchin'} eq 'instd') {          } elsif ($srch->{'srchin'} eq 'instd') {
             %srch_results = &Apache::lonnet::inst_directory_query($srch);              ($dirsrchres,%srch_results) = &Apache::lonnet::inst_directory_query($srch);
             ($currstate,$response,$forcenewuser) =               if ($dirsrchres eq 'ok') {
                 &build_search_response($srch,%srch_results);                   ($currstate,$response,$forcenewuser) = 
                       &build_search_response($srch,%srch_results);
               } else {
                   my $showdom = &display_domain_info($srch->{'srchdomain'});
                   $response = '<span class="LC_warning">'.
                       &mt('Institutional directory search is not available in domain: [_1]',$showdom).
                       '</span><br />'.
                       &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').
                       '<br /><br />'; 
               }
         }          }
     } else {      } else {
         if ($srch->{'srchin'} eq 'dom') {          if ($srch->{'srchin'} eq 'dom') {
Line 2388  sub user_search_result { Line 2400  sub user_search_result {
         } elsif ($srch->{'srchin'} eq 'alc') {          } elsif ($srch->{'srchin'} eq 'alc') {
             $currstate = 'query';              $currstate = 'query';
         } elsif ($srch->{'srchin'} eq 'instd') {          } elsif ($srch->{'srchin'} eq 'instd') {
             %srch_results = &Apache::lonnet::inst_directory_query($srch);               ($dirsrchres,%srch_results) = &Apache::lonnet::inst_directory_query($srch); 
             ($currstate,$response,$forcenewuser) =               if ($dirsrchres eq 'ok') {
                 &build_search_response($srch,%srch_results);                  ($currstate,$response,$forcenewuser) = 
                       &build_search_response($srch,%srch_results);
               } else {
                   my $showdom = &display_domain_info($srch->{'srchdomain'});                $response = '<span class="LC_warning">'.
                       &mt('Institutional directory search is not available in domain: [_1]',$showdom).
                       '</span><br />'.
                       &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').
                       '<br /><br />';
               }
         }          }
     }      }
     return ($currstate,$response,$forcenewuser,\%srch_results);      return ($currstate,$response,$forcenewuser,\%srch_results);
Line 2549  sub build_search_response { Line 2569  sub build_search_response {
                 }                  }
             }              }
             if (!($srch->{'srchby'} eq 'uname' && $srch->{'srchin'} eq 'dom' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchdomain'} eq $env{'request.role.domain'})) {              if (!($srch->{'srchby'} eq 'uname' && $srch->{'srchin'} eq 'dom' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchdomain'} eq $env{'request.role.domain'})) {
                 $response .= '<br />'.&mt("<b>To add a new user</b> (you can only create new users in your current role's domain - <span class=\"LC_cusr_emph\">[_1]</span>) ...",$env{'request.role.domain'}).'<ul><li>'.&mt("Set '<span class=\"LC_cusr_emph\">Make new user if no match found</span>' to '<b>Yes</b>'").'</li><li>'.&mt('Provide the proposed username').'</li><li>'.&mt('Search').'</li></ul><br />';                  my $showdom = &display_domain_info($env{'request.role.domain'}); 
                   $response .= '<br /><br />'.&mt("<b>To add a new user</b> (you can only create new users in your current role's domain - <span class=\"LC_cusr_emph\">[_1]</span>):",$env{'request.role.domain'}).'<ul><li>'.&mt("Set 'Domain/institution to search' to: <span class=\"LC_cusr_emph\">[_1]</span>",$showdom).'<li>'.&mt("Set 'Search criteria' to: <span class=\"LC_cusr_emph\">'username is ...... in selected LON-CAPA domain'").'</span></li><li>'.&mt('Provide the proposed username').'</li><li>'.&mt('Search').'</li></ul><br />';
             }              }
         }          }
     }      }

Removed from v.1.180  
changed lines
  Added in v.1.184


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