Diff for /loncom/interface/slotrequest.pm between versions 1.84 and 1.85

version 1.84, 2008/12/11 14:55:15 version 1.85, 2008/12/21 04:14:39
Line 165  sub check_for_reservation { Line 165  sub check_for_reservation {
 sub get_consumed_uniqueperiods {  sub get_consumed_uniqueperiods {
     my ($slots) = @_;      my ($slots) = @_;
     my $navmap=Apache::lonnavmaps::navmap->new;      my $navmap=Apache::lonnavmaps::navmap->new;
       if (!defined($navmap)) {
           return 'error: Unable to determine current status';
       }
     my @problems = $navmap->retrieveResources(undef,      my @problems = $navmap->retrieveResources(undef,
       sub { $_[0]->is_problem() },1,0);        sub { $_[0]->is_problem() },1,0);
     my %used_slots;      my %used_slots;
Line 214  sub check_for_conflict { Line 217  sub check_for_conflict {
   
     if (!ref($consumed_uniqueperiods)) {      if (!ref($consumed_uniqueperiods)) {
  $consumed_uniqueperiods = &get_consumed_uniqueperiods($slots);   $consumed_uniqueperiods = &get_consumed_uniqueperiods($slots);
  if (&Apache::lonnet::error(%$consumed_uniqueperiods)) {          if (ref($consumed_uniqueperiods) eq 'HASH') {
     return 'error: Unable to determine current status';      if (&Apache::lonnet::error(%$consumed_uniqueperiods)) {
  }          return 'error: Unable to determine current status';
       }
           } else {
               return 'error: Unable to determine current status';
           }
     }      }
           
     my ($new_uniq_start,$new_uniq_end) = @{$new_slot->{'uniqueperiod'}};      my ($new_uniq_start,$new_uniq_end) = @{$new_slot->{'uniqueperiod'}};
Line 229  sub check_for_conflict { Line 236  sub check_for_conflict {
  }   }
     }      }
     return undef;      return undef;
   
 }  }
   
 sub make_reservation {  sub make_reservation {
Line 413  sub release_all_slot { Line 419  sub release_all_slot {
  my ($result,$msg) =   my ($result,$msg) =
     &release_reservation($slot_name,$uname,$udom,      &release_reservation($slot_name,$uname,$udom,
  $consumed{$entry}{'symb'},$mgr);   $consumed{$entry}{'symb'},$mgr);
  $r->print("<p>$msg</p>");          if (!$result) {
               $r->print('<p><span class="LC_error">'.&mt($msg).'</span></p>');
           } else {
       $r->print("<p>$msg</p>");
           }
  $r->rflush();   $r->rflush();
     }      }
     $r->print('<p><a href="/adm/slotrequest?command=showslots">'.      $r->print('<p><a href="/adm/slotrequest?command=showslots">'.
Line 439  sub release_slot { Line 449  sub release_slot {
   
     my ($result,$msg) =      my ($result,$msg) =
  &release_reservation($slot_name,$uname,$udom,$symb,$mgr);   &release_reservation($slot_name,$uname,$udom,$symb,$mgr);
     $r->print("<p>$msg</p>");      if (!$result) {
           $r->print('<p><span class="LC_error">'.&mt($msg).'</span></p>');
       } else {
           $r->print("<p>$msg</p>");
       }
           
     if ($mgr eq 'F') {      if ($mgr eq 'F') {
  $r->print('<p><a href="/adm/slotrequest?command=showslots">'.   $r->print('<p><a href="/adm/slotrequest?command=showslots">'.
Line 464  sub release_reservation { Line 478  sub release_reservation {
     # if the reservation symb is for a map get a resource in that map      # if the reservation symb is for a map get a resource in that map
     # to check slot parameters on      # to check slot parameters on
     my $navmap=Apache::lonnavmaps::navmap->new;      my $navmap=Apache::lonnavmaps::navmap->new;
       if (!defined($navmap)) {
           return (0,'error: Unable to determine current status');
       }
     my $passed_resource = $navmap->getBySymb($symb);      my $passed_resource = $navmap->getBySymb($symb);
     if ($passed_resource->is_map()) {      if ($passed_resource->is_map()) {
  my ($a_resource) =    my ($a_resource) = 
Line 737  sub allowed_slot { Line 754  sub allowed_slot {
   
     my $conflict = &check_for_conflict($symb,$slot_name,$slot,$slots,      my $conflict = &check_for_conflict($symb,$slot_name,$slot,$slots,
        $consumed_uniqueperiods);         $consumed_uniqueperiods);
     if ($conflict) {      if ($conflict =~ /^error: /) {
           return 0;
       } else {
  if ($slots->{$conflict}{'starttime'} < time) {   if ($slots->{$conflict}{'starttime'} < time) {
     return 0;      return 0;
  }   }
Line 763  sub show_choices { Line 782  sub show_choices {
     my ($cnum,$cdom)=&get_course();      my ($cnum,$cdom)=&get_course();
     my %slots=&Apache::lonnet::dump('slots',$cdom,$cnum);      my %slots=&Apache::lonnet::dump('slots',$cdom,$cnum);
     my $consumed_uniqueperiods = &get_consumed_uniqueperiods(\%slots);      my $consumed_uniqueperiods = &get_consumed_uniqueperiods(\%slots);
       if (ref($consumed_uniqueperiods) eq 'HASH') {
           if (&Apache::lonnet::error(%$consumed_uniqueperiods)) {
               $r->print('<span class="LC_error">'.
                         &mt('An error occurred determining slot availability').
                         '</span>');
               return;
           }
       } elsif ($consumed_uniqueperiods =~ /^error: /) {
           $r->print('<span class="LC_error">'.
                     &mt('An error occurred determining slot availability').
                     '</span>');
           return;
       }
     my $available;      my $available;
     $r->print('<table border="1">');  
     &Apache::lonxml::debug("Checking Slots");      &Apache::lonxml::debug("Checking Slots");
     my @got_slots=&check_for_reservation($symb,'allslots');      my @got_slots=&check_for_reservation($symb,'allslots');
       if ($got_slots[0] =~ /^error: /) {
           $r->print('<span class="LC_error">'.
                     &mt('An error occurred determining slot availability').
                     '</span>');
           return;
       }
       $r->print('<table border="1">');
     foreach my $slot (sort       foreach my $slot (sort 
       { return $slots{$a}->{'starttime'} <=> $slots{$b}->{'starttime'} }        { return $slots{$a}->{'starttime'} <=> $slots{$b}->{'starttime'} }
       (keys(%slots)))  {        (keys(%slots)))  {
Line 791  sub show_choices { Line 829  sub show_choices {
  my $conflict = &check_for_conflict($symb,$slot,$slots{$slot},   my $conflict = &check_for_conflict($symb,$slot,$slots{$slot},
    \%slots,     \%slots,
    $consumed_uniqueperiods);     $consumed_uniqueperiods);
  if ($conflict) {                  if ($conflict) {
     $text=&mt('Change Reservation');                      if ($conflict =~ /^error: /) {
     $command='get';                          $r->print('<tr><td><span class="LC_error" colspan="2">'
  }                                    .&mt('Slot: [_1] has unknown status.',$description)
                                     .'</span></td></tr>');
                       } else {
           $text=&mt('Change Reservation');
           $command='get';
       }
                   }
     }      }
     my $escsymb=&escape($symb);      my $escsymb=&escape($symb);
     $form=<<STUFF;      $form=<<STUFF;

Removed from v.1.84  
changed lines
  Added in v.1.85


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