Diff for /loncom/interface/loncreateuser.pm between versions 1.403 and 1.406.2.3

version 1.403, 2014/06/30 14:49:35 version 1.406.2.3, 2016/09/18 18:10:54
Line 813  sub entry_form { Line 813  sub entry_form {
     }      }
     my $cancreate =      my $cancreate =
         &Apache::lonuserutils::can_create_user($dom,$context,$usertype);          &Apache::lonuserutils::can_create_user($dom,$context,$usertype);
     my $userpicker =       my ($userpicker,$cansearch) = 
        &Apache::loncommon::user_picker($dom,$srch,$forcenewuser,         &Apache::loncommon::user_picker($dom,$srch,$forcenewuser,
                                        'document.crtuser',$cancreate,$usertype);                                         'document.crtuser',$cancreate,$usertype);
     my $srchbutton = &mt('Search');      my $srchbutton = &mt('Search');
Line 822  sub entry_form { Line 822  sub entry_form {
     } elsif ($cancreate && $responsemsg ne '' && $inexact) {      } elsif ($cancreate && $responsemsg ne '' && $inexact) {
         $srchbutton = &mt('Search or Add New User');          $srchbutton = &mt('Search or Add New User');
     }      }
     my $output = <<"ENDBLOCK";      my $output;
       if ($cansearch) {
           $output = <<"ENDBLOCK";
 <form action="/adm/createuser" method="post" name="crtuser">  <form action="/adm/createuser" method="post" name="crtuser">
 <input type="hidden" name="action" value="$env{'form.action'}" />  <input type="hidden" name="action" value="$env{'form.action'}" />
 <input type="hidden" name="phase" value="get_user_info" />  <input type="hidden" name="phase" value="get_user_info" />
Line 830  $userpicker Line 832  $userpicker
 <input name="userrole" type="button" value="$srchbutton" onclick="javascript:validateEntry(document.crtuser)" />  <input name="userrole" type="button" value="$srchbutton" onclick="javascript:validateEntry(document.crtuser)" />
 </form>  </form>
 ENDBLOCK  ENDBLOCK
       } else {
           $output = '<p>'.$userpicker.'</p>';
       }
     if ($env{'form.phase'} eq '') {      if ($env{'form.phase'} eq '') {
         my $defdom=$env{'request.role.domain'};          my $defdom=$env{'request.role.domain'};
         my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain');          my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain');
Line 2244  sub personal_data_display { Line 2249  sub personal_data_display {
                    '<input type="text" name="uname" size="25" value="" autocomplete="off" />';                     '<input type="text" name="uname" size="25" value="" autocomplete="off" />';
         $rowcount ++;          $rowcount ++;
         $output .= &Apache::lonhtmlcommon::row_closure(1);          $output .= &Apache::lonhtmlcommon::row_closure(1);
         my $upassone = '<input type="password" name="upass'.$now.'" size="10" autocomplete="off" />';          my $upassone = '<input type="password" name="upass'.$now.'" size="20" autocomplete="off" />';
         my $upasstwo = '<input type="password" name="upasscheck'.$now.'" size="10" autocomplete="off" />';          my $upasstwo = '<input type="password" name="upasscheck'.$now.'" size="20" autocomplete="off" />';
         $output .= &Apache::lonhtmlcommon::row_title(&mt('Password').'<b>*</b>',          $output .= &Apache::lonhtmlcommon::row_title(&mt('Password').'<b>*</b>',
                                                     'LC_pick_box_title',                                                      'LC_pick_box_title',
                                                     'LC_oddrow_value')."\n".                                                      'LC_oddrow_value')."\n".
Line 2351  sub personal_data_display { Line 2356  sub personal_data_display {
     }      }
     if (($context eq 'selfcreate') && ($newuser eq 'email')) {      if (($context eq 'selfcreate') && ($newuser eq 'email')) {
         if ($captchaform) {          if ($captchaform) {
             $output .= &Apache::lonhtmlcommon::row_title($lt{'valid'},              $output .= &Apache::lonhtmlcommon::row_title($lt{'valid'}.'*',
                                                          'LC_pick_box_title')."\n".                                                           'LC_pick_box_title')."\n".
                        $captchaform."\n".'<br /><br />'.                         $captchaform."\n".'<br /><br />'.
                        &Apache::lonhtmlcommon::row_closure(1)                         &Apache::lonhtmlcommon::row_closure(1)
Line 3625  sub update_roles { Line 3630  sub update_roles {
     my @rolechanges;      my @rolechanges;
     my %disallowed;      my %disallowed;
     $r->print('<h3>'.&mt('Modifying Roles').'</h3>');      $r->print('<h3>'.&mt('Modifying Roles').'</h3>');
     foreach my $key (keys (%env)) {      foreach my $key (keys(%env)) {
  next if (! $env{$key});   next if (! $env{$key});
         next if ($key eq 'form.action');          next if ($key eq 'form.action');
  # Revoke roles   # Revoke roles
Line 3807  sub update_roles { Line 3812  sub update_roles {
                 } else {                  } else {
     my %curr_groups =      my %curr_groups =
  &Apache::longroup::coursegroups($one,$two);   &Apache::longroup::coursegroups($one,$two);
                     foreach my $sec (sort {$a cmp $b} keys %sections) {                      foreach my $sec (sort {$a cmp $b} keys(%sections)) {
                         if (($sec eq 'none') || ($sec eq 'all') ||                           if (($sec eq 'none') || ($sec eq 'all') || 
                             exists($curr_groups{$sec})) {                              exists($curr_groups{$sec})) {
                             $disallowed{$sec} = $url;                              $disallowed{$sec} = $url;
Line 3853  sub update_roles { Line 3858  sub update_roles {
                     my %curr_groups =                       my %curr_groups = 
  &Apache::longroup::coursegroups($one,$two);   &Apache::longroup::coursegroups($one,$two);
                     my $emptysec = 0;                      my $emptysec = 0;
                     foreach my $sec (sort {$a cmp $b} keys %sections) {                      foreach my $sec (sort {$a cmp $b} keys(%sections)) {
                         $sec =~ s/\W//g;                          $sec =~ s/\W//g;
                         if ($sec ne '') {                          if ($sec ne '') {
                             if (($sec eq 'none') || ($sec eq 'all') ||                               if (($sec eq 'none') || ($sec eq 'all') || 
Line 3893  sub update_roles { Line 3898  sub update_roles {
                     $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,'',$context));                      $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,'',$context));
                 } else {                  } else {
                     my $emptysec = 0;                      my $emptysec = 0;
                     foreach my $sec (sort {$a cmp $b} keys %sections) {                      foreach my $sec (sort {$a cmp $b} keys(%sections)) {
                         if ($sec ne '') {                          if ($sec ne '') {
                             my $securl = $url.'/'.$sec;                              my $securl = $url.'/'.$sec;
                             $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$two,$start,$end,$one,undef,$sec,$context));                              $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$two,$start,$end,$one,undef,$sec,$context));
Line 5544  sub print_selfenroll_menu { Line 5549  sub print_selfenroll_menu {
         butn => 'but no user types have been checked.',          butn => 'but no user types have been checked.',
         wilf => "Please uncheck 'activate' or check at least one type.",          wilf => "Please uncheck 'activate' or check at least one type.",
     );      );
       &js_escape(\%alerts);
     my $selfenroll_js = <<"ENDSCRIPT";      my $selfenroll_js = <<"ENDSCRIPT";
 function update_types(caller,num) {  function update_types(caller,num) {
     var delidx = getIndexByName('selfenroll_delete');      var delidx = getIndexByName('selfenroll_delete');
Line 5745  ENDSCRIPT Line 5751  ENDSCRIPT
         $cathash = $domconfig{'coursecategories'}{'cats'};          $cathash = $domconfig{'coursecategories'}{'cats'};
         $cattype{'auth'} = $domconfig{'coursecategories'}{'auth'};          $cattype{'auth'} = $domconfig{'coursecategories'}{'auth'};
         $cattype{'unauth'} = $domconfig{'coursecategories'}{'unauth'};          $cattype{'unauth'} = $domconfig{'coursecategories'}{'unauth'};
           if ($cattype{'auth'} eq '') {
               $cattype{'auth'} = 'std';
           }
           if ($cattype{'unauth'} eq '') {
               $cattype{'unauth'} = 'std';
           }
     } else {      } else {
         $cathash = {};          $cathash = {};
         $cattype{'auth'} = 'std';          $cattype{'auth'} = 'std';
Line 6819  sub user_search_result { Line 6831  sub user_search_result {
         $response = '<span class="LC_warning">'.$response.'</span>';          $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 = &instdirectorysrch_check($srch);
         if ($instd_chk ne 'ok') {          if ($instd_chk ne 'ok') {
             $response = '<span class="LC_warning">'.$instd_chk.'</span>'.              my $domd_chk = &domdirectorysrch_check($srch);
                         '<br />'.&mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').'<br /><br />';              $response = '<span class="LC_warning">'.$instd_chk.'</span><br />';
               if ($domd_chk eq 'ok') {
                   $response = &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.');
               }
               $response .= '<br /><br />';
           }
       } else {
           unless (($context eq 'requestcrs') && ($srch->{'srchtype'} eq 'exact')) {
               my $domd_chk = &domdirectorysrch_check($srch);
               if ($domd_chk ne 'ok') {
                   my $instd_chk = &instdirectorysrch_check($srch);
                   $response = '<span class="LC_warning">'.$domd_chk.'</span><br />';
                   if ($instd_chk eq 'ok') {
                       $response = &mt('You may want to search in the institutional directory instead of the LON-CAPA domain.');
                   }
                   $response .= '<br /><br />';
               }
         }          }
     }      }
     if ($response ne '') {      if ($response ne '') {
Line 6997  sub user_search_result { Line 7025  sub user_search_result {
     return ($currstate,$response,$forcenewuser,\%srch_results);      return ($currstate,$response,$forcenewuser,\%srch_results);
 }  }
   
 sub directorysrch_check {  sub domdirectorysrch_check {
       my ($srch) = @_;
       my $response;
       my %dom_inst_srch = &Apache::lonnet::get_dom('configuration',
                                                ['directorysrch'],$srch->{'srchdomain'});
       my $showdom = &display_domain_info($srch->{'srchdomain'});
       if (ref($dom_inst_srch{'directorysrch'}) eq 'HASH') {
           if ($dom_inst_srch{'directorysrch'}{'lcavailable'} eq '0') {
               return &mt('LON-CAPA directory search is not available in domain: [_1]',$showdom);
           }
           if ($dom_inst_srch{'directorysrch'}{'lclocalonly'}) {
               if ($env{'request.role.domain'} ne $srch->{'srchdomain'}) {
                   return &mt('LON-CAPA directory search in domain: [_1] is only allowed for users with a current role in the domain.',$showdom);
               }
           }
       }
       return 'ok';
   }
   
   sub instdirectorysrch_check {
     my ($srch) = @_;      my ($srch) = @_;
     my $can_search = 0;      my $can_search = 0;
     my $response;      my $response;
Line 7451  sub course_level_dc { Line 7498  sub course_level_dc {
         my $plrole=&Apache::lonnet::plaintext($role);          my $plrole=&Apache::lonnet::plaintext($role);
         $otheritems .= '  <option value="'.$role.'">'.$plrole.'</option>';          $otheritems .= '  <option value="'.$role.'">'.$plrole.'</option>';
     }      }
     if ( keys %customroles > 0) {      if ( keys(%customroles) > 0) {
         foreach my $cust (sort keys %customroles) {          foreach my $cust (sort(keys(%customroles))) {
             my $custrole='cr_cr_'.$env{'user.domain'}.              my $custrole='cr_cr_'.$env{'user.domain'}.
                     '_'.$env{'user.name'}.'_'.$cust;                      '_'.$env{'user.name'}.'_'.$cust;
             $otheritems .= '  <option value="'.$custrole.'">'.$cust.'</option>';              $otheritems .= '  <option value="'.$custrole.'">'.$cust.'</option>';

Removed from v.1.403  
changed lines
  Added in v.1.406.2.3


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