version 1.39, 2006/02/03 17:07:20
|
version 1.40, 2006/02/03 18:22:44
|
Line 89 sub get_reservation_ids {
|
Line 89 sub get_reservation_ids {
|
|
|
my %consumed=&Apache::lonnet::dump('slot_reservations',$cdom,$cnum, |
my %consumed=&Apache::lonnet::dump('slot_reservations',$cdom,$cnum, |
"^$slot_name\0"); |
"^$slot_name\0"); |
|
if (&network_error(%consumed)) { |
|
return 'error: Unable to determine current status'; |
|
} |
my ($tmp)=%consumed; |
my ($tmp)=%consumed; |
if ($tmp=~/^error: 2 / ) { |
if ($tmp=~/^error: 2 / ) { |
return 0; |
return 0; |
Line 148 sub check_for_conflict {
|
Line 150 sub check_for_conflict {
|
my @slots = (split(/:/,$student), split(/:/, $course)); |
my @slots = (split(/:/,$student), split(/:/, $course)); |
my ($cnum,$cdom)=&get_course(); |
my ($cnum,$cdom)=&get_course(); |
my %slots=&Apache::lonnet::get('slots', [@slots], $cdom, $cnum); |
my %slots=&Apache::lonnet::get('slots', [@slots], $cdom, $cnum); |
|
my ($tmp) = %slots; |
|
if (&network_error($student) || &network_error($course) || |
|
&network_error($tmp)) { |
|
return 'error: Unable to determine current status'; |
|
} |
foreach my $slot_name (@slots) { |
foreach my $slot_name (@slots) { |
next if (!defined($slots{$slot_name}) || |
next if (!defined($slots{$slot_name}) || |
!ref($slots{$slot_name})); |
!ref($slots{$slot_name})); |
Line 163 sub check_for_conflict {
|
Line 170 sub check_for_conflict {
|
|
|
} |
} |
|
|
|
sub network_error { |
|
my ($result) = @_; |
|
if ($result =~ /^(con_lost|no_such_host|error: [^2])/) { |
|
return 1; |
|
} |
|
return 0; |
|
} |
|
|
sub make_reservation { |
sub make_reservation { |
my ($slot_name,$slot,$symb)=@_; |
my ($slot_name,$slot,$symb)=@_; |
|
|
Line 171 sub make_reservation {
|
Line 186 sub make_reservation {
|
my $value=&Apache::lonnet::EXT("resource.0.availablestudent",$symb, |
my $value=&Apache::lonnet::EXT("resource.0.availablestudent",$symb, |
$env{'user.domain'},$env{'user.name'}); |
$env{'user.domain'},$env{'user.name'}); |
&Apache::lonxml::debug("value is $value<br />"); |
&Apache::lonxml::debug("value is $value<br />"); |
|
if (&network_error($value)) { |
|
return 'error: Unable to determine current status'; |
|
} |
|
|
foreach my $other_slot (split(/:/, $value)) { |
foreach my $other_slot (split(/:/, $value)) { |
if ($other_slot eq $slot_name) { |
if ($other_slot eq $slot_name) { |
my %consumed=&Apache::lonnet::dump('slot_reservations', $cdom, |
my %consumed=&Apache::lonnet::dump('slot_reservations', $cdom, |
$cnum, "^$slot_name\0"); |
$cnum, "^$slot_name\0"); |
|
if (&network_error($value)) { |
|
return 'error: Unable to determine current status'; |
|
} |
my $me=$env{'user.name'}.'@'.$env{'user.domain'}; |
my $me=$env{'user.name'}.'@'.$env{'user.domain'}; |
foreach my $key (keys(%consumed)) { |
foreach my $key (keys(%consumed)) { |
if ($consumed{$key}->{'name'} eq $me) { |
if ($consumed{$key}->{'name'} eq $me) { |
Line 190 sub make_reservation {
|
Line 211 sub make_reservation {
|
if (!defined($max)) { $max=99999; } |
if (!defined($max)) { $max=99999; } |
|
|
my (@ids)=&get_reservation_ids($slot_name); |
my (@ids)=&get_reservation_ids($slot_name); |
|
if (&network_error(@ids)) { |
|
return 'error: Unable to determine current status'; |
|
} |
my $last=0; |
my $last=0; |
foreach my $id (@ids) { |
foreach my $id (@ids) { |
my $num=(split('\0',$id))[1]; |
my $num=(split('\0',$id))[1]; |
Line 359 sub delete_slot {
|
Line 382 sub delete_slot {
|
&mt('Return to last resource').'</a></p>'); |
&mt('Return to last resource').'</a></p>'); |
} |
} |
|
|
|
sub return_link { |
|
my ($r) = @_; |
|
$r->print('<p><a href="/adm/flip?postdata=return:">'. |
|
&mt('Return to last resource').'</a></p>'); |
|
} |
|
|
sub get_slot { |
sub get_slot { |
my ($r,$symb)=@_; |
my ($r,$symb)=@_; |
|
|
my $slot_name=&check_for_conflict($symb,$env{'form.slotname'}); |
my $slot_name=&check_for_conflict($symb,$env{'form.slotname'}); |
|
|
|
if ($slot_name =~ /^error: (.*)/) { |
|
$r->print("<p>An error occured while attempting to make a reservation. ($1)</p>"); |
|
&return_link($r); |
|
return; |
|
} |
if ($slot_name) { |
if ($slot_name) { |
my %slot=&Apache::lonnet::get_slot($slot_name); |
my %slot=&Apache::lonnet::get_slot($slot_name); |
my $description1=&get_description($slot_name,\%slot); |
my $description1=&get_description($slot_name,\%slot); |
Line 383 STUFF
|
Line 418 STUFF
|
STUFF |
STUFF |
$r->print(' your reservation from <b>'.$description1.'</b> to <b>'. |
$r->print(' your reservation from <b>'.$description1.'</b> to <b>'. |
$description2. |
$description2. |
'</b> <br />or <a href="/adm/flip?postdata=return:">'. |
'</b> <br />or </p>'); |
&mt('Return to last resource').'</a></p>'); |
&return_link($r); |
$r->print(<<STUFF); |
$r->print(<<STUFF); |
</form> |
</form> |
STUFF |
STUFF |
} else { |
} else { |
$r->print('<p><a href="/adm/flip?postdata=return:">'. |
&return_link($r); |
&mt('Return to last resource').'</a></p>'); |
|
} |
} |
return; |
return; |
} |
} |
Line 399 STUFF
|
Line 433 STUFF
|
\%slot,$symb); |
\%slot,$symb); |
my $description=&get_description($env{'form.slotname'},\%slot); |
my $description=&get_description($env{'form.slotname'},\%slot); |
if (defined($reserved)) { |
if (defined($reserved)) { |
if ($reserved > -1) { |
if ($slot_name =~ /^error: (.*)/) { |
|
$r->print("<p>An error occured while attempting to make a reservation. ($1)</p>"); |
|
} elsif ($reserved > -1) { |
$r->print("<p>Success: $description</p>"); |
$r->print("<p>Success: $description</p>"); |
$r->print('<p><a href="/adm/flip?postdata=return:">'. |
|
&mt('Return to last resource').'</a></p>'); |
|
return; |
|
} elsif ($reserved < 0) { |
} elsif ($reserved < 0) { |
$r->print("<p>Already reserved: $description</p>"); |
$r->print("<p>Already reserved: $description</p>"); |
$r->print('<p><a href="/adm/flip?postdata=return:">'. |
|
&mt('Return to last resource').'</a></p>'); |
|
return; |
|
} |
} |
|
&return_link($r); |
|
return; |
} |
} |
|
|
my %lt=('request'=>"Availibility list", |
my %lt=('request'=>"Availibility list", |