Diff for /loncom/auth/lonroles.pm between versions 1.98 and 1.103

version 1.98, 2004/08/23 18:57:16 version 1.103, 2004/11/09 16:18:51
Line 88  sub handler { Line 88  sub handler {
  if ($ENV{'request.course.id'}) {   if ($ENV{'request.course.id'}) {
     my %temp=('logout_'.$ENV{'request.course.id'} => time);      my %temp=('logout_'.$ENV{'request.course.id'} => time);
     &Apache::lonnet::put('email_status',\%temp);      &Apache::lonnet::put('email_status',\%temp);
         }      &Apache::lonnet::delenv('user.state.'.$ENV{'request.course.id'});
    }
  &Apache::lonnet::appenv("request.course.id"   => '',   &Apache::lonnet::appenv("request.course.id"   => '',
  "request.course.fn"   => '',   "request.course.fn"   => '',
  "request.course.uri"  => '',   "request.course.uri"  => '',
Line 98  sub handler { Line 99  sub handler {
  "request.role.domain" => $ENV{'user.domain'});   "request.role.domain" => $ENV{'user.domain'});
         foreach $envkey (keys %ENV) {          foreach $envkey (keys %ENV) {
             next if ($envkey!~/^user\.role\./);              next if ($envkey!~/^user\.role\./);
     my (undef,undef,$role,@pwhere)=split(/\./,$envkey);              my ($where,$trolecode,$role,$tstatus,$tend,$tstart);
             my $where=join('.',@pwhere);              &role_status($envkey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend);
             my $trolecode=$role.'.'.$where;  
             if ($ENV{'form.'.$trolecode}) {              if ($ENV{'form.'.$trolecode}) {
  my ($tstart,$tend)=split(/\./,$ENV{$envkey});  
  my $tstatus='is';  
  if ($tstart) {  
     if ($tstart>$then) {   
  $tstatus='future';  
     }  
  }  
  if ($tend) {  
     if ($tend<$then) { $tstatus='expired'; }  
     if ($tend<$now) { $tstatus='will_not'; }  
  }  
  if ($tstatus eq 'is') {   if ($tstatus eq 'is') {
     $where=~s/^\///;      $where=~s/^\///;
     my ($cdom,$cnum,$csec)=split(/\//,$where);      my ($cdom,$cnum,$csec)=split(/\//,$where);
Line 206  ENDENTERKEY Line 195  ENDENTERKEY
  $ENV{'user.name'},   $ENV{'user.name'},
  $ENV{'user.home'},   $ENV{'user.home'},
  "Role ".$trolecode);   "Role ".$trolecode);
                     my $tadv=0;      
                     if (($trolecode!~/^st/) &&   
                         ($trolecode!~/^ta/) &&   
                         ($trolecode!~/^cm/)) { $tadv=1; }  
     &Apache::lonnet::appenv(      &Apache::lonnet::appenv(
                                            'request.role'        => $trolecode,     'request.role'        => $trolecode,
    'request.role.adv'    => $tadv,  
    'request.role.domain' => $cdom,     'request.role.domain' => $cdom,
    'request.course.sec'  => $csec);     'request.course.sec'  => $csec);
                       my $tadv=0;
       if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
       &Apache::lonnet::appenv('request.role.adv'    => $tadv);
   
     my $msg=&mt('Entering course ...');      my $msg=&mt('Entering course ...');
   
     if (($cnum) && ($role ne 'ca')) {      if (($cnum) && ($role ne 'ca')) {
Line 379  ENDHEADER Line 368  ENDHEADER
  my $roletext;   my $roletext;
  my $sortkey;   my $sortkey;
         if ($envkey=~/^user\.role\./) {          if ($envkey=~/^user\.role\./) {
     my (undef,undef,$role,@pwhere)=split(/\./,$envkey);              my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend,$tfont);
               &role_status($envkey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend);
             next if (!defined($role) || $role eq '');              next if (!defined($role) || $role eq '');
             my $where=join('.',@pwhere);              $tremark='';
             my $trolecode=$role.'.'.$where;              $tpstart='&nbsp;';
             my ($tstart,$tend)=split(/\./,$ENV{$envkey});              $tpend='&nbsp;';
             my $tremark='';              $tfont='#000000';
             my $tstatus='is';  
             my $tpstart='&nbsp;';  
             my $tpend='&nbsp;';  
             my $tfont='#000000';  
             if ($tstart) {              if ($tstart) {
  if ($tstart>$then) {   
                     $tstatus='future';  
                     if ($tstart<$now) { $tstatus='will'; }  
                 }  
                 $tpstart=&Apache::lonlocal::locallocaltime($tstart);                  $tpstart=&Apache::lonlocal::locallocaltime($tstart);
             }              }
             if ($tend) {              if ($tend) {
                 if ($tend<$then) {   
                     $tstatus='expired';   
                 } elsif ($tend<$now) {   
                     $tstatus='will_not';   
                 }  
                 $tpend=&Apache::lonlocal::locallocaltime($tend);                  $tpend=&Apache::lonlocal::locallocaltime($tend);
             }              }
             if ($ENV{'request.role'} eq $trolecode) {              if ($ENV{'request.role'} eq $trolecode) {
Line 605  ENDHEADER Line 582  ENDHEADER
     unless ($nochoose) { $r->print('<th>&nbsp;</th>'); }      unless ($nochoose) { $r->print('<th>&nbsp;</th>'); }
     $r->print('<th>'.&mt('User Role').'</th><th colspan=2>'.&mt('Extent').      $r->print('<th>'.&mt('User Role').'</th><th colspan=2>'.&mt('Extent').
          '</th><th>'.&mt('Start').'</th><th>'.&mt('End').'</th><th>'.           '</th><th>'.&mt('Start').'</th><th>'.&mt('End').'</th><th>'.
       &mt('Remark').'</th></tr>'."\n");        &mt('Remarks and Calendar Announcements').'</th></tr>'."\n");
     my $doheaders=-1;      my $doheaders=-1;
     foreach my $type ('Construction Space','Course','Domain','System') {      foreach my $type ('Construction Space','Course','Domain','System') {
  my $haverole=0;   my $haverole=0;
Line 620  ENDHEADER Line 597  ENDHEADER
  my $output;   my $output;
  foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {   foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
     if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) {       if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) { 
  $output.=&mt($roletext{$sortrole{$which}});   $output.=$roletext{$sortrole{$which}};
     }      }
  }   }
  if ($output) {   if ($output) {
Line 718  ENDHEADER Line 695  ENDHEADER
     }      }
     $r->print("</body></html>\n");      $r->print("</body></html>\n");
     return OK;      return OK;
 }   }
   
   sub role_status {
       my ($rolekey,$then,$now,$role,$where,$trolecode,$tstatus,$tstart,$tend) = @_;
       my @pwhere = ();
       if (exists($ENV{$rolekey}) && $ENV{$rolekey} ne '') {
           (undef,undef,$$role,@pwhere)=split(/\./,$rolekey);
           unless (!defined($$role) || $$role eq '') {
               $$where=join('.',@pwhere);
               $$trolecode=$$role.'.'.$$where;
               ($$tstart,$$tend)=split(/\./,$ENV{$rolekey});
               $$tstatus='is';
               if ($$tstart) {
                   if ($tstart>$then) {
                       $tstatus='future';
                       if ($tstart<$now) { $tstatus='will'; }
                   }
                   if ($$tstart>$then) {
                       $$tstatus='future';
                       if ($$tstart<$now) { $$tstatus='will'; }
                   }
               }
               if ($$tend) {
                   if ($$tend<$then) {
                       $$tstatus='expired';
                   } elsif ($$tend<$now) {
                        $$tstatus='will_not'; 
                   }
               }
           }
       }
   }
   
 1;  1;
 __END__  __END__

Removed from v.1.98  
changed lines
  Added in v.1.103


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