Diff for /loncom/interface/slotrequest.pm between versions 1.123 and 1.125.2.2

version 1.123, 2015/06/23 16:09:43 version 1.125.2.2, 2016/08/08 21:18:31
Line 37  use Apache::lonnet; Line 37  use Apache::lonnet;
 use Apache::lonnavmaps();  use Apache::lonnavmaps();
 use Date::Manip;  use Date::Manip;
 use lib '/home/httpd/lib/perl/';  use lib '/home/httpd/lib/perl/';
 use LONCAPA;  use LONCAPA qw(:DEFAULT :match);
   
 sub fail {  sub fail {
     my ($r,$code)=@_;      my ($r,$code)=@_;
Line 162  $js Line 162  $js
                 var startdate = startm+"/"+startd+"/"+starty;                  var startdate = startm+"/"+startd+"/"+starty;
                 var starttime = new Date(startdate).getTime();                  var starttime = new Date(startdate).getTime();
                 starttime = starttime/1000;                  starttime = starttime/1000;
                   var starth = form.start_hour.options[form.start_hour.selectedIndex].value;
                   if (numberRegExp.test(starth)) {
                       starth = parseInt(starth);
                       if (starth > 0 && starth <= 23) {
                           starttime += 3600 * starth;
                       }
                   }
                 var enddate = endm+"/"+endd+"/"+endy;                  var enddate = endm+"/"+endd+"/"+endy;
                 var endtime = new Date(enddate).getTime();                  var endtime = new Date(enddate).getTime();
                 endtime = endtime/1000;                  endtime = endtime/1000;
                   var endh = form.end_hour.options[form.end_hour.selectedIndex].value;
                   if (numberRegExp.test(endh)) {
                       endh = parseInt(endh);
                       if (endh > 0 && endh <= 23) {
                           endtime += 3600 * endh;
                       }
                   }
   
                 var shown = 0;                  var shown = 0;
                 for (var i=0; i<$i; i++) {                  for (var i=0; i<$i; i++) {
                     if ((slotstart[i] >= starttime) && (slotend[i] <= endtime)) {                      if ((slotstart[i] >= starttime) && (slotend[i] <= endtime)) {
Line 237  function uncheckSlotRadio() { Line 252  function uncheckSlotRadio() {
     if (document.getElementsByClassName) {      if (document.getElementsByClassName) {
         slotpicks = document.getElementsByClassName('LC_slotpick_radio');          slotpicks = document.getElementsByClassName('LC_slotpick_radio');
     } else {      } else {
         sloctpicks = getElementsByClassName(document.body,'LC_slotpick_radio');          slotpicks = getElementsByClassName(document.body,'LC_slotpick_radio');
     }      }
     if (slotpicks.length) {      if (slotpicks.length) {
         for (var i=0; i<slotpicks.length; i++) {          for (var i=0; i<slotpicks.length; i++) {
Line 2740  sub csv_upload_assign { Line 2755  sub csv_upload_assign {
  }   }
   
  if ($entries{$fields{'startreserve'}}) {   if ($entries{$fields{'startreserve'}}) {
     $slot{'startreserve'}=              my $date = &UnixDate($entries{$fields{'startreserve'}},"%s");
  &UnixDate($entries{$fields{'startreserve'}},"%s");              if ($date eq '') {
                   push(@errors,"$name -- No reservation start time set for slot -- value provided had invalid format");
               } else {
                   $slot{'startreserve'} = $date;
               }
  }   }
  if (defined($slot{'startreserve'})   if (defined($slot{'startreserve'})
     && $slot{'startreserve'} > $slot{'starttime'}) {      && $slot{'startreserve'} > $slot{'starttime'}) {
Line 2750  sub csv_upload_assign { Line 2769  sub csv_upload_assign {
  }   }
   
         if ($entries{$fields{'endreserve'}}) {          if ($entries{$fields{'endreserve'}}) {
             $slot{'endreserve'}=              my $date = &UnixDate($entries{$fields{'endreserve'}},"%s");
                 &UnixDate($entries{$fields{'endreserve'}},"%s");              if ($date eq '') {
                   push(@errors,"$name -- No reservation end time set for slot -- value provided had invalid format");
               } else {
                   $slot{'endreserve'} = $date;
               }
         }          }
         if (defined($slot{'endreserve'})          if (defined($slot{'endreserve'})
             && $slot{'endreserve'} > $slot{'starttime'}) {              && $slot{'endreserve'} > $slot{'starttime'}) {
Line 2779  sub csv_upload_assign { Line 2802  sub csv_upload_assign {
  $slot{$key}=$entries{$fields{$key}};   $slot{$key}=$entries{$fields{$key}};
     }      }
  }   }
           if ($entries{$fields{'allowedusers'}}) {
               $entries{$fields{'allowedusers'}} =~ s/^\s+//;
               $entries{$fields{'allowedusers'}} =~ s/\s+$//;
               my @allowedusers;
               foreach my $poss (split(/\s*,\s*/,$entries{$fields{'allowedusers'}})) {
                   my ($possuname,$possudom) = split(/:/,$poss);
                   if (($possuname =~ /^$match_username$/) && ($possudom =~ /^$match_domain$/)) {
                       unless (grep(/^\Q$poss\E$/,@allowedusers)) {
                           push(@allowedusers,$poss);
                       }
                   }
               }
               if (@allowedusers > 0) {
                   $slot{'allowedusers'} = join(',',@allowedusers);
               }
           }
           if ($entries{$fields{'allowedsections'}}) {
               $entries{$fields{'allowedsections'}} =~ s/^\s+//;
               $entries{$fields{'allowedsections'}} =~ s/\s+$//;
               my @allowedsections;
               foreach my $poss (split(/\s*,\s*/,$entries{$fields{'allowedsections'}})) {
                   if (($poss !~ /\W/) && ($poss ne 'none')) {
                       unless (grep(/^\Q$poss\E$/,@allowedsections)) {
                           push(@allowedsections,$poss);
                       }
                   }
               }
               if (@allowedsections > 0) {
                   $slot{'allowedsections'} = join(',',@allowedsections);
               }
           }
  if ($entries{$fields{'uniqueperiod'}}) {   if ($entries{$fields{'uniqueperiod'}}) {
     my ($start,$end)=split(',',$entries{$fields{'uniqueperiod'}});              my ($start,$end)= map { &UnixDate($_,"%s"); } split(',',$entries{$fields{'uniqueperiod'}});
     my @times=(&UnixDate($start,"%s"),              if (($start ne '') && ($end ne '')) {
        &UnixDate($end,"%s"));                  $slot{'uniqueperiod'}=[$start,$end];
     $slot{'uniqueperiod'}=\@times;              } else {
                   push(@errors,"$name -- Slot's unique period ignored -- one or both of the comma separated values for start and end had an invalid format");
               }
  }   }
  if (defined($slot{'uniqueperiod'})   if (ref($slot{'uniqueperiod'}) eq 'ARRAY' 
     && $slot{'uniqueperiod'}[0] > $slot{'uniqueperiod'}[1]) {      && $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.");      push(@errors,"$name not created -- Slot's unique period start time is later than the unique period's end time.");
     next;      next;

Removed from v.1.123  
changed lines
  Added in v.1.125.2.2


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