Diff for /loncom/interface/lonmsgdisplay.pm between versions 1.14 and 1.15

version 1.14, 2006/04/25 20:02:30 version 1.15, 2006/04/25 21:25:13
Line 1275  sub get_blockdates { Line 1275  sub get_blockdates {
                          $env{'course.'.$env{'request.course.id'}.'.domain'},                           $env{'course.'.$env{'request.course.id'}.'.domain'},
                          $env{'course.'.$env{'request.course.id'}.'.num'}                           $env{'course.'.$env{'request.course.id'}.'.num'}
                          );                           );
     $$blockcount = keys %{$records};      $$blockcount = keys(%{$records});
                                                                                                                
     foreach (keys %{$records}) {      if ((keys(%{$records}))[0] =~ /^error: 2 /) {
         if ($_ eq 'error: 2 tie(GDBM) Failed while attempting dump') {   $records = {};
             $$blockcount = 0;   $$blockcount = 0;
             last;  
         }  
     }      }
 }  }
   
Line 1319  END Line 1317  END
         my ($start,$end) = split/____/,$_;          my ($start,$end) = split/____/,$_;
         my $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.$parmcount,$start,$onchange);          my $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.$parmcount,$start,$onchange);
         my $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.$parmcount,$end,$onchange);          my $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.$parmcount,$end,$onchange);
  my (@data,$setuname,$setudom,$title);  
  @data = split(/:/,$$records{$_},3);   my ($setuname,$setudom,$title) = &parse_block_record($$records{$_});
  if (scalar(@data) eq 2) {  
     $title = $data[1];  
     ($setuname,$setudom) = split(/@/,$data[0]);  
  } else {  
     ($setuname,$setudom,$title) = @data;  
  }  
         my $settername = &Apache::loncommon::plainname($setuname,$setudom);          my $settername = &Apache::loncommon::plainname($setuname,$setudom);
         $r->print(<<"END");          $r->print(<<"END");
        <tr bgcolor="$bgcols[$iter]">         <tr bgcolor="$bgcols[$iter]">
