Diff for /loncom/auth/lonroles.pm between versions 1.101 and 1.102

version 1.101, 2004/11/02 23:22:46 version 1.102, 2004/11/09 15:52:29
Line 99  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 380  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) {    if ($tstart>$then) { 
                     $tstatus='future';                      $tstatus='future';
Line 719  ENDHEADER Line 704  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 ($$tend) {
                   if ($$tend<$then) {
                       $$tstatus='expired';
                       if ($$tend<$now) { $$tstatus='will_not'; }
                   }
               }
           }
       }
   }
   
 1;  1;
 __END__  __END__

Removed from v.1.101  
changed lines
  Added in v.1.102


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