Diff for /loncom/auth/lonroles.pm between versions 1.86 and 1.93

version 1.86, 2004/02/19 21:45:22 version 1.93, 2004/07/03 19:44:53
Line 47  sub redirect_user { Line 47  sub redirect_user {
     $r->send_http_header;      $r->send_http_header;
     my $swinfo=&Apache::lonmenu::rawconfig();      my $swinfo=&Apache::lonmenu::rawconfig();
     my $bodytag=&Apache::loncommon::bodytag('Switching Role');      my $bodytag=&Apache::loncommon::bodytag('Switching Role');
     $r->print (<<ENDREDIR);  # Note to style police: 
   # This must only replace the spaces, nothing else, or it bombs elsewhere.
       $url=~s/ /\%20/g;
       $r->print(<<ENDREDIR);
 <head><title>$title</title>  <head><title>$title</title>
 <meta HTTP-EQUIV="Refresh" CONTENT="1; url=$url">  <meta HTTP-EQUIV="Refresh" CONTENT="1; url=$url">
 </head>  </head>
Line 109  sub handler { Line 112  sub handler {
 # check for keyed access  # check for keyed access
     if (($role eq 'st') &&       if (($role eq 'st') && 
                        ($ENV{'course.'.$cdom.'_'.$cnum.'.keyaccess'} eq 'yes')) {                         ($ENV{'course.'.$cdom.'_'.$cnum.'.keyaccess'} eq 'yes')) {
          unless (&Apache::lonnet::validate_access_key(  # who is key authority?
    my $authdom=$cdom;
    my $authnum=$cnum;
    if ($ENV{'course.'.$cdom.'_'.$cnum.'.keyauth'}) {
       ($authnum,$authdom)=
    split(/\W/,$ENV{'course.'.$cdom.'_'.$cnum.'.keyauth'});
    }
   # check with key authority
    unless (&Apache::lonnet::validate_access_key(
      $ENV{'environment.key.'.$cdom.'_'.$cnum},       $ENV{'environment.key.'.$cdom.'_'.$cnum},
      $cdom,$cnum)) {       $authdom,$authnum)) {
 # there is no valid key  # there is no valid key
      if ($ENV{'form.newkey'}) {       if ($ENV{'form.newkey'}) {
 # student attempts to register a new key  # student attempts to register a new key
    &Apache::loncommon::content_type($r,'text/html');
    &Apache::loncommon::no_cache($r);
    $r->send_http_header;
    my $swinfo=&Apache::lonmenu::rawconfig();
    my $bodytag=&Apache::loncommon::bodytag
       ('Verifying Access Key to Unlock this Course');
    my $buttontext=&mt('Enter Course');
    my $message=&mt('Successfully registered key');
    my $assignresult=
        &Apache::lonnet::assign_access_key(
        $ENV{'form.newkey'},
        $authdom,$authnum,
        $cdom,$cnum,
                                                        $ENV{'user.domain'},
        $ENV{'user.name'},
         'Assigned from '.$ENV{'REMOTE_ADDR'}.' at '.localtime().' for '.
                                                        $trolecode);
    unless ($assignresult eq 'ok') {
        $assignresult=~s/^error\:\s*//;
        $message=&mt($assignresult).
        '<br /><a href="/adm/logout">'.
        &mt('Logout').'</a>';
        $buttontext=&mt('Re-Enter Key');
    }
    $r->print(<<ENDENTEREDKEY);
   <head><title>Verifying Course Access Key</title>
   </head>
   <html>
   $bodytag
   <script>
   $swinfo
   </script>
   <form method="post">
   <input type="hidden" name="selectrole" value="1" />
   <input type="hidden" name="$trolecode" value="1" />
   <font size="+2">$message</font><br />
   <input type="submit" value="$buttontext" />
   </form>
   </body></html>
   ENDENTEREDKEY
                                    return OK;
      } else {       } else {
 # print form to enter a new key  # print form to enter a new key
  &Apache::loncommon::content_type($r,'text/html');   &Apache::loncommon::content_type($r,'text/html');
Line 132  $bodytag Line 184  $bodytag
 $swinfo  $swinfo
 </script>  </script>
 <form method="post">  <form method="post">
 <input type="hidden" name="selectrole" value="$ENV{'form.selectrole'}" />  <input type="hidden" name="selectrole" value="1" />
   <input type="hidden" name="$trolecode" value="1" />
 <input type="text" size="20" name="newkey" value="$ENV{'form.newkey'}" />  <input type="text" size="20" name="newkey" value="$ENV{'form.newkey'}" />
 <input type="submit" value="Enter key" />  <input type="submit" value="Enter key" />
 </form>  </form>
Line 142  ENDENTERKEY Line 195  ENDENTERKEY
      }       }
  }   }
      }       }
       &Apache::lonnet::log($ENV{'user.domain'},
    $ENV{'user.name'},
    $ENV{'user.home'},
    "Role ".$trolecode);
                     my $tadv=0;                      my $tadv=0;
                     if (($trolecode!~/^st/) &&                       if (($trolecode!~/^st/) && 
                         ($trolecode!~/^ta/) &&                           ($trolecode!~/^ta/) && 
Line 223  ENDENTERKEY Line 280  ENDENTERKEY
   
     my $swinfo=&Apache::lonmenu::rawconfig();      my $swinfo=&Apache::lonmenu::rawconfig();
     my $bodytag=&Apache::loncommon::bodytag('User Roles');      my $bodytag=&Apache::loncommon::bodytag('User Roles');
     my $helptag='<table><tr><td>'.&Apache::loncommon::help_open_topic      my $helptag='<table><tr><td>'.&Apache::loncommon::help_open_menu('','General Intro','General_Intro','User Roles',1,'').'</td></td></tr></table>';
      ("General_Intro",&mt("Click here for help")).'</td><td>'.  
       &Apache::loncommon::help_open_faq(1,&mt('Click here for FAQ')).'</td><td>'.  
       &Apache::loncommon::help_open_bug('',&mt('Click here to report bugs')).'</td></tr></table>';  
     $r->print(<<ENDHEADER);      $r->print(<<ENDHEADER);
 <html>  <html>
 <head>  <head>
Line 525  ENDHEADER Line 579  ENDHEADER
  $r->print('</form></body></html>');   $r->print('</form></body></html>');
  return OK;   return OK;
 # Is there only one choice?  # Is there only one choice?
     } elsif ($countactive==1) {      } elsif (($countactive==1) && ($ENV{'request.role'} eq 'cm')) {
  $r->print('<h3>'.&mt('Please stand by.').'</h3>'.   $r->print('<h3>'.&mt('Please stand by.').'</h3>'.
     '<input type="hidden" name="'.$possiblerole.'" value="1" />');      '<input type="hidden" name="'.$possiblerole.'" value="1" />');
  $r->print("</form>\n");   $r->print("</form>\n");

Removed from v.1.86  
changed lines
  Added in v.1.93


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