[LON-CAPA-cvs] cvs: loncom /interface slotrequest.pm

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 03 Feb 2006 17:07:21 -0000


albertel		Fri Feb  3 12:07:21 2006 EDT

  Modified files:              
    /loncom/interface	slotrequest.pm 
  Log:
  - was allowing users to release reservations for expired slots
  
  
Index: loncom/interface/slotrequest.pm
diff -u loncom/interface/slotrequest.pm:1.38 loncom/interface/slotrequest.pm:1.39
--- loncom/interface/slotrequest.pm:1.38	Tue Jan 24 01:41:16 2006
+++ loncom/interface/slotrequest.pm	Fri Feb  3 12:07:20 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler for requesting to have slots added to a students record
 #
-# $Id: slotrequest.pm,v 1.38 2006/01/24 06:41:16 albertel Exp $
+# $Id: slotrequest.pm,v 1.39 2006/02/03 17:07:20 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -275,7 +275,17 @@
 	&& defined($env{'form.symb'})) {
 	$symb = $env{'form.symb'};
     }
+    my %slot=&Apache::lonnet::get_slot($slot_name);
+    my $description=&get_description($env{'form.slotname'},\%slot);
 
+    if ($mgr ne 'F') {
+	if ($slot{$slot_name}{'starttime'} < time) {
+	    $r->print("<p>Not allowed to release Reservation: $description, as it has already ended.</p>");
+	    $r->print('<p><a href="/adm/flip?postdata=return:">'.
+		      &mt('Return to last resource').'</a></p>');
+	    return 0;
+	}
+    }
     # get parameter string, check for existance, rebuild string with the slot
     my @slots = split(/:/,&Apache::lonnet::EXT("resource.0.availablestudent",
 					       $symb,$udom,$uname));
@@ -302,7 +312,6 @@
 						      '0_availablestudent',
 						      1, $new_param, 'string',
 						      $uname,$udom);
-    my %slot=&Apache::lonnet::get_slot($slot_name);
     my $description=&get_description($env{'form.slotname'},\%slot);
     $r->print("<p>Released Reservation: $description</p>");
     if ($mgr eq 'F') {
@@ -1157,8 +1166,9 @@
 	} elsif ($env{'form.command'} eq 'get') {
 	    &get_slot($r,$symb);
 	} elsif ($env{'form.command'} eq 'change') {
-	    &release_slot($r,$symb,$env{'form.releaseslot'},1);
-	    &get_slot($r,$symb);
+	    if (&release_slot($r,$symb,$env{'form.releaseslot'},1)) {
+		&get_slot($r,$symb);
+	    }
 	} else {
 	    $r->print("<p>Unknown command: ".$env{'form.command'}."</p>");
 	}