');
$r->print('
@@ -1001,14 +1031,15 @@ sub show_table {
$r->print('');
$r->print('
');
my $linkstart='
-
- ');
+ $r->print(&Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row().'
+ ');
foreach my $which (@show_order) {
if ($which ne 'proctor' && exists($show{$which})) {
$r->print(''.$linkstart.$which.'">'.$show_fields{$which}.' ');
}
}
+ $r->print(&Apache::loncommon::end_data_table_header_row());
my %name_cache;
my $slotsort = sub {
@@ -1081,7 +1112,7 @@ sub show_table {
my $unique;
if (ref($slots{$slot}{'uniqueperiod'})) {
- $unique=localtime($slots{$slot}{'uniqueperiod'}[0]).','.
+ $unique=localtime($slots{$slot}{'uniqueperiod'}[0]).', '.
localtime($slots{$slot}{'uniqueperiod'}[1]);
}
@@ -1122,7 +1153,7 @@ sub show_table {
if (exists($show{'proctor'})) {
$rowspan=2;
@proctors= map {
- my ($uname,$udom)=split(/@/,$_);
+ my ($uname,$udom)=split(/:/,$_);
my $fullname=$name_cache{$_};
if (!defined($fullname)) {
$fullname = &Apache::loncommon::plainname($uname,$udom);
@@ -1139,7 +1170,7 @@ sub show_table {
EDITLINK
my $delete=(<<"DELETELINK");
-Delete
+Delete
DELETELINK
my $remove_all=&remove_link($slot,'remove all').' ';
@@ -1150,7 +1181,10 @@ DELETELINK
undef($remove_all);
}
- $r->print(" \n$edit $delete \n");
+ my $row_start=&Apache::loncommon::start_data_table_row();
+ my $row_end=&Apache::loncommon::end_data_table_row();
+ $r->print($row_start.
+ "\n$edit $delete \n");
if (exists($show{'name'})) {
$colspan++;$r->print("$slot ");
}
@@ -1187,18 +1221,22 @@ DELETELINK
if (exists($show{'allowedusers'})) {
$colspan++;$r->print("$allowedusers \n");
}
+ if (exists($show{'uniqueperiod'})) {
+ $colspan++;$r->print("$unique \n");
+ }
if (exists($show{'scheduled'})) {
- $colspan++;$r->print("$remove_all $ids \n \n");
+ $colspan++;$r->print(" $remove_all $ids \n");
}
+ $r->print("$row_end\n");
if (exists($show{'proctor'})) {
$r->print(<
+$row_start
$proctors
-
+$row_end
STUFF
}
}
- $r->print('
');
+ $r->print('');
}
sub upload_start {
@@ -1420,22 +1458,49 @@ sub csv_upload_assign {
if ($entries{$fields{'endtime'}}) {
$slot{'endtime'}=&UnixDate($entries{$fields{'endtime'}},"%s");
}
+
+ # start/endtime must be defined and greater than zero
+ if (!$slot{'starttime'}) {
+ push(@errors,"$name not created -- Invalid start time");
+ next;
+ }
+ if (!$slot{'endtime'}) {
+ push(@errors,"$name not created -- Invalid end time");
+ next;
+ }
+ if ($slot{'starttime'} > $slot{'endtime'}) {
+ push(@errors,"$name not created -- Slot starts after it ends");
+ next;
+ }
+
if ($entries{$fields{'startreserve'}}) {
$slot{'startreserve'}=
&UnixDate($entries{$fields{'startreserve'}},"%s");
}
+ if (defined($slot{'startreserve'})
+ && $slot{'startreserve'} > $slot{'starttime'}) {
+ push(@errors,"$name not created -- Slot's reservation start time is after the slot's start time.");
+ next;
+ }
+
foreach my $key ('ip','proctor','description','maxspace',
'secret','symb') {
if ($entries{$fields{$key}}) {
$slot{$key}=$entries{$fields{$key}};
}
}
+
if ($entries{$fields{'uniqueperiod'}}) {
my ($start,$end)=split(',',$entries{$fields{'uniqueperiod'}});
my @times=(&UnixDate($start,"%s"),
&UnixDate($end,"%s"));
$slot{'uniqueperiod'}=\@times;
}
+ if (defined($slot{'uniqueperiod'})
+ && $slot{'uniqueperiod'}[0] > $slot{'uniqueperiod'}[1]) {
+ push(@errors,"$name not created -- Slot's unique period start time is later than the unique period's end time.");
+ next;
+ }
&Apache::lonnet::cput('slots',{$name=>\%slot},$cdom,$cname);
$r->print('.');
@@ -1498,11 +1563,15 @@ sub handler {
&csv_upload_map($r);
}
} else {
- my $symb=&Apache::lonnet::unescape($env{'form.symb'});
+ my $symb=&unescape($env{'form.symb'});
+ if (!defined($symb)) {
+ &fail($r,'not_valid');
+ return OK;
+ }
my (undef,undef,$res)=&Apache::lonnet::decode_symb($symb);
my $useslots = &Apache::lonnet::EXT("resource.0.useslots",$symb);
- if ($useslots ne 'resource') {
- &fail($r,'not_valid');
+ if ($useslots ne 'resource' && $useslots ne 'map') {
+ &fail($r,'not_available');
return OK;
}
$env{'request.symb'}=$symb;