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

version 1.179, 2007/08/26 21:09:43 version 1.180, 2007/08/31 03:21:27
Line 2241  sub user_search_result { Line 2241  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 2261  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 2397  sub directorysrch_check { Line 2402  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 2430  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 2449  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 2460  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 2468  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'}});
             }              }
         }          }
     }      }
Line 2491  sub build_search_response { Line 2497  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 2537  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'})) {
                   $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 />';
             }              }
         }          }
     }      }
     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.180


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