version 1.39, 2006/02/03 17:07:20
|
version 1.42, 2006/02/03 18:53:08
|
Line 47 sub fail {
|
Line 47 sub fail {
|
$r->print('<p>'.&mt('Failed.').'</p>'); |
$r->print('<p>'.&mt('Failed.').'</p>'); |
} |
} |
|
|
$r->print('<p><a href="/adm/flip?postdata=return:">'. |
&return_link($r); |
&mt('Return to last resource').'</a></p>'); |
|
&end_page($r); |
&end_page($r); |
} |
} |
|
|
Line 89 sub get_reservation_ids {
|
Line 88 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 124 sub check_for_reservation {
|
Line 125 sub check_for_reservation {
|
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); |
|
|
|
if (&network_error($student) || &network_error($course) || |
|
&network_error(%slots)) { |
|
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 148 sub check_for_conflict {
|
Line 153 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); |
|
|
|
if (&network_error($student) || &network_error($course) || |
|
&network_error(%slots)) { |
|
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 173 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 189 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 214 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 281 sub release_slot {
|
Line 307 sub release_slot {
|
if ($mgr ne 'F') { |
if ($mgr ne 'F') { |
if ($slot{$slot_name}{'starttime'} < time) { |
if ($slot{$slot_name}{'starttime'} < time) { |
$r->print("<p>Not allowed to release Reservation: $description, as it has already ended.</p>"); |
$r->print("<p>Not allowed to release Reservation: $description, as it has already ended.</p>"); |
$r->print('<p><a href="/adm/flip?postdata=return:">'. |
&return_link($r); |
&mt('Return to last resource').'</a></p>'); |
|
return 0; |
return 0; |
} |
} |
} |
} |
Line 318 sub release_slot {
|
Line 343 sub release_slot {
|
$r->print('<p><a href="/adm/slotrequest?command=showslots">'. |
$r->print('<p><a href="/adm/slotrequest?command=showslots">'. |
&mt('Return to slot list').'</a></p>'); |
&mt('Return to slot list').'</a></p>'); |
} |
} |
if (!$inhibit_return_link) { |
if (!$inhibit_return_link) { &return_link($r); } |
$r->print('<p><a href="/adm/flip?postdata=return:">'. |
|
&mt('Return to last resource').'</a></p>'); |
|
} |
|
return 1; |
return 1; |
} |
} |
|
|
Line 355 sub delete_slot {
|
Line 377 sub delete_slot {
|
} |
} |
$r->print('<p><a href="/adm/slotrequest?command=showslots">'. |
$r->print('<p><a href="/adm/slotrequest?command=showslots">'. |
&mt('Return to slot list').'</a></p>'); |
&mt('Return to slot list').'</a></p>'); |
|
&return_link($r); |
|
} |
|
|
|
sub return_link { |
|
my ($r) = @_; |
$r->print('<p><a href="/adm/flip?postdata=return:">'. |
$r->print('<p><a href="/adm/flip?postdata=return:">'. |
&mt('Return to last resource').'</a></p>'); |
&mt('Return to last resource').'</a></p>'); |
} |
} |
Line 363 sub get_slot {
|
Line 390 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 416 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 431 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", |
Line 436 or
|
Line 466 or
|
</p> |
</p> |
or |
or |
STUFF |
STUFF |
$r->print('<p><a href="/adm/flip?postdata=return:">'. |
|
&mt('Return to last resource').'</a></p>'); |
&return_link($r); |
return; |
return; |
} |
} |
|
|