Line 1352  END Line 1344  END
     return $parmcount;      return $parmcount;
 }  }
   
   sub parse_block_record {
       my ($record) = @_;
       my ($setuname,$setudom,$title);
       my @data = split(/:/,$record,3);
       if (scalar(@data) eq 2) {
    $title = $data[1];
    ($setuname,$setudom) = split(/@/,$data[0]);
       } else {
    ($setuname,$setudom,$title) = @data;
       }
       return ($setuname,$setudom,$title);
   }
   
 sub display_addblocker_table {  sub display_addblocker_table {
     my ($r,$parmcount,$ltext) = @_;      my ($r,$parmcount,$ltext) = @_;
     my $start = time;      my $start = time;
Line 1402  END Line 1407  END
 sub blockcheck {  sub blockcheck {
     my ($setters,$startblock,$endblock) = @_;      my ($setters,$startblock,$endblock) = @_;
     # Retrieve active student roles and active course coordinator/instructor roles      # Retrieve active student roles and active course coordinator/instructor roles
     my @livecses = ();      my %live_courses =
     my @staffcses = ();   map { $_ => 1} &Apache::loncommon::findallcourses();
     $$startblock = 0;      # FIXME should really probe for apriv, but ::allowed can only probe the 
     $$endblock = 0;      #       currently active role
     foreach (keys %env) {      my %staff_of =
         if ($_ =~ m-^user\.role\.(st|cc|in)\./(.+)$-) {   map { $_ => 1} &Apache::loncommon::findallcourses(['cc','in']);
             my $role = $1;  
             my $cse = $2;      # Retrieve blocking times and identity of blocker for active courses
             $cse =~ s|/|_|;      # for students.
             if ($env{$_} =~ m/^(\d*)\.(\d*)$/) {      return if (!%live_courses);
                 unless (($2 > 0 && $2 < time) || ($1 > time)) {  
                     if ($role eq 'st') {      &Apache::lonnet::logthis("hmm");
                         push @livecses, $cse;      &Apache::lonnet::logthis(join(" ",%live_courses));
                     } else {      &Apache::lonnet::logthis(join(" ",%staff_of));
                         unless (grep/^$cse$/,@staffcses) {  
                             push @staffcses, $cse;      foreach my $course (keys(%live_courses)) {
                         }   my ($cdom,$cnum) = split(/_/,$course);
                     }  
                 }   # if they are a staff member and are currently not playing student
             }   next if ( $staff_of{$course} 
         } elsif ($_ =~ m-user\.role\.cr/(\w+)/(\w+)/([^/]+)\./(.+)$- ) {     && ($env{'request.role'} !~ m{^st\./$cdom/$cnum}));
             my $rolepriv = $env{'user.role..rolesdef_'.$3};  
         }   $setters->{$course} = {};
     }   $setters->{$course}{'staff'} = [];
     # Retrieve blocking times and identity of blocker for active courses for students.   $setters->{$course}{'times'} = [];
     if (@livecses > 0) {   my %records = &Apache::lonnet::dump('comm_block',$cdom,$cnum);
         foreach my $cse (@livecses) {   foreach my $record (keys %records) {
             my ($cdom,$crs) = split/_/,$cse;      my ($start,$end) = ($record =~ m/^(\d+)____(\d+)$/);
             if ( (grep/^$cse$/,@staffcses) && ($env{'request.role'} !~ m-^st\./$cdom/$crs$-) ) {      if ($start <= time && $end >= time) {
                 next;   my ($staff_name,$staff_dom,$title) = 
             } else {      &parse_block_record($records{$record});
                 %{$$setters{$cse}} = ();   push(@{$$setters{$course}{'staff'}}, [$staff_name,$staff_dom]);
                 @{$$setters{$cse}{'staff'}} = ();   push(@{$$setters{$course}{'times'}}, [$start,$end]);
                 @{$$setters{$cse}{'times'}} = ();   if ( ($$startblock == 0) || ($$startblock > $1) ) {
                 my %records = &Apache::lonnet::dump('comm_block',$cdom,$crs);      $$startblock = $1;
                 foreach (keys %records) {   }
                     if ($_ =~ m/^(\d+)____(\d+)$/) {   if ( ($$endblock == 0) || ($$endblock < $2) ) {
                         if ($1 <= time && $2 >= time) {      $$endblock = $2;
                             my ($staff,$title) = split/:/,$records{$_};   }
                             push @{$$setters{$cse}{'staff'}}, $staff;      }
                             push @{$$setters{$cse}{'times'}}, $_;   }
                             if ( ($$startblock == 0) || ($$startblock > $1) ) {  
                                 $$startblock = $1;  
                             }  
                             if ( ($$endblock == 0) || ($$endblock < $2) ) {  
                                 $$endblock = $2;  
                             }  
                         }  
                     }  
                 }  
             }  
         }  
     }      }
 }  }
   
Line 1486  END Line 1480  END
     foreach (keys %{$setters}) {      foreach (keys %{$setters}) {
         my %courseinfo=&Apache::lonnet::coursedescription($_);          my %courseinfo=&Apache::lonnet::coursedescription($_);
         for (my $i=0; $i<@{$$setters{$_}{staff}}; $i++) {          for (my $i=0; $i<@{$$setters{$_}{staff}}; $i++) {
             my ($uname,$udom) = split/\@/,$$setters{$_}{staff}[$i];              my ($uname,$udom) = @{$$setters{$_}{staff}[$i]};
             my $fullname = &Apache::loncommon::plainname($uname,$udom);              my $fullname = &Apache::loncommon::plainname($uname,$udom);
             my ($openblock,$closeblock) = split/____/,$$setters{$_}{times}[$i];              my ($openblock,$closeblock) = @{$$setters{$_}{times}[$i]};
             $openblock = &Apache::lonlocal::locallocaltime($openblock);              $openblock = &Apache::lonlocal::locallocaltime($openblock);
             $closeblock= &Apache::lonlocal::locallocaltime($closeblock);              $closeblock= &Apache::lonlocal::locallocaltime($closeblock);
             $r->print('<tr><td>'.$courseinfo{'description'}.'</td>'.              $r->print('<tr><td>'.$courseinfo{'description'}.'</td>'.

Removed from v.1.14  
changed lines
  Added in v.1.15


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