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

version 1.186, 2007/09/18 23:57:15 version 1.187, 2007/09/19 06:24:26
Line 68  use Apache::longroup; Line 68  use Apache::longroup;
 use LONCAPA qw(:DEFAULT :match);  use LONCAPA qw(:DEFAULT :match);
   
 my $loginscript; # piece of javascript used in two separate instances  my $loginscript; # piece of javascript used in two separate instances
 my $generalrule;  
 my $authformnop;  my $authformnop;
 my $authformkrb;  my $authformkrb;
 my $authformint;  my $authformint;
Line 76  my $authformfsys; Line 75  my $authformfsys;
 my $authformloc;  my $authformloc;
   
 sub initialize_authen_forms {  sub initialize_authen_forms {
       my ($dom,$curr_authtype) = @_; 
     my ($krbdefdom)=( $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/);      my ($krbdefdom)=( $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/);
     $krbdefdom= uc($krbdefdom);      $krbdefdom= uc($krbdefdom);
     my %param = ( formname => 'document.cu',      my %param = ( formname => 'document.cu',
                   kerb_def_dom => $krbdefdom                     kerb_def_dom => $krbdefdom,
                   );                    domain => $dom,
                   );
       if ($curr_authtype =~ /^(krb4|krb5|internal|localauth|unix):$/) {
           $param{'curr_authtype'} = $curr_authtype;
       }
 # no longer static due to configurable kerberos defaults  # no longer static due to configurable kerberos defaults
 #    $loginscript  = &Apache::loncommon::authform_header(%param);  #    $loginscript  = &Apache::loncommon::authform_header(%param);
     $generalrule  = &Apache::loncommon::authform_authorwarning(%param);  
     $authformnop  = &Apache::loncommon::authform_nochange(%param);      $authformnop  = &Apache::loncommon::authform_nochange(%param);
 # no longer static due to configurable kerberos defaults  # no longer static due to configurable kerberos defaults
 #    $authformkrb  = &Apache::loncommon::authform_kerberos(%param);  #    $authformkrb  = &Apache::loncommon::authform_kerberos(%param);
Line 425  sub print_user_modification_page { Line 428  sub print_user_modification_page {
  &print_username_entry_form($r,$usermsg);   &print_username_entry_form($r,$usermsg);
         return;          return;
     }      }
     my ($instsrch,$rulematch,$rules,%inst_results);      my ($curr_authtype,$instsrch,$rulematch,$rules,%inst_results);
     my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);      my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);
     if ($uhome eq 'no_host') {      if ($uhome eq 'no_host') {
         $instsrch =          $instsrch =
Line 442  sub print_user_modification_page { Line 445  sub print_user_modification_page {
             &print_username_entry_form($r,$usercheckmsg);              &print_username_entry_form($r,$usercheckmsg);
             return;              return;
         }          }
       } else {
           $curr_authtype = 
               &Apache::lonnet::queryauthenticate($ccuname,$ccdomain);
     }      }
     if ($response) {      if ($response) {
         $response = '<br />'.$response          $response = '<br />'.$response
Line 453  sub print_user_modification_page { Line 459  sub print_user_modification_page {
   
     my %param = ( formname => 'document.cu',      my %param = ( formname => 'document.cu',
                   kerb_def_dom => $krbdefdom,                    kerb_def_dom => $krbdefdom,
                   kerb_def_auth => $krbdef                    kerb_def_auth => $krbdef,
                     curr_authtype => $curr_authtype,
                     domain => $ccdomain,
                 );                  );
     $loginscript  = &Apache::loncommon::authform_header(%param);      $loginscript  = &Apache::loncommon::authform_header(%param);
     $authformkrb  = &Apache::loncommon::authform_kerberos(%param);      $authformkrb  = &Apache::loncommon::authform_kerberos(%param);
Line 701  ENDFORMINFO Line 709  ENDFORMINFO
         }          }
     }      }
     if ($uhome eq 'no_host') {      if ($uhome eq 'no_host') {
         my $home_server_list=  
             '<option value="default" selected>default</option>'."\n".  
                 &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",
Line 742  ENDFORMINFO Line 746  ENDFORMINFO
             $portfolioform = &portfolio_quota($ccuname,$ccdomain);              $portfolioform = &portfolio_quota($ccuname,$ccdomain);
         }          }
  my $genhelp=&Apache::loncommon::help_open_topic('Generation');   my $genhelp=&Apache::loncommon::help_open_topic('Generation');
         &initialize_authen_forms();          &initialize_authen_forms($ccdomain);
  $r->print(<<ENDTITLE);   $r->print(<<ENDTITLE);
 $start_page  $start_page
 $crumbs  $crumbs
 <h1>$lt{'cnu'}</h1>  
 $response  $response
 $forminfo  $forminfo
 <h2>$lt{'nu'} "$ccuname" $lt{'ind'} $ccdomain</h2>  <h2>$lt{'cnu'} "$ccuname" $lt{'ind'} $ccdomain</h2>
 <script type="text/javascript" language="Javascript">  <script type="text/javascript" language="Javascript">
 $loginscript  $loginscript
 </script>  </script>
