Diff for /loncom/interface/slotrequest.pm between versions 1.122 and 1.125.2.1

version 1.122, 2015/05/10 03:58:12 version 1.125.2.1, 2016/08/06 21:32:55
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 237  function uncheckSlotRadio() { Line 237  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 689  sub release_reservation { Line 689  sub release_reservation {
         return (0,'error: Unable to determine current status');          return (0,'error: Unable to determine current status');
     }      }
     my $passed_resource = $navmap->getBySymb($symb);      my $passed_resource = $navmap->getBySymb($symb);
     if ($passed_resource->is_map()) {      if (ref($passed_resource)) {
  my ($a_resource) =           if ($passed_resource->is_map()) {
     $navmap->retrieveResources($passed_resource,       my ($a_resource) = 
        sub {$_[0]->is_problem()},0,1);                  $navmap->retrieveResources($passed_resource, 
  $symb = $a_resource->symb();                                             sub {$_[0]->is_problem()},0,1);
               $symb = $a_resource->symb();
           }
       } else {
           unless ($mgr eq 'F') {
               return (0,'error: Unable to determine current status');
           }
     }      }
   
     # get parameter string, check for existance, rebuild string with the slot      # get parameter string, check for existence, rebuild string with the slot
     my $student = &Apache::lonnet::EXT("resource.0.availablestudent",      my $student = &Apache::lonnet::EXT("resource.0.availablestudent",
                                        $symb,$udom,$uname);                                         $symb,$udom,$uname);
     my @slots = split(/:/,$student);      my @slots = split(/:/,$student);
Line 2734  sub csv_upload_assign { Line 2740  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 2744  sub csv_upload_assign { Line 2754  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 2773  sub csv_upload_assign { Line 2787  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.122  
changed lines
  Added in v.1.125.2.1


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