Diff for /loncom/interface/loncreateuser.pm between versions 1.179 and 1.186

version 1.179, 2007/08/26 21:09:43 version 1.186, 2007/09/18 23:57:15
Line 420  sub print_user_query_page { Line 420  sub print_user_query_page {
   
 sub print_user_modification_page {  sub print_user_modification_page {
     my ($r,$ccuname,$ccdomain,$srch,$response) = @_;      my ($r,$ccuname,$ccdomain,$srch,$response) = @_;
     unless (($ccuname) && ($ccdomain)) {      if (($ccuname eq '') || ($ccdomain eq '')) {
  &print_username_entry_form($r);          my $usermsg = &mt('No username and/or domain provided.'); 
    &print_username_entry_form($r,$usermsg);
         return;          return;
     }      }
       my ($instsrch,$rulematch,$rules,%inst_results);
       my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);
       if ($uhome eq 'no_host') {
           $instsrch =
                         {
                            srchin => 'instd',
                            srchby => 'uname',
                            srchtype => 'exact',
                            srchterm => $ccuname,
                            srchdomain => $ccdomain,
                          };
           (my $usercheckmsg,$rulematch,$rules,%inst_results) = 
               &Apache::loncommon::username_rule_check($instsrch,'new');
           if ($usercheckmsg) {
               &print_username_entry_form($r,$usercheckmsg);
               return;
           }
       }
     if ($response) {      if ($response) {
         $response = '<br />'.$response          $response = '<br />'.$response
     }      }
Line 675  ENDSECCODE Line 694  ENDSECCODE
 <input type="hidden" name="pres_type"   value="" />  <input type="hidden" name="pres_type"   value="" />
 <input type="hidden" name="pres_marker" value="" />  <input type="hidden" name="pres_marker" value="" />
 ENDFORMINFO  ENDFORMINFO
     my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);  
     my %inccourses;      my %inccourses;
     foreach my $key (keys(%env)) {      foreach my $key (keys(%env)) {
  if ($key=~/^user\.priv\.cm\.\/($match_domain)\/($match_username)/) {   if ($key=~/^user\.priv\.cm\.\/($match_domain)\/($match_username)/) {
Line 683  ENDFORMINFO Line 701  ENDFORMINFO
         }          }
     }      }
     if ($uhome eq 'no_host') {      if ($uhome eq 'no_host') {
         my $newuser;  
         my $instsrch = {  
                          srchin => 'instd',  
                          srchby => 'uname',  
                          srchtype => 'exact',  
                        };  
         if ($env{'form.phase'} eq 'userpicked') {  
             $instsrch->{'srchterm'} = $env{'form.seluname'};  
             $instsrch->{'srchdomain'} = $env{'form.seludom'};  
         } else {  
             $instsrch->{'srchterm'} = $ccuname;  
             $instsrch->{'srchdomain'} = $ccdomain,  
         }  
         if (($instsrch->{'srchterm'} ne '') && ($instsrch->{'srchdomain'} ne '')) {  
             $newuser = $instsrch->{'srchterm'}.':'.$instsrch->{'srchdomain'};  
         }  
         my (%dirsrch_results,%inst_results);  
         if ($newuser) {  
             if (&directorysrch_check($instsrch) eq 'ok') {  
                 %dirsrch_results = &Apache::lonnet::inst_directory_query($instsrch);  
                 if (ref($dirsrch_results{$newuser}) eq 'HASH') {   
                     %inst_results = %{$dirsrch_results{$newuser}};  
                 }  
             }  
         }  
         my $home_server_list=          my $home_server_list=
             '<option value="default" selected>default</option>'."\n".              '<option value="default" selected>default</option>'."\n".
                 &Apache::loncommon::home_server_option_list($ccdomain);                  &Apache::loncommon::home_server_option_list($ccdomain);
                   
  my %lt=&Apache::lonlocal::texthash(   my %lt=&Apache::lonlocal::texthash(
                     'cnu'  => "Create New User",                      'cnu'            => "Create New User",
                     'nu'   => "New User",                      'nu'             => "New User",
                     'id'   => "in domain",                      'ind'            => "in domain",
                     'pd'   => "Personal Data",                      'pd'             => "Personal Data",
                     'fn'   => "First Name",                      'firstname'      => "First Name",
                     'mn'   => "Middle Name",                      'middlename'     => "Middle Name",
                     'ln'   => "Last Name",                      'lastname'       => "Last Name",
                     'gen'  => "Generation",                      'generation'     => "Generation",
                     'mail' => "Permanent e-mail address",                      'permanentemail' => "Permanent e-mail address",
                     'idsn' => "ID/Student Number",                      'id'             => "ID/Student Number",
                     'hs'   => "Home Server",                      'hs'             => "Home Server",
                     'lg'   => "Login Data"                      'lg'             => "Login Data"
        );         );
           my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
           my %textboxsize = (
                              firstname      => '15',
                              middlename     => '15',
                              lastname       => '15',
                              generation     => '5',
                              permanentemail => '25',
                              id             => '15',
                             );
           my %element   = (
                              firstname      => 'cfirst', 
                              middlename     => 'cmiddle',
                              lastname       => 'clast',
                              generation     => 'cgen',
                              permanentemail => 'cemail',
                              id             => 'cstid',
                             );
         my $portfolioform;          my $portfolioform;
         if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {          if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {
             # Current user has quota modification privileges              # Current user has quota modification privileges
Line 733  ENDFORMINFO Line 743  ENDFORMINFO
         }          }
  my $genhelp=&Apache::loncommon::help_open_topic('Generation');   my $genhelp=&Apache::loncommon::help_open_topic('Generation');
         &initialize_authen_forms();          &initialize_authen_forms();
  $r->print(<<ENDNEWUSER);   $r->print(<<ENDTITLE);
 $start_page  $start_page
 $crumbs  $crumbs
 <h1>$lt{'cnu'}</h1>  <h1>$lt{'cnu'}</h1>
 $response  $response
 $forminfo  $forminfo
 <h2>$lt{'nu'} "$ccuname" $lt{'id'} $ccdomain</h2>  <h2>$lt{'nu'} "$ccuname" $lt{'ind'} $ccdomain</h2>
 <script type="text/javascript" language="Javascript">  <script type="text/javascript" language="Javascript">
 $loginscript  $loginscript
 </script>  </script>
 <input type='hidden' name='makeuser' value='1' />  <input type='hidden' name='makeuser' value='1' />
 <h3>$lt{'pd'}</h3>  <h3>$lt{'pd'}</h3>
 <p>  <p>
 <table>  ENDTITLE
 <tr><td>$lt{'fn'}  </td>          $r->print(&Apache::lonhtmlcommon::start_pick_box());
     <td><input type="text" name="cfirst" size="15" value="$inst_results{'firstname'}" /></td></tr>          foreach my $item (@userinfo) {
 <tr><td>$lt{'mn'} </td>               my $rowtitle = $lt{$item};
     <td><input type="text" name="cmiddle" size="15" value="$inst_results{'middlename'}" /></td></tr>              if ($item eq 'generation') {
 <tr><td>$lt{'ln'}   </td>                  $rowtitle = $genhelp.$rowtitle;
     <td><input type="text" name="clast" size="15" value="$inst_results{'lastname'}" /></td></tr>              }
 <tr><td>$lt{'gen'}$genhelp</td>              $r->print(&Apache::lonhtmlcommon::row_title($rowtitle,undef,'LC_oddrow_value')."\n");
     <td><input type="text" name="cgen" size="5" value="$inst_results{'generation'}" /></td></tr>              if ($inst_results{$item} ne '') {
 <tr><td>$lt{'mail'}</td>                  $r->print('<input type="hidden" name="'.$element{$item}.'" value="'.$inst_results{$item}.'" />'.$inst_results{$item});
     <td><input type="text" name="cemail" size="20" value="$inst_results{'permanentemail'}" /></td></tr>              } else {
 </table>                  $r->print('<input type="text" name="'.$element{$item}.'" size="'.$textboxsize{$item}.'" value="" />');
 $lt{'idsn'} <input type="text" name="cstid" size="15" value="$inst_results{'id'}" /></p>              }
               $r->print(&Apache::lonhtmlcommon::row_closure(1));
           }
           $r->print(&Apache::lonhtmlcommon::end_pick_box());
           $r->print(<<ENDNEWUSER);
   <br />
 $lt{'hs'}: <select name="hserver" size="1"> $home_server_list </select>  $lt{'hs'}: <select name="hserver" size="1"> $home_server_list </select>
   <br />
 <hr />  <hr />
 <h3>$lt{'lg'}</h3>  <h3>$lt{'lg'}</h3>
 <p>$generalrule </p>  ENDNEWUSER
 <p>$authformkrb </p>          my ($fixedauth,$varauth,$authmsg); 
 <p>$authformint </p>          if ($rulematch) {
 <p>$authformfsys</p>              if (ref($rules) eq 'HASH') {
 <p>$authformloc </p>                  if (ref($rules->{$rulematch}) eq 'HASH') {
                       my $authtype = $rules->{$rulematch}{'authtype'};
                       if ($authtype !~ /^(krb4|krb5|int|fsys|loc)$/) {
                           $r->print(&set_login());
                       } else { 
                           my $authparm = $rules->{$rulematch}{'authparm'};
                           if ($authtype =~ /^krb(4|5)$/) {
                               my $ver = $1;
                               if ($authparm ne '') {
                                   $fixedauth = <<"KERB"; 
   <input type="hidden" name="login" value="krb" />
   <input type="hidden" name="krbver" value="$ver" />
   <input type="hidden" name="krbarg" value="$authparm" />
   KERB
                                   $authmsg = $rules->{$rulematch}{'authmsg'};    
                               }
                           } else {
                               $fixedauth = 
   '<input type="hidden" name="login" value="'.$authtype.'" />'."\n";
                               if ($rules->{$rulematch}{'authparmfixed'}) {
                                   $fixedauth .=    
   '<input type="hidden" name="'.$authtype.'arg" value="'.$authparm.'" />'."\n";
                               } else {
                                   $varauth =  
   '<input type="text" name="'.$authtype.'arg" value="" />'."\n";
                               }
                           }
                       }
                   } else {
                       $r->print(&set_login());
                   }
               }
               if ($authmsg) {
                   $r->print(<<ENDAUTH);
   $fixedauth
   $authmsg
   $varauth
   ENDAUTH
               }
           } else {
               $r->print(&set_login()); 
            }
            $r->print(<<ENDPORT);
 <hr />  <hr />
 $portfolioform  $portfolioform
 ENDNEWUSER  ENDPORT
     } else { # user already exists      } else { # user already exists
  my %lt=&Apache::lonlocal::texthash(   my %lt=&Apache::lonlocal::texthash(
                     'cup'  => "Change User Privileges",                      'cup'  => "Change User Privileges",
Line 1012  END Line 1070  END
             $loginscript  = &Apache::loncommon::authform_header(%param);              $loginscript  = &Apache::loncommon::authform_header(%param);
  }   }
  # Check for a bad authentication type   # Check for a bad authentication type
         unless ($currentauth=~/^krb(4|5):/ or          if ($currentauth !~ /^(krb4|krb5|unix|internal|localauth):/) { 
  $currentauth=~/^unix:/ or              # bad authentication scheme
  $currentauth=~/^internal:/ or  
  $currentauth=~/^localauth:/  
  ) { # bad authentication scheme  
     if (&Apache::lonnet::allowed('mau',$ccdomain)) {      if (&Apache::lonnet::allowed('mau',$ccdomain)) {
                 &initialize_authen_forms();                  &initialize_authen_forms();
  my %lt=&Apache::lonlocal::texthash(   my %lt=&Apache::lonlocal::texthash(
Line 1111  $lt{'yodo'} $lt{'ifch'}: $ccdomain Line 1166  $lt{'yodo'} $lt{'ifch'}: $ccdomain
 ENDNOPRIV  ENDNOPRIV
                 }                   } 
             }              }
             if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {  
                 # Current user has quota modification privileges  
                 $r->print(&portfolio_quota($ccuname,$ccdomain));  
             }  
         }  ## End of "check for bad authentication type" logic          }  ## End of "check for bad authentication type" logic
           if (&Apache::lonnet::allowed('mpq',$ccdomain)) {
               # Current user has quota modification privileges
               $r->print(&portfolio_quota($ccuname,$ccdomain));
           } elsif (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {
               my %lt=&Apache::lonlocal::texthash(
                   'dska'  => "Disk space allocated to user's portfolio files",
                   'youd'  => "You do not have privileges to modify the portfolio quota for this user.",
                   'ichr'  => "If a change is required, contact a domain coordinator for the domain",
               );
               $r->print(<<ENDNOPORTPRIV);
   <hr />
   <h3>$lt{'dska'}</h3>
   $lt{'youd'} $lt{'ichr'}: $ccdomain
   ENDNOPORTPRIV
           }
     } ## End of new user/old user logic      } ## End of new user/old user logic
     $r->print('<hr /><h3>'.&mt('Add Roles').'</h3>');      $r->print('<hr /><h3>'.&mt('Add Roles').'</h3>');
 #  #
Line 1228  ENDNOPRIV Line 1294  ENDNOPRIV
     $r->print("</form>".&Apache::loncommon::end_page());      $r->print("</form>".&Apache::loncommon::end_page());
 }  }
   
   sub set_login {
       my $response = (<<ENDAUTH);
   <p>$generalrule </p>
   <p>$authformkrb </p>
   <p>$authformint </p>
   <p>$authformfsys</p>
   <p>$authformloc </p>
   ENDAUTH
       return $response;
   }
   
 # ================================================================= Phase Three  # ================================================================= Phase Three
 sub update_user_data {  sub update_user_data {
     my ($r) = @_;       my ($r) = @_; 
Line 1357  sub update_user_data { Line 1434  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 2288  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 2302  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 2241  sub user_search_result { Line 2319  sub user_search_result {
             }              }
         }          }
     }      }
       if ($response ne '') {
           $response = '<span class="LC_warning">'.$response.'</span>';
       }
     if ($srch->{'srchin'} eq 'instd') {      if ($srch->{'srchin'} eq 'instd') {
         my $instd_chk = &directorysrch_check($srch);          my $instd_chk = &directorysrch_check($srch);
         if ($instd_chk ne 'ok') {          if ($instd_chk ne 'ok') {
             $response = $instd_chk;              $response = '<span class="LC_warning">'.$instd_chk.'</span>'.
                           '<br />'.&mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').'<br /><br />';
         }          }
     }      }
     if ($response ne '') {      if ($response ne '') {
         return ($currstate,'<span class="LC_warning">'.$response.'</span>');          return ($currstate,$response);
     }      }
     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 2257  sub user_search_result { Line 2339  sub user_search_result {
                     my $uhome=&Apache::lonnet::homeserver($srch->{'srchterm'},$srch->{'srchdomain'});                      my $uhome=&Apache::lonnet::homeserver($srch->{'srchterm'},$srch->{'srchdomain'});
                     if ($uhome eq 'no_host') {                      if ($uhome eq 'no_host') {
                         my $domdesc = &Apache::lonnet::domain($env{'request.role.domain'},'description');                          my $domdesc = &Apache::lonnet::domain($env{'request.role.domain'},'description');
                         $response = &mt('New users can only be created in the domain to which you current role belongs - [_1].',$env{'request.role.domain'}.' ('.$domdesc.')');                          my $showdom = &display_domain_info($env{'request.role.domain'});
                           $response = &mt('New users can only be created in the domain to which your current role belongs - [_1].',$showdom);
                     } else {                      } else {
                         $currstate = 'modify';                          $currstate = 'modify';
                     }                      }
Line 2319  sub user_search_result { Line 2402  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 2383  sub user_search_result { Line 2475  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 2397  sub directorysrch_check { Line 2497  sub directorysrch_check {
     my $response;      my $response;
     my %dom_inst_srch = &Apache::lonnet::get_dom('configuration',      my %dom_inst_srch = &Apache::lonnet::get_dom('configuration',
                                              ['directorysrch'],$srch->{'srchdomain'});                                               ['directorysrch'],$srch->{'srchdomain'});
       my $showdom = &display_domain_info($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('Institutional directory search unavailable in domain: [_1]',$srch->{'srchdomain'});               return &mt('Institutional directory search is not available in domain: [_1]',$showdom); 
         }          }
         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('Insitutional directory search in domain: [_1] is only allowed for users with a current role in the domain.',$srch->{'srchdomain'});                   return &mt('Institutional directory search in domain: [_1] is only allowed for users with a current role in the domain.',$showdom); 
             }              }
             my @usertypes = split(/:/,$env{'environment.inststatus'});              my @usertypes = split(/:/,$env{'environment.inststatus'});
             if (!@usertypes) {              if (!@usertypes) {
Line 2424  sub directorysrch_check { Line 2525  sub directorysrch_check {
                     push (@longtypes,$insttypes->{$item});                      push (@longtypes,$insttypes->{$item});
                 }                  }
                 my $insttype_str = join(', ',@longtypes);                   my $insttype_str = join(', ',@longtypes); 
                 return &mt('Directory search in domain: [_1] is unavailable to your user type: ',$srch->{'srchdomain'}).$insttype_str;                  return &mt('Institutional directory search in domain: [_1] is not available to your user type: ',$showdom).$insttype_str;
             }               } 
         } else {          } else {
             $can_search = 1;              $can_search = 1;
         }          }
     } else {      } else {
         return &mt('Directory search has not been configured for domain: [_1]',$srch->{'srchdomain'});          return &mt('Institutional directory search has not been configured for domain: [_1]',$showdom);
     }      }
     my %longtext = &Apache::lonlocal::texthash (      my %longtext = &Apache::lonlocal::texthash (
                        uname     => 'username',                         uname     => 'username',
Line 2443  sub directorysrch_check { Line 2544  sub directorysrch_check {
     if ($can_search) {      if ($can_search) {
         if (ref($dom_inst_srch{'directorysrch'}{'searchby'}) eq 'ARRAY') {          if (ref($dom_inst_srch{'directorysrch'}{'searchby'}) eq 'ARRAY') {
             if (!grep(/^\Q$srch->{'srchby'}\E$/,@{$dom_inst_srch{'directorysrch'}{'searchby'}})) {              if (!grep(/^\Q$srch->{'srchby'}\E$/,@{$dom_inst_srch{'directorysrch'}{'searchby'}})) {
                 return &mt('Directory search in domain: [_1] is not available for searching by "[_2]"',$srch->{'srchdomain'},$longtext{$srch->{'srchby'}});                  return &mt('Institutional directory search in domain: [_1] is not available for searching by "[_2]"',$showdom,$longtext{$srch->{'srchby'}});
             }              }
         } else {          } else {
             return &mt('Directory search in domain: [_1] is not available.', $srch->{'srchdomain'});              return &mt('Institutional directory search in domain: [_1] is not available.', $showdom);
         }          }
     }      }
     if ($can_search) {      if ($can_search) {
Line 2454  sub directorysrch_check { Line 2555  sub directorysrch_check {
             if (grep(/^\Q$srch->{'srchtype'}\E/,@{$dom_inst_srch{'directorysrch'}{'searchtypes'}})) {              if (grep(/^\Q$srch->{'srchtype'}\E/,@{$dom_inst_srch{'directorysrch'}{'searchtypes'}})) {
                 return 'ok';                  return 'ok';
             } else {              } else {
                 return &mt('Directory search in domain [_1] is not available for the requested search type: "[_2]"',$srch->{'srchdomain'},$longtext{$srch->{'srchtype'}});                  return &mt('Institutional directory search in domain [_1] is not available for the requested search type: "[_2]"',$showdom,$longtext{$srch->{'srchtype'}});
             }              }
         } else {          } else {
             if ((($dom_inst_srch{'directorysrch'}{'searchtypes'} eq 'specify') &&              if ((($dom_inst_srch{'directorysrch'}{'searchtypes'} eq 'specify') &&
Line 2462  sub directorysrch_check { Line 2563  sub directorysrch_check {
                 ($dom_inst_srch{'directorysrch'}{'searchtypes'} eq $srch->{'srchtype'})) {                  ($dom_inst_srch{'directorysrch'}{'searchtypes'} eq $srch->{'srchtype'})) {
                 return 'ok';                  return 'ok';
             } else {              } else {
                 return &mt('Directory search in domain [_1] is not available for the requested search type: "[_2]"',$srch->{'srchdomain'},$longtext{$srch->{'srchtype'}});                  return &mt('Institutional directory search in domain [_1] is not available for the requested search type: "[_2]"',$showdom,$longtext{$srch->{'srchtype'}});
             }              }
         }          }
     }      }
 }  }
   
   
 sub get_courseusers {  sub get_courseusers {
     my %advhash;      my %advhash;
     my $classlist = &Apache::loncoursedata::get_classlist();      my $classlist = &Apache::loncoursedata::get_classlist();
Line 2491  sub build_search_response { Line 2591  sub build_search_response {
           'lastname' => 'last name',            'lastname' => 'last name',
           'lastfirst' => 'last name, first name',            'lastfirst' => 'last name, first name',
           'crs' => 'this course',            'crs' => 'this course',
           'dom' => 'this domain',            'dom' => 'LON-CAPA domain: ',
           'instd' => "your institution's directory",            'instd' => 'the institutional directory for domain: ',
     );      );
   
     my %single = (      my %single = (
                      begins   => 'A match',
                    contains => 'A match',                     contains => 'A match',
                    exact => 'An exact match',                     exact    => 'An exact match',
                  );                   );
     my %nomatch = (      my %nomatch = (
                      begins   => 'No match',
                    contains => 'No match',                     contains => 'No match',
                    exact => 'No exact match',                     exact    => 'No exact match',
                   );                    );
     if (keys(%srch_results) > 1) {      if (keys(%srch_results) > 1) {
         $currstate = 'select';          $currstate = 'select';
     } else {      } else {
         if (keys(%srch_results) == 1) {          if (keys(%srch_results) == 1) {
             $currstate = 'modify';              $currstate = '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 the $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'});
               if ($srch->{'srchin'} eq 'dom' || $srch->{'srchin'} eq 'instd') {
                   $response .= &display_domain_info($srch->{'srchdomain'});
               }
         } else {          } else {
             $response = '<span class="LC_warning">'.&mt("$nomatch{$srch->{'srchtype'}} found for this $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'}).'</span>';              $response = '<span class="LC_warning">'.&mt("$nomatch{$srch->{'srchtype'}} found for the $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}",$srch->{'srchterm'});
               if ($srch->{'srchin'} eq 'dom' || $srch->{'srchin'} eq 'instd') {
                   $response .= &display_domain_info($srch->{'srchdomain'});
               }
               $response .= '</span>';
             if ($srch->{'srchin'} ne 'alc') {              if ($srch->{'srchin'} ne 'alc') {
                 $forcenewuser = 1;                  $forcenewuser = 1;
                 my $cansrchinst = 0;                   my $cansrchinst = 0; 
Line 2522  sub build_search_response { Line 2631  sub build_search_response {
                         }                           } 
                     }                      }
                 }                  }
                 if (($srch->{'srchby'} eq 'lastfirst') ||                   if ((($srch->{'srchby'} eq 'lastfirst') || 
                     ($srch->{'srchby'} eq 'lastname')) {                       ($srch->{'srchby'} eq 'lastname')) &&
                     if ($srch->{'srchin'} eq 'crs') {                      ($srch->{'srchin'} eq 'dom')) {
                         $response .= '<br />'.&mt('You may want to broaden your search to the whole domain.');                       if ($cansrchinst) {
                     } elsif ($srch->{'srchin'} eq 'dom') {                          $response .= '<br />'.&mt('You may want to broaden your search to a search of the institutional directory for the domain.');
                         if ($cansrchinst) {  
                             $response .= '<br />'.&mt('You may want to broaden your search to a search of the institutional directory for this domain.');  
                         }  
                     }                      }
                 }                  }
                   if ($srch->{'srchin'} eq 'crs') {
                       $response .= '<br />'.&mt('You may want to broaden your search to the selected LON-CAPA domain.');
                   }
               }
               if (!($srch->{'srchby'} eq 'uname' && $srch->{'srchin'} eq 'dom' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchdomain'} eq $env{'request.role.domain'})) {
                   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 />';
             }              }
         }          }
     }      }
     return ($currstate,$response,$forcenewuser);      return ($currstate,$response,$forcenewuser);
 }  }
   
   sub display_domain_info {
       my ($dom) = @_;
       my $output = $dom;
       if ($dom ne '') { 
           my $domdesc = &Apache::lonnet::domain($dom,'description');
           if ($domdesc ne '') {
               $output .= ' <span class="LC_cusr_emph">('.$domdesc.')</span>';
           }
       }
       return $output;
   }
   
 sub crumb_utilities {  sub crumb_utilities {
     my %elements = (      my %elements = (
        crtuser => {         crtuser => {

Removed from v.1.179  
changed lines
  Added in v.1.186


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