Line 772  ENDTITLE Line 775  ENDTITLE
             $r->print(&Apache::lonhtmlcommon::row_closure(1));              $r->print(&Apache::lonhtmlcommon::row_closure(1));
         }          }
         $r->print(&Apache::lonhtmlcommon::end_pick_box());          $r->print(&Apache::lonhtmlcommon::end_pick_box());
         $r->print(<<ENDNEWUSER);          my ($home_server_pick,$numlib) = 
 <br />              &Apache::loncommon::home_server_form_item($ccdomain,'hserver',
 $lt{'hs'}: <select name="hserver" size="1"> $home_server_list </select>                                                        'default','hide');
           if ($numlib > 1) {
               $r->print("
 <br />  <br />
 <hr />  $lt{'hs'}: $home_server_pick
 <h3>$lt{'lg'}</h3>  <br />");
 ENDNEWUSER          } else {
               $r->print($home_server_pick);
           }
           $r->print("<hr />\n".'<h3>'.$lt{'lg'}.'</h3>');
         my ($fixedauth,$varauth,$authmsg);           my ($fixedauth,$varauth,$authmsg); 
         if ($rulematch) {          if ($rulematch) {
             if (ref($rules) eq 'HASH') {              if (ref($rules) eq 'HASH') {
                 if (ref($rules->{$rulematch}) eq 'HASH') {                  if (ref($rules->{$rulematch}) eq 'HASH') {
                     my $authtype = $rules->{$rulematch}{'authtype'};                      my $authtype = $rules->{$rulematch}{'authtype'};
                     if ($authtype !~ /^(krb4|krb5|int|fsys|loc)$/) {                      if ($authtype !~ /^(krb4|krb5|int|fsys|loc)$/) {
                         $r->print(&set_login());                          $r->print(&set_login($ccdomain));
                     } else {                       } else { 
                         my $authparm = $rules->{$rulematch}{'authparm'};                          my $authparm = $rules->{$rulematch}{'authparm'};
                         if ($authtype =~ /^krb(4|5)$/) {                          if ($authtype =~ /^krb(4|5)$/) {
Line 811  KERB Line 819  KERB
                         }                          }
                     }                      }
                 } else {                  } else {
                     $r->print(&set_login());                      $r->print(&set_login($ccdomain));
                 }                  }
             }              }
             if ($authmsg) {              if ($authmsg) {
Line 822  $varauth Line 830  $varauth
 ENDAUTH  ENDAUTH
             }              }
         } else {          } else {
             $r->print(&set_login());               $r->print(&set_login($ccdomain)); 
          }          }
          $r->print(<<ENDPORT);          $r->print(<<ENDPORT);
 <hr />  <hr />
 $portfolioform  $portfolioform
 ENDPORT  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 for",
                     'usr'  => "User",                      
                     'id'   => "in domain",                      'id'   => "in domain",
                     'fn'   => "first name",                      'fn'   => "first name",
                     'mn'   => "middle name",                      'mn'   => "middle name",
Line 842  ENDPORT Line 849  ENDPORT
  $r->print(<<ENDCHANGEUSER);   $r->print(<<ENDCHANGEUSER);
 $start_page  $start_page
 $crumbs  $crumbs
 <h1>$lt{'cup'}</h1>  
 $forminfo  $forminfo
 <h2>$lt{'usr'} "$ccuname" $lt{'id'} "$ccdomain"</h2>  <h2>$lt{'cup'} "$ccuname" $lt{'id'} "$ccdomain"</h2>
 ENDCHANGEUSER  ENDCHANGEUSER
         # Get the users information          # Get the users information
         my %userenv =           my %userenv = 
Line 1065  END Line 1071  END
     $currentauth=~/^krb(4|5):(.*)/;      $currentauth=~/^krb(4|5):(.*)/;
     my $krbdefdom=$2;      my $krbdefdom=$2;
             my %param = ( formname => 'document.cu',              my %param = ( formname => 'document.cu',
                           kerb_def_dom => $krbdefdom                             kerb_def_dom => $krbdefdom,
                             domain => $ccdomain,
                             curr_authtype => $currentauth, 
                           );                            );
             $loginscript  = &Apache::loncommon::authform_header(%param);              $loginscript  = &Apache::loncommon::authform_header(%param);
  }   }
  # Check for a bad authentication type   # Check for a bad authentication type
         if ($currentauth !~ /^(krb4|krb5|unix|internal|localauth):/) {           if ($currentauth !~ /^(krb4|krb5|unix|internal|localauth):/) {
             # bad authentication scheme      # bad authentication scheme
     if (&Apache::lonnet::allowed('mau',$ccdomain)) {      if (&Apache::lonnet::allowed('mau',$ccdomain)) {
                 &initialize_authen_forms();                  &initialize_authen_forms($ccdomain);
  my %lt=&Apache::lonlocal::texthash(   my %lt=&Apache::lonlocal::texthash(
                                'err'   => "ERROR",                                 'err'   => "ERROR",
        'uuas'  => "This user has an unrecognized authentication scheme",         'uuas'  => "This user has an unrecognized authentication scheme",
                                'sldb'  => "Please specify login data below",                                 'sldb'  => "Please specify login data below",
                                'ld'    => "Login Data"                                 'ld'    => "Login Data"
    );     );
                   my $choices = &set_login($ccdomain);
  $r->print(<<ENDBADAUTH);   $r->print(<<ENDBADAUTH);
 <hr />  <hr />
 <script type="text/javascript" language="Javascript">  <script type="text/javascript" language="Javascript">
Line 1088  $loginscript Line 1097  $loginscript
 <font color='#ff0000'>$lt{'err'}:</font>  <font color='#ff0000'>$lt{'err'}:</font>
 $lt{'uuas'} ($currentauth). $lt{'sldb'}.  $lt{'uuas'} ($currentauth). $lt{'sldb'}.
 <h3>$lt{'ld'}</h3>  <h3>$lt{'ld'}</h3>
 <p>$generalrule</p>  $choices
 <p>$authformkrb</p>  
 <p>$authformint</p>  
 <p>$authformfsys</p>  
 <p>$authformloc</p>  
 ENDBADAUTH  ENDBADAUTH
             } else {               } else { 
                 # This user is not allowed to modify the user's                   # This user is not allowed to modify the user's 
Line 1112  ENDBADAUTH Line 1117  ENDBADAUTH
         } else { # Authentication type is valid          } else { # Authentication type is valid
     my $authformcurrent='';      my $authformcurrent='';
     my $authform_other='';      my $authform_other='';
             &initialize_authen_forms();              &initialize_authen_forms($ccdomain,$currentauth);
     if ($currentauth=~/^krb(4|5):/) {              my ($authformcurrent,$authform_other,$can_modify) = 
  $authformcurrent=$authformkrb;                  &modify_login_block($ccdomain,$currentauth);
  $authform_other="<p>$authformint</p>\n".  
                     "<p>$authformfsys</p><p>$authformloc</p>";  
     }  
     elsif ($currentauth=~/^internal:/) {  
  $authformcurrent=$authformint;  
  $authform_other="<p>$authformkrb</p>".  
                     "<p>$authformfsys</p><p>$authformloc</p>";  
     }  
     elsif ($currentauth=~/^unix:/) {  
  $authformcurrent=$authformfsys;  
  $authform_other="<p>$authformkrb</p>".  
                     "<p>$authformint</p><p>$authformloc;</p>";  
     }  
     elsif ($currentauth=~/^localauth:/) {  
  $authformcurrent=$authformloc;  
  $authform_other="<p>$authformkrb</p>".  
                     "<p>$authformint</p><p>$authformfsys</p>";  
     }  
             $authformcurrent.=' <i>(will override current values)</i><br />';  
             if (&Apache::lonnet::allowed('mau',$ccdomain)) {              if (&Apache::lonnet::allowed('mau',$ccdomain)) {
  # Current user has login modification privileges   # Current user has login modification privileges
  my %lt=&Apache::lonlocal::texthash(   my %lt=&Apache::lonlocal::texthash(
Line 1146  ENDBADAUTH Line 1132  ENDBADAUTH
 $loginscript  $loginscript
 </script>  </script>
 <h3>$lt{'ccld'}</h3>  <h3>$lt{'ccld'}</h3>
 <p>$generalrule</p>  <p>$authformnop
 <p>$authformnop</p>  
 <p>$authformcurrent</p>  
 <h3>$lt{'enld'}</h3>  
 $authform_other  
 ENDOTHERAUTHS  ENDOTHERAUTHS
                   if ($can_modify) {
                       $r->print('</p><p>'.$authformcurrent.'</p>');
                   } else {
                       $r->print('&nbsp;('.$authformcurrent.')</p>'); 
                   }
                   if ($authform_other ne '') {
                       $r->print('<h3>'.$lt{'enld'}.'</h3>'."\n".
                                 $authform_other);
                   }
             } else {              } else {
                 if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) {                  if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) {
                     my %lt=&Apache::lonlocal::texthash(                      my %lt=&Apache::lonlocal::texthash(
Line 1170  ENDNOPRIV Line 1161  ENDNOPRIV
         if (&Apache::lonnet::allowed('mpq',$ccdomain)) {          if (&Apache::lonnet::allowed('mpq',$ccdomain)) {
             # Current user has quota modification privileges              # Current user has quota modification privileges
             $r->print(&portfolio_quota($ccuname,$ccdomain));              $r->print(&portfolio_quota($ccuname,$ccdomain));
         } elsif (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {          } elsif (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) { 
             my %lt=&Apache::lonlocal::texthash(              my %lt=&Apache::lonlocal::texthash(
                 'dska'  => "Disk space allocated to user's portfolio files",                  'dska'  => "Disk space allocated to user's portfolio files",
                 'youd'  => "You do not have privileges to modify the portfolio quota for this user.",                  'youd'  => "You do not have privileges to modify the portfolio quota for this user.",
Line 1295  ENDNOPORTPRIV Line 1286  ENDNOPORTPRIV
 }  }
   
 sub set_login {  sub set_login {
     my $response = (<<ENDAUTH);      my ($dom) = @_;
 <p>$generalrule </p>      my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom);
 <p>$authformkrb </p>      my $response;
 <p>$authformint </p>      my ($authnum,%can_assign) = 
 <p>$authformfsys</p>          &Apache::loncommon::get_assignable_auth($dom);
 <p>$authformloc </p>      if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) {
 ENDAUTH          $response .= "<p>$authformkrb </p>\n";
       }
       if ($can_assign{'int'}) {
           $response .= "<p>$authformint </p>\n"
       }
       if ($can_assign{'loc'}) {
           $response .= "<p>$authformloc </p>\n";
       }
     return $response;      return $response;
 }  }
   
   sub modify_login_block {
       my ($dom,$currentauth) = @_;
       my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom);
       my ($authnum,%can_assign) =
           &Apache::loncommon::get_assignable_auth($dom);
       my ($authformcurrent,$authform_other,$show_override_msg);
       if ($currentauth=~/^krb(4|5):/) {
           $authformcurrent=$authformkrb;
           if ($can_assign{'int'}) {
               $authform_other = "<p>$authformint </p>\n"
           }
           if ($can_assign{'loc'}) {
               $authform_other .= "<p>$authformloc </p>\n";
           }
           if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) {
               $show_override_msg = 1;
           }
       } elsif ($currentauth=~/^internal:/) {
           $authformcurrent=$authformint;
           if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) {
               $authform_other = "<p>$authformkrb </p>\n"
           }
           if ($can_assign{'loc'}) {
               $authform_other .= "<p>$authformloc </p>\n";
           }
           if ($can_assign{'int'}) {
               $show_override_msg = 1;
           }
       } elsif ($currentauth=~/^unix:/) {
           $authformcurrent=$authformfsys;
           if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) {
               $authform_other = "<p>$authformkrb </p>\n"
           }
           if ($can_assign{'int'}) {
               $authform_other .= "<p>$authformint </p>\n"
           }
           if ($can_assign{'loc'}) {
               $authform_other .= "<p>$authformloc </p>\n";
           }
           if ($can_assign{'fsys'}) {
               $show_override_msg = 1;
           }
       } elsif ($currentauth=~/^localauth:/) {
           $authformcurrent=$authformloc;
           if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) {
               $authform_other = "<p>$authformkrb </p>\n"
           }
           if ($can_assign{'int'}) {
               $authform_other .= "<p>$authformint </p>\n"
           }
           if ($can_assign{'loc'}) {
               $show_override_msg = 1;
           }
       }
       if ($show_override_msg) {
           $authformcurrent.= ' <span class="LC_cusr_emph">'.
                               &mt('will override current values').
                               '</span><br />';
       }
       return ($authformcurrent,$authform_other,$show_override_msg); 
   }
   
 # ================================================================= Phase Three  # ================================================================= Phase Three
 sub update_user_data {  sub update_user_data {
     my ($r) = @_;       my ($r) = @_; 

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


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