Diff for /loncom/interface/loncreateuser.pm between versions 1.192 and 1.193

version 1.192, 2007/11/09 20:51:20 version 1.193, 2007/11/10 03:51:46
Line 447  sub print_user_modification_page { Line 447  sub print_user_modification_page {
         return;          return;
     }      }
     my %abv_auth = &auth_abbrev();      my %abv_auth = &auth_abbrev();
     my ($curr_authtype,$instsrch,$rulematch,$rules,%inst_results,      my ($curr_authtype,%rulematch,%inst_results,$curr_kerb_ver,$newuser,
         $curr_kerb_ver,$newuser);          %alerts,%curr_rules);
     my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);      my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);
     if ($uhome eq 'no_host') {      if ($uhome eq 'no_host') {
         $newuser = 1;          $newuser = 1;
         $instsrch =          my $checkhash;
                       {          my $checks = { 'username' => 1 };
                          srchin => 'instd',          $checkhash->{$ccuname.':'.$ccdomain} = { 'status' => 'new' };
                          srchby => 'uname',          &Apache::loncommon::user_rule_check($checkhash,$checks,
                          srchtype => 'exact',                     \%alerts,\%rulematch,\%inst_results,\%curr_rules);
                          srchterm => $ccuname,          if (ref($alerts{$ccuname.':'.$ccdomain}) eq 'HASH') {
                          srchdomain => $ccdomain,              if ($alerts{$ccuname.':'.$ccdomain}{'username'}) {
                        };                  my $domdesc = 
         (my $usercheckmsg,$rulematch,$rules,%inst_results) =                       &Apache::lonnet::domain($ccdomain,'description');
             &Apache::loncommon::username_rule_check($instsrch,'new');                  my $userchkmsg;
         if ($usercheckmsg) {                  if (ref($curr_rules{$ccdomain}) eq 'HASH') {  
             &print_username_entry_form($r,$usercheckmsg);                      $userchkmsg = 
             return;                          &Apache::loncommon::instrule_disallow_msg('username',
                                                                    $domdesc,1).
                           &Apache::loncommon::user_rule_formats($ccdomain,
                               $domdesc,$curr_rules{$ccdomain}{'username'},
                               'username');
                   }
                   &print_username_entry_form($r,$userchkmsg);
                   return;
               }
         }          }
     } else {      } else {
         $newuser = 0;          $newuser = 0;
Line 766  $forminfo Line 774  $forminfo
 $loginscript  $loginscript
 </script>  </script>
 <input type='hidden' name='makeuser' value='1' />  <input type='hidden' name='makeuser' value='1' />
 <h3>$lt{'cnu'} "$ccuname" $lt{'ind'} $ccdomain</h3>  <h2>$lt{'cnu'} "$ccuname" $lt{'ind'} $ccdomain</h2>
 ENDTITLE  ENDTITLE
         $r->print('<div class="LC_left_float">'.          $r->print('<div class="LC_left_float">'.
                   &personal_data_display($ccuname,$ccdomain,$newuser,                    &personal_data_display($ccuname,$ccdomain,$newuser,
Line 785  $lt{'hs'}: $home_server_pick Line 793  $lt{'hs'}: $home_server_pick
         $r->print('</div>'."\n".'<div class="LC_left_float"><h3>'.          $r->print('</div>'."\n".'<div class="LC_left_float"><h3>'.
                   $lt{'lg'}.'</h3>');                    $lt{'lg'}.'</h3>');
         my ($fixedauth,$varauth,$authmsg);           my ($fixedauth,$varauth,$authmsg); 
         if ($rulematch) {          if (ref($rulematch{$ccuname.':'.$ccdomain}) eq 'HASH') {
               my $matchedrule = $rulematch{$ccuname.':'.$ccdomain}{'username'};
               my ($rules,$ruleorder) = 
                   &Apache::lonnet::inst_userrules($ccdomain,'username');
             if (ref($rules) eq 'HASH') {              if (ref($rules) eq 'HASH') {
                 if (ref($rules->{$rulematch}) eq 'HASH') {                  if (ref($rules->{$matchedrule}) eq 'HASH') {
                     my $authtype = $rules->{$rulematch}{'authtype'};                      my $authtype = $rules->{$matchedrule}{'authtype'};
                     if ($authtype !~ /^(krb4|krb5|int|fsys|loc)$/) {                      if ($authtype !~ /^(krb4|krb5|int|fsys|loc)$/) {
                         $r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc));                          $r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc));
                     } else {                       } else { 
                         my $authparm = $rules->{$rulematch}{'authparm'};                          my $authparm = $rules->{$matchedrule}{'authparm'};
                         if ($authtype =~ /^krb(4|5)$/) {                          if ($authtype =~ /^krb(4|5)$/) {
                             my $ver = $1;                              my $ver = $1;
                             if ($authparm ne '') {                              if ($authparm ne '') {
Line 801  $lt{'hs'}: $home_server_pick Line 812  $lt{'hs'}: $home_server_pick
 <input type="hidden" name="krbver" value="$ver" />  <input type="hidden" name="krbver" value="$ver" />
 <input type="hidden" name="krbarg" value="$authparm" />  <input type="hidden" name="krbarg" value="$authparm" />
 KERB  KERB
                                 $authmsg = $rules->{$rulematch}{'authmsg'};                                      $authmsg = $rules->{$matchedrule}{'authmsg'};    
                             }                              }
                         } else {                          } else {
                             $fixedauth =                               $fixedauth = 
 '<input type="hidden" name="login" value="'.$authtype.'" />'."\n";  '<input type="hidden" name="login" value="'.$authtype.'" />'."\n";
                             if ($rules->{$rulematch}{'authparmfixed'}) {                              if ($rules->{$matchedrule}{'authparmfixed'}) {
                                 $fixedauth .=                                      $fixedauth .=    
 '<input type="hidden" name="'.$authtype.'arg" value="'.$authparm.'" />'."\n";  '<input type="hidden" name="'.$authtype.'arg" value="'.$authparm.'" />'."\n";
                             } else {                              } else {
Line 1450  sub update_user_data { Line 1461  sub update_user_data {
                                           $env{'form.ccdomain'});                                            $env{'form.ccdomain'});
     # Error messages      # Error messages
     my $error     = '<span class="LC_error">'.&mt('Error').': ';      my $error     = '<span class="LC_error">'.&mt('Error').': ';
     my $end       = '</span><br /><br />'.      my $end       = '</span><br /><br />';
                     '<a href="javascript:backPage(document.userupdate,'.      my $rtnlink   = '<a href="javascript:backPage(document.userupdate,'.
                     "'$env{'form.prevphase'}','modify')".'" />'.                      "'$env{'form.prevphase'}','modify')".'" />'.
                     &mt('Return to previous page').'</a>'.&Apache::loncommon::end_page();                      &mt('Return to previous page').'</a>'.&Apache::loncommon::end_page();
     my $title;      my $title;
Line 1489  sub update_user_data { Line 1500  sub update_user_data {
     $r->print(&update_result_form($uhome));      $r->print(&update_result_form($uhome));
     # Check Inputs      # Check Inputs
     if (! $env{'form.ccuname'} ) {      if (! $env{'form.ccuname'} ) {
  $r->print($error.&mt('No login name specified').'.'.$end);   $r->print($error.&mt('No login name specified').'.'.$end.$rtnlink);
  return;   return;
     }      }
     if (  $env{'form.ccuname'} ne       if (  $env{'form.ccuname'} ne 
   &LONCAPA::clean_username($env{'form.ccuname'}) ) {    &LONCAPA::clean_username($env{'form.ccuname'}) ) {
  $r->print($error.&mt('Invalid login name').'.  '.   $r->print($error.&mt('Invalid login name').'.  '.
   &mt('Only letters, numbers, periods, dashes, @, and underscores are valid').'.'.    &mt('Only letters, numbers, periods, dashes, @, and underscores are valid').'.'.
   $end);    $end.$rtnlink);
  return;   return;
     }      }
     if (! $env{'form.ccdomain'}       ) {      if (! $env{'form.ccdomain'}       ) {
  $r->print($error.&mt('No domain specified').'.'.$end);   $r->print($error.&mt('No domain specified').'.'.$end.$rtnlink);
  return;   return;
     }      }
     if (  $env{'form.ccdomain'} ne      if (  $env{'form.ccdomain'} ne
   &LONCAPA::clean_domain($env{'form.ccdomain'}) ) {    &LONCAPA::clean_domain($env{'form.ccdomain'}) ) {
  $r->print($error.&mt ('Invalid domain name').'.  '.   $r->print($error.&mt ('Invalid domain name').'.  '.
   &mt('Only letters, numbers, periods, dashes, and underscores are valid').'.'.    &mt('Only letters, numbers, periods, dashes, and underscores are valid').'.'.
   $end);    $end.$rtnlink);
  return;   return;
     }      }
     if (! exists($env{'form.makeuser'})) {      if (! exists($env{'form.makeuser'})) {
Line 1543  sub update_user_data { Line 1554  sub update_user_data {
         # If they are creating a new user but have not specified login          # If they are creating a new user but have not specified login
         # information this will be caught below.          # information this will be caught below.
     } else {      } else {
     $r->print($error.&mt('Invalid login mode or password').$end);          $r->print($error.&mt('Invalid login mode or password').$end.$rtnlink);    
     return;      return;
     }      }
   
   
     $r->print('<h3>'.&mt('User [_1] in domain [_2]',      $r->print('<h3>'.&mt('User [_1] in domain [_2]',
  $env{'form.ccuname'}, $env{'form.ccdomain'}).'</h3>');   $env{'form.ccuname'}, $env{'form.ccdomain'}).'</h3>');
       my (%alerts,%rulematch,%inst_results,%curr_rules);
     if ($env{'form.makeuser'}) {      if ($env{'form.makeuser'}) {
  $r->print('<h3>'.&mt('Creating new account.').'</h3>');   $r->print('<h3>'.&mt('Creating new account.').'</h3>');
         # Check for the authentication mode and password          # Check for the authentication mode and password
         if (! $amode || ! $genpwd) {          if (! $amode || ! $genpwd) {
     $r->print($error.&mt('Invalid login mode or password').$end);          $r->print($error.&mt('Invalid login mode or password').$end.$rtnlink);    
     return;      return;
  }   }
         # Determine desired host          # Determine desired host
Line 1566  sub update_user_data { Line 1577  sub update_user_data {
             my %home_servers =               my %home_servers = 
  &Apache::lonnet::get_servers($env{'form.ccdomain'},'library');   &Apache::lonnet::get_servers($env{'form.ccdomain'},'library');
             if (! exists($home_servers{$desiredhost})) {              if (! exists($home_servers{$desiredhost})) {
                 $r->print($error.&mt('Invalid home server specified'));                  $r->print($error.&mt('Invalid home server specified').$end.$rtnlink);
                   return;
               }
           }
           # Check ID format
           my %checkhash;
           my %checks = ('id' => 1);
           %{$checkhash{$env{'form.ccuname'}.':'.$env{'form.ccdomain'}}} = (
               'status' => 'new', 
               'id' => $env{'form.cid'}
           );
           &Apache::loncommon::user_rule_check(\%checkhash,\%checks,\%alerts,
                                         \%rulematch,\%inst_results,\%curr_rules);
           if (ref($alerts{$env{'form.ccuname'}.':'.$env{'form.ccdomain'}}) eq 'HASH') {
               if ($alerts{$env{'form.ccuname'}.':'.$env{'form.ccdomain'}}{'id'}) {
                   my $domdesc =
                       &Apache::lonnet::domain($env{'form.ccdomain'},'description');
                   my $userchkmsg;
                   if (ref($curr_rules{$env{'form.ccdomain'}}) eq 'HASH') {
                       $userchkmsg  = 
                           &Apache::loncommon::instrule_disallow_msg('id',
                                                                     $domdesc,1).
                           &Apache::loncommon::user_rule_formats($env{'form.ccdomain'},
                               $domdesc,$curr_rules{$env{'form.ccdomain'}}{'id'},'id');
                   } 
                   $r->print($error.&mt('Invalid ID format').$end.
                             $userchkmsg.$rtnlink);
                 return;                  return;
             }              }
         }          }
  # Call modifyuser   # Call modifyuser
  my $result = &Apache::lonnet::modifyuser   my $result = &Apache::lonnet::modifyuser
     ($env{'form.ccdomain'},$env{'form.ccuname'},$env{'form.cstid'},      ($env{'form.ccdomain'},$env{'form.ccuname'},$env{'form.cid'},
              $amode,$genpwd,$env{'form.cfirstname'},               $amode,$genpwd,$env{'form.cfirstname'},
              $env{'form.cmiddlename'},$env{'form.clastname'},               $env{'form.cmiddlename'},$env{'form.clastname'},
              $env{'form.cgeneration'},undef,$desiredhost,               $env{'form.cgeneration'},undef,$desiredhost,
Line 1586  sub update_user_data { Line 1623  sub update_user_data {
              ($env{'form.login'} ne ''        )) {               ($env{'form.login'} ne ''        )) {
  # Modify user privileges   # Modify user privileges
         if (! $amode || ! $genpwd) {          if (! $amode || ! $genpwd) {
     $r->print($error.'Invalid login mode or password'.$end);          $r->print($error.'Invalid login mode or password'.$end.$rtnlink);    
     return;      return;
  }   }
  # Only allow authentification modification if the person has authority   # Only allow authentification modification if the person has authority
Line 1599  sub update_user_data { Line 1636  sub update_user_data {
   ($env{'form.ccuname'},$env{'form.ccdomain'}));    ($env{'form.ccuname'},$env{'form.ccdomain'}));
  } else {   } else {
     # Okay, this is a non-fatal error.      # Okay, this is a non-fatal error.
     $r->print($error.&mt('You do not have the authority to modify this users authentification information').'.');          $r->print($error.&mt('You do not have the authority to modify this users authentification information').'.'.$end);    
  }   }
     }      }
     ##      ##
Line 1766  END Line 1803  END
     }      }
     ##      ##
     my $now=time;      my $now=time;
       my $rolechanges = 0;
     $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});
Line 1795  END Line 1833  END
   $env{'form.ccuname'},$1,$2,$3,$4).    $env{'form.ccuname'},$1,$2,$3,$4).
  '</b><br />');   '</b><br />');
     }      }
               $rolechanges ++;
  } elsif ($key=~/^form\.del/) {   } elsif ($key=~/^form\.del/) {
     if ($key=~/^form\.del\:([^\_]+)\_([^\_\.]+)$/) {      if ($key=~/^form\.del\:([^\_]+)\_([^\_\.]+)$/) {
 # Delete standard role  # Delete standard role
Line 1820  END Line 1859  END
                          $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,                           $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,
                          0,1).'</b><br />');                           0,1).'</b><br />');
             }              }
               $rolechanges ++;
  } elsif ($key=~/^form\.ren/) {   } elsif ($key=~/^form\.ren/) {
             my $udom = $env{'form.ccdomain'};              my $udom = $env{'form.ccdomain'};
             my $uname = $env{'form.ccuname'};              my $uname = $env{'form.ccuname'};
Line 1858  END Line 1898  END
                 $r->print(&mt('Re-enabling custom role [_1] by [_2]@[_3] in [_4] : <b>[_5]</b>',                  $r->print(&mt('Re-enabling custom role [_1] by [_2]@[_3] in [_4] : <b>[_5]</b>',
                           $rolename,$rnam,$rdom,$url,$result).'<br />');                            $rolename,$rnam,$rdom,$url,$result).'<br />');
             }              }
               $rolechanges ++;
  } elsif ($key=~/^form\.act/) {   } elsif ($key=~/^form\.act/) {
             my $udom = $env{'form.ccdomain'};              my $udom = $env{'form.ccdomain'};
             my $uname = $env{'form.ccuname'};              my $uname = $env{'form.ccuname'};
Line 1971  END Line 2012  END
                 }                  }
                 $r->print(' '.&mt('Please <a href="javascript:history.go(-1)">go back</a> and choose a different section name.').'</p><br />');                  $r->print(' '.&mt('Please <a href="javascript:history.go(-1)">go back</a> and choose a different section name.').'</p><br />');
             }              }
               $rolechanges ++;
  }   }
     } # 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();
       if (!$rolechanges) {
           $r->print(&mt('No roles to modify'));
       }
     $r->print(&Apache::loncommon::end_page());      $r->print(&Apache::loncommon::end_page());
 }  }
   

Removed from v.1.192  
changed lines
  Added in v.1.193


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