Diff for /loncom/interface/loncreateuser.pm between versions 1.34 and 1.41

version 1.34, 2002/04/29 14:32:11 version 1.41, 2002/08/22 21:05:25
Line 87  sub phase_one { Line 87  sub phase_one {
     my $defdom=$ENV{'user.domain'};      my $defdom=$ENV{'user.domain'};
     my @domains = &Apache::loncommon::get_domains();      my @domains = &Apache::loncommon::get_domains();
     my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');      my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');
       my $bodytag =&Apache::loncommon::bodytag(
                                     'Create Users, Change User Privileges');
     $r->print(<<"ENDDOCUMENT");      $r->print(<<"ENDDOCUMENT");
 <html>  <html>
 <head>  <head>
 <title>The LearningOnline Network with CAPA</title>  <title>The LearningOnline Network with CAPA</title>
 </head>  </head>
 <body bgcolor="#FFFFFF">  $bodytag
 <h1>Create User, Change User Privileges</h1>  
 <form action=/adm/createuser method=post>  <form action=/adm/createuser method=post>
 <input type=hidden name=phase value=two>  <input type=hidden name=phase value=two>
 <p>  <p>
Line 154  sub phase_two { Line 155  sub phase_two {
   
 </script>  </script>
 </head>  </head>
 <body bgcolor="#FFFFFF">  
 <img align="right" src="/adm/lonIcons/lonlogos.gif">  
 ENDDOCHEAD  ENDDOCHEAD
       $r->print(&Apache::loncommon::bodytag(
                                        'Create Users, Change User Privileges'));
     my $forminfo =<<"ENDFORMINFO";      my $forminfo =<<"ENDFORMINFO";
 <form action="/adm/createuser" method="post" name="cu">  <form action="/adm/createuser" method="post" name="cu">
 <input type="hidden" name="phase"       value="three">  <input type="hidden" name="phase"       value="three">
Line 250  END Line 251  END
         my ($tmp) = keys(%rolesdump);          my ($tmp) = keys(%rolesdump);
         unless ($tmp =~ /^(con_lost|error)/i) {          unless ($tmp =~ /^(con_lost|error)/i) {
            my $now=time;             my $now=time;
            $r->print('<hr /><h3>Revoke Existing Roles</h3>'.             $r->print(<<END);
              '<table border=2><tr><th>Revoke</th><th>Role</th><th>Extent</th>'.  <hr />
      '<th>Start</th><th>End</th>');  <h3>Revoke Existing Roles</h3>
   <table border=2>
   <tr><th>Revoke</th><th>Role</th><th>Extent</th><th>Start</th><th>End</th>
   END
    foreach my $area (keys(%rolesdump)) {     foreach my $area (keys(%rolesdump)) {
               if ($area!~/^rolesdef/) {                 next if ($area =~ /^rolesdef/);
                  my $role = $rolesdump{$area};                 my $role = $rolesdump{$area};
                  my $thisrole=$area;                 my $thisrole=$area;
                  $area=~s/\_\w\w$//;                 $area =~ s/\_\w\w$//;
                  my ($role_code,$role_end_time,$role_start_time) =                 my ($role_code,$role_end_time,$role_start_time) = 
                      split(/_/,$role);                     split(/_/,$role);
                  my $bgcol='ffffff';                 my $bgcol='ffffff';
                  my $allows=0;                 my $allowed=0;
                  if ($area=~/^\/(\w+)\/(\d\w+)/) {                 if ($area =~ /^\/(\w+)\/(\d\w+)/ ) {
                     my %coursedata=                     my %coursedata=
                         &Apache::lonnet::coursedescription($1.'_'.$2);                         &Apache::lonnet::coursedescription($1.'_'.$2);
                     my $carea='Course: '.$coursedata{'description'};                     my $carea='Course: '.$coursedata{'description'};
                     $inccourses{$1.'_'.$2}=1;                     $inccourses{$1.'_'.$2}=1;
                     if (&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2)) {                     if (&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2)) {
                         $allows=1;                         $allowed=1;
                     }                     }
                     # Compute the background color based on $area                     # Compute the background color based on $area
                     $bgcol=$1.'_'.$2;                     $bgcol=$1.'_'.$2;
                     $bgcol=~s/[^8-9b-e]//g;                     $bgcol=~s/[^8-9b-e]//g;
                     $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',0,6);                     $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',0,6);
                     if ($area=~/^\/(\w+)\/(\d\w+)\/(\w+)/) {                     if ($area=~/^\/(\w+)\/(\d\w+)\/(\w+)/) {
                        $carea.='<br>Section/Group: '.$3;                         $carea.='<br>Section/Group: '.$3;
                     }                     }
                     $area=$carea;                     $area=$carea;
                  } else {                 } else {
                      # Determine if current user is able to revoke privileges                     # Determine if current user is able to revoke privileges
                      if ($area=~/^\/(\w+)\//) {                     if ($area=~ /^\/(\w+)\//) {
                         if (&Apache::lonnet::allowed('c'.$role_code,$1)) {                         if (&Apache::lonnet::allowed('c'.$role_code,$1)) {
                            $allows=1;                             $allowed=1;
                         }                         }
                      } else {                     } else {
                         if (&Apache::lonnet::allowed('c'.$role_code,'/')) {                         if (&Apache::lonnet::allowed('c'.$role_code,'/')) {
                            $allows=1;                             $allowed=1;
                         }                         }
                      }                     }
                  }                 }
                  $r->print('<tr bgcolor=#"'.$bgcol.'"><td>');                 # I have no idea what the hell the above code does
                  my $active=1;                 # So the following is a check:
                  $active=0 if (($role_end_time) && ($now>$role_end_time));                 if ($allowed) {
                  if (($active) && ($allows)) {                     # If we are looking at a co-author role, make sure it is 
                     $r->print('<input type="checkbox" name="rev:'                     # for the current users construction space before we let 
                               .$thisrole.'">');                     # them revoke it.
                  } else {                     if (($role_code eq 'ca') && 
                     $r->print('&nbsp;');                         ($ENV{'request.role'} !~ /^dc/)) {
                  }                         if ($area !~ 
                  $r->print('</td><td>'.                             /^\/$ENV{'user.domain'}\/$ENV{'user.name'}/) {
                            &Apache::lonnet::plaintext($role_code).                             $allowed = 0;
                            '</td><td>'.$area.'</td><td>'.                         }
                            ($role_start_time ? localtime($role_start_time)                     }
                                              : '&nbsp;' )                 }
                            .'</td><td>'.                 my $row = '';
                            ($role_end_time   ? localtime($role_end_time)                 $row.='<tr bgcolor=#"'.$bgcol.'"><td>';
                                              : '&nbsp;' )                 my $active=1;
                            ."</td></tr>\n");                 $active=0 if (($role_end_time) && ($now>$role_end_time));
               }                 if (($active) && ($allowed)) {
                      $row.= '<input type="checkbox" name="rev:'.$thisrole.'">';
                  } else {
                      $row.='&nbsp;';
                  }
                  $row.= '</td><td>'.&Apache::lonnet::plaintext($role_code).
                         '</td><td>'.$area.
                         '</td><td>'.($role_start_time?localtime($role_start_time)
                                                      : '&nbsp;' ).
                         '</td><td>'.($role_end_time  ?localtime($role_end_time)
                                                      : '&nbsp;' )
                         ."</td></tr>\n";
                  $r->print($row);
            } # end of foreach        (table building loop)             } # end of foreach        (table building loop)
    $r->print('</table>');     $r->print('</table>');
         }  # End of unless          }  # End of unless
  my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain);   my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain);
  if ($currentauth=~/^krb4:/) {   if ($currentauth=~/^krb(4|5):/) {
     $currentauth=~/^krb4:(.*)/;      $currentauth=~/^krb(4|5):(.*)/;
     my $krbdefdom2=$1;      my $krbdefdom2=$1;
             my %param = ( formname => 'document.cu',              my %param = ( formname => 'document.cu',
                           kerb_def_dom => $krbdefdom                             kerb_def_dom => $krbdefdom 
Line 322  END Line 338  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=~/^krb4:/ or          unless ($currentauth=~/^krb(4|5):/ or
  $currentauth=~/^unix:/ or   $currentauth=~/^unix:/ or
  $currentauth=~/^internal:/ or   $currentauth=~/^internal:/ or
  $currentauth=~/^localauth:/   $currentauth=~/^localauth:/
Line 360  ENDBADAUTH Line 376  ENDBADAUTH
         } else { # Authentication type is valid          } else { # Authentication type is valid
     my $authformcurrent='';      my $authformcurrent='';
     my $authform_other='';      my $authform_other='';
     if ($currentauth=~/^krb4:/) {      if ($currentauth=~/^krb(4|5):/) {
  $authformcurrent=$authformkrb;   $authformcurrent=$authformkrb;
  $authform_other="<p>$authformint</p>\n".   $authform_other="<p>$authformint</p>\n".
                     "<p>$authformfsys</p><p>$authformloc</p>";                      "<p>$authformfsys</p><p>$authformloc</p>";
Line 483  sub phase_three { Line 499  sub phase_three {
 <head>  <head>
 <title>The LearningOnline Network with CAPA</title>  <title>The LearningOnline Network with CAPA</title>
 </head>  </head>
 <body bgcolor="#FFFFFF">  
 <img align="right" src="/adm/lonIcons/lonlogos.gif">  
 ENDTHREEHEAD  ENDTHREEHEAD
       my $title;
       if (exists($ENV{'form.makeuser'})) {
    $title='Set Privileges for New User';
       } else {
           $title='Modify User Privileges';
       }
       $r->print(&Apache::loncommon::bodytag($title));
     # Check Inputs      # Check Inputs
     if (! $ENV{'form.ccuname'} ) {      if (! $ENV{'form.ccuname'} ) {
  $r->print($error.'No login name specified.'.$end);   $r->print($error.'No login name specified.'.$end);
Line 520  ENDTHREEHEAD Line 541  ENDTHREEHEAD
     my $amode='';      my $amode='';
     my $genpwd='';      my $genpwd='';
     if ($ENV{'form.login'} eq 'krb') {      if ($ENV{'form.login'} eq 'krb') {
  $amode='krb4';   $amode='krb';
    $amode.=$ENV{'form.krbver'};
  $genpwd=$ENV{'form.krbarg'};   $genpwd=$ENV{'form.krbarg'};
     } elsif ($ENV{'form.login'} eq 'int') {      } elsif ($ENV{'form.login'} eq 'int') {
  $amode='internal';   $amode='internal';
Line 532  ENDTHREEHEAD Line 554  ENDTHREEHEAD
  $amode='localauth';   $amode='localauth';
  $genpwd=$ENV{'form.locarg'};   $genpwd=$ENV{'form.locarg'};
  $genpwd=" " if (!$genpwd);   $genpwd=" " if (!$genpwd);
     } elsif (($ENV{'form.login'} eq 'nochange')) {       } elsif (($ENV{'form.login'} eq 'nochange') ||
                ($ENV{'form.login'} eq ''        )) { 
         # There is no need to tell the user we did not change what they          # There is no need to tell the user we did not change what they
         # did not ask us to change.          # did not ask us to change.
           # If they are creating a new user but have not specified login
           # information this will be caught below.
     } else {      } else {
     $r->print($error.'Invalid login mode or password'.$end);          $r->print($error.'Invalid login mode or password'.$end);    
     return;      return;
Line 542  ENDTHREEHEAD Line 567  ENDTHREEHEAD
     if ($ENV{'form.makeuser'}) {      if ($ENV{'form.makeuser'}) {
         # Create a new user          # Create a new user
  $r->print(<<ENDNEWUSERHEAD);   $r->print(<<ENDNEWUSERHEAD);
 <h1>Create User</h1>  
 <h3>Creating user "$ENV{'form.ccuname'}" in domain "$ENV{'form.ccdomain'}"</h2>  <h3>Creating user "$ENV{'form.ccuname'}" in domain "$ENV{'form.ccdomain'}"</h2>
 ENDNEWUSERHEAD  ENDNEWUSERHEAD
         # Check for the authentication mode and password          # Check for the authentication mode and password
Line 555  ENDNEWUSERHEAD Line 579  ENDNEWUSERHEAD
         if (lc($desiredhost) eq 'default') {          if (lc($desiredhost) eq 'default') {
             $desiredhost = undef;              $desiredhost = undef;
         } else {          } else {
             my %home_servers = &Apache::loncommon::get_home_servers              my %home_servers = &Apache::loncommon::get_library_servers
                 ($ENV{'form.ccdomain'});                    ($ENV{'form.ccdomain'});  
             if (! exists($home_servers{$desiredhost})) {              if (! exists($home_servers{$desiredhost})) {
                 $r->print($error.'Invalid home server specified');                  $r->print($error.'Invalid home server specified');
Line 574  ENDNEWUSERHEAD Line 598  ENDNEWUSERHEAD
                                                $ENV{'form.ccdomain'});                                                 $ENV{'form.ccdomain'});
         $r->print('<br>Home server: '.$home.' '.          $r->print('<br>Home server: '.$home.' '.
                   $Apache::lonnet::libserv{$home});                    $Apache::lonnet::libserv{$home});
     } elsif ($ENV{'form.login'} ne 'nochange') {      } elsif (($ENV{'form.login'} ne 'nochange') &&
                ($ENV{'form.login'} ne ''        )) {
  # Modify user privileges   # Modify user privileges
  $r->print(<<ENDMODIFYUSERHEAD);   $r->print(<<ENDMODIFYUSERHEAD);
 <h1>Change User Privileges</h1>  
 <h2>User "$ENV{'form.ccuname'}" in domain "$ENV{'form.ccdomain'}"</h2>  <h2>User "$ENV{'form.ccuname'}" in domain "$ENV{'form.ccdomain'}"</h2>
 ENDMODIFYUSERHEAD  ENDMODIFYUSERHEAD
         if (! $amode || ! $genpwd) {          if (! $amode || ! $genpwd) {
Line 585  ENDMODIFYUSERHEAD Line 609  ENDMODIFYUSERHEAD
     return;      return;
  }   }
  # Only allow authentification modification if the person has authority   # Only allow authentification modification if the person has authority
  if (&Apache::lonnet::allowed('mau',$ENV{'user.domain'})) {   if (&Apache::lonnet::allowed('mau',$ENV{'form.ccdomain'})) {
     $r->print('Modifying authentication: '.      $r->print('Modifying authentication: '.
                       &Apache::lonnet::modifyuserauth(                        &Apache::lonnet::modifyuserauth(
        $ENV{'form.ccdomain'},$ENV{'form.ccuname'},         $ENV{'form.ccdomain'},$ENV{'form.ccuname'},

Removed from v.1.34  
changed lines
  Added in v.1.41


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