Diff for /loncom/interface/slotrequest.pm between versions 1.125.2.4 and 1.126

version 1.125.2.4, 2018/06/27 14:26:28 version 1.126, 2015/09/23 23:04:53
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 841  sub get_slot { Line 826  sub get_slot {
     if ($slot_name && $slot_name ne $conflictable_slot) {      if ($slot_name && $slot_name ne $conflictable_slot) {
  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);
         my $slottype1=$slot{'type'};  
  %slot=&Apache::lonnet::get_slot($env{'form.slotname'});   %slot=&Apache::lonnet::get_slot($env{'form.slotname'});
  my $description2=&get_description($env{'form.slotname'},\%slot);   my $description2=&get_description($env{'form.slotname'},\%slot);
         if ($slottype1 eq 'preassigned') {   if ($slot_name ne $env{'form.slotname'}) {
             $r->print('<p>'.&mt('You already have a reservation: "[_1]", assigned by your instructor.',  
                                 $description1).'</p>'.  
                       '<p>'.&mt('Your instructor must unassign it before you can make a new reservation.').  
                       '</p>');  
         } elsif ($slot_name ne $env{'form.slotname'}) {  
     $r->print(<<STUFF);      $r->print(<<STUFF);
 <form method="post" action="/adm/slotrequest">  <form method="post" action="/adm/slotrequest">
    <input type="hidden" name="symb" value="$env{'form.symb'}" />     <input type="hidden" name="symb" value="$env{'form.symb'}" />
Line 1021  sub allowed_slot { Line 1000  sub allowed_slot {
     return 0 if (!$userallowed);      return 0 if (!$userallowed);
   
     # not allowed for this resource      # not allowed for this resource
     if (defined($slot->{'symb'})      if (defined($slot->{'symb'})) {
  && $slot->{'symb'} ne $symb) {          my $exclude = 1;
         unless ((ref($toskip) eq 'HASH') && ($toskip->{'symb'})) {          my ($slotmap,$slotid,$sloturl) = &Apache::lonnet::decode_symb($slot->{'symb'});
     return 0;          if ($sloturl=~/\.(page|sequence)$/) {
               my ($map,$id,$url) = &Apache::lonnet::decode_symb($symb);
               if (($map ne '') && ($map eq $slotmap)) {
                   $exclude = 0;
               }
           } elsif ($slot->{'symb'} eq $symb) {
               $exclude = 0;
           }
           if ($exclude) {
               unless ((ref($toskip) eq 'HASH') && ($toskip->{'symb'})) {
           return 0;
               }
         }          }
     }      }
   
Line 1370  sub show_table { Line 1360  sub show_table {
      'secret'          => 'Secret Word',       'secret'          => 'Secret Word',
      'space'           => '# of students/max',       'space'           => '# of students/max',
      'ip'              => 'IP or DNS restrictions',       'ip'              => 'IP or DNS restrictions',
      'symb'            => 'Resource slot is restricted to.',       'symb'            => 'Resource/Map slot is restricted to.',
      'allowedsections' => 'Sections slot is restricted to.',       'allowedsections' => 'Sections slot is restricted to.',
      'allowedusers'    => 'Users slot is restricted to.',       'allowedusers'    => 'Users slot is restricted to.',
      'uniqueperiod'    => 'Period of time slot is unique',       'uniqueperiod'    => 'Period of time slot is unique',
Line 1482  sub show_table { Line 1472  sub show_table {
     $r->print('</div>');      $r->print('</div>');
     $r->print('<p><input type="submit" name="start" value="'.&mt('Update Display').'" /></p>');      $r->print('<p><input type="submit" name="start" value="'.&mt('Update Display').'" /></p>');
     my $linkstart='<a href="/adm/slotrequest?command=showslots&amp;order=';      my $linkstart='<a href="/adm/slotrequest?command=showslots&amp;order=';
     my $tableheader = &Apache::loncommon::start_data_table().      $r->print(&Apache::loncommon::start_data_table().
                       &Apache::loncommon::start_data_table_header_row().'        &Apache::loncommon::start_data_table_header_row().'
                       <th></th>';         <th></th>');
     foreach my $which (@show_order) {      foreach my $which (@show_order) {
  if ($which ne 'proctor' && exists($show{$which})) {   if ($which ne 'proctor' && exists($show{$which})) {
     $tableheader .= '<th>'.$linkstart.$which.'">'.$show_fields{$which}.'</a></th>';      $r->print('<th>'.$linkstart.$which.'">'.$show_fields{$which}.'</a></th>');
  }   }
     }      }
     $tableheader .= &Apache::loncommon::end_data_table_header_row();      $r->print(&Apache::loncommon::end_data_table_header_row());
     my $shownheader = 0;  
   
     my %name_cache;      my %name_cache;
     my $slotsort = sub {      my $slotsort = sub {
Line 1640  sub show_table { Line 1629  sub show_table {
                                                delete => 'Delete',                                                 delete => 'Delete',
                                                slotlog => 'History',                                                 slotlog => 'History',
         );          );
         my ($edit,$delete,$showlog,$remove_all);   my $edit=(<<"EDITLINK");
         if ($mgr) {  
     $edit=(<<"EDITLINK");  
 <a href="/adm/helper/newslot.helper?name=$slot">$lt{'edit'}</a>  <a href="/adm/helper/newslot.helper?name=$slot">$lt{'edit'}</a>
 EDITLINK  EDITLINK
   
     $delete=(<<"DELETELINK");   my $delete=(<<"DELETELINK");
 <a href="/adm/slotrequest?command=delete&amp;slotname=$slot">$lt{'delete'}</a>  <a href="/adm/slotrequest?command=delete&amp;slotname=$slot">$lt{'delete'}</a>
 DELETELINK  DELETELINK
   
             $remove_all=&remove_link($slot,'remove all').'<br />';          my $showlog=(<<"LOGLINK");
   
             if ($ids eq '') {  
                 undef($remove_all);  
             } else {  
                 undef($delete);  
             }  
         }  
   
         $showlog=(<<"LOGLINK");  
 <a href="/adm/slotrequest?command=slotlog&amp;slotname=$slot">$lt{'slotlog'}</a>  <a href="/adm/slotrequest?command=slotlog&amp;slotname=$slot">$lt{'slotlog'}</a>
 LOGLINK  LOGLINK
   
           my $remove_all=&remove_link($slot,'remove all').'<br />';
   
           if ($ids eq '') {
               undef($remove_all);
           } else {
               undef($delete);
           }
  if ($slots{$slot}{'type'} ne 'schedulable_student') {   if ($slots{$slot}{'type'} ne 'schedulable_student') {
             undef($showlog);               undef($showlog); 
     undef($remove_all);      undef($remove_all);
  }   }
   
         unless ($shownheader) {  
             $r->print($tableheader);  
             $shownheader = 1;  
         }  
   
  my $row_start=&Apache::loncommon::start_data_table_row();   my $row_start=&Apache::loncommon::start_data_table_row();
  my $row_end=&Apache::loncommon::end_data_table_row();   my $row_end=&Apache::loncommon::end_data_table_row();
         $r->print($row_start.          $r->print($row_start.
Line 1741  $row_end Line 1721  $row_end
 STUFF  STUFF
         }          }
     }      }
     if ($shownheader) {      $r->print(&Apache::loncommon::end_data_table().'</form>');
         $r->print(&Apache::loncommon::end_data_table());  
     } else {  
         $r->print('<p>'.&mt('No slots meet the criteria for display').'</p>');  
     }  
     $r->print('</form>');  
     return;      return;
 }  }
   
Line 2102  sub show_reservations { Line 2077  sub show_reservations {
     if ($showntablehdr) {      if ($showntablehdr) {
         $r->print(&Apache::loncommon::end_data_table().'<br />');          $r->print(&Apache::loncommon::end_data_table().'<br />');
         if (($curr{'page'} > 1) || ($more_records)) {          if (($curr{'page'} > 1) || ($more_records)) {
             $r->print('<p>');              $r->print('<table><tr>');
             if ($curr{'page'} > 1) {              if ($curr{'page'} > 1) {
                 $r->print('<input type="button" onclick="javascript:chgPage('."'previous'".');" value="'.                  $r->print('<td><a href="javascript:chgPage('."'previous'".');">'.&mt('Previous [_1] changes',$curr{'show'}).'</a></td>');
                           &mt('Previous [_1] changes',$curr{'show'}).'" />');  
             }              }
             if ($more_records) {              if ($more_records) {
                 $r->print('<input type="button" onclick="javascript:chgPage('."'next'".');" value="'.                  $r->print('<td><a href="javascript:chgPage('."'next'".');">'.&mt('Next [_1] changes',$curr{'show'}).'</a></td>');
                           &mt('Next [_1] changes',$curr{'show'}).'" />');  
             }              }
             $r->print('</p>');              $r->print('</tr></table>');
             $r->print(<<"ENDSCRIPT");              $r->print(<<"ENDSCRIPT");
 <script type="text/javascript">  <script type="text/javascript">
 // <![CDATA[  // <![CDATA[
Line 2315  sub show_reservations_log { Line 2288  sub show_reservations_log {
     if ($showntablehdr) {      if ($showntablehdr) {
         $r->print(&Apache::loncommon::end_data_table().'<br />');          $r->print(&Apache::loncommon::end_data_table().'<br />');
         if (($curr{'page'} > 1) || ($more_records)) {          if (($curr{'page'} > 1) || ($more_records)) {
             $r->print('<p>');              $r->print('<table><tr>');
             if ($curr{'page'} > 1) {              if ($curr{'page'} > 1) {
                 $r->print('<input type="button" onclick="javascript:chgPage('."'previous'".');" value="'.                  $r->print('<td><a href="javascript:chgPage('."'previous'".');">'.&mt('Previous [_1] changes',$curr{'show'}).'</a></td>');
                           &mt('Previous [_1] changes',$curr{'show'}).'" />');  
             }              }
             if ($more_records) {              if ($more_records) {
                 $r->print('<input type="button" onclick="javascript:chgPage('."'next'".');" value="'.                  $r->print('<td><a href="javascript:chgPage('."'next'".');">'.&mt('Next [_1] changes',$curr{'show'}).'</a></td>');
                           &mt('Next [_1] changes',$curr{'show'}).'" />');  
             }              }
             $r->print('</p>');              $r->print('</tr></table>');
             $r->print(<<"ENDSCRIPT");              $r->print(<<"ENDSCRIPT");
 <script type="text/javascript">  <script type="text/javascript">
 function chgPage(caller) {  function chgPage(caller) {
Line 2464  sub display_filter { Line 2435  sub display_filter {
         }          }
         $output .= '</select></td>';          $output .= '</select></td>';
     }      }
     $output .= '<td>&nbsp;&nbsp;</td></tr></table>'.      $output .= '<td>&nbsp;&nbsp;</td><td valign="middle"><input type="submit" value="'.
                '<p><input type="submit" value="'.                 &mt('Update Display').'" /></tr></table>'.
                &mt('Update Display').'" /></p>'.  
                '<p class="LC_info">'.                 '<p class="LC_info">'.
                &mt('Only changes made from servers running LON-CAPA [_1] or later are displayed.'                 &mt('Only changes made from servers running LON-CAPA [_1] or later are displayed.'
                   ,'2.9.0');                    ,'2.9.0');
Line 2713  sub csvupload_fields { Line 2683  sub csvupload_fields {
     ['proctor','List of proctor ids'],      ['proctor','List of proctor ids'],
     ['description','Slot Description'],      ['description','Slot Description'],
     ['maxspace','Maximum number of reservations'],      ['maxspace','Maximum number of reservations'],
     ['symb','Resource Restriction'],      ['symb','Resource/Map Restriction'],
     ['uniqueperiod','Date range of slot exclusion'],      ['uniqueperiod','Date range of slot exclusion'],
     ['secret','Secret word proctor uses to validate'],      ['secret','Secret word proctor uses to validate'],
     ['allowedsections','Sections slot is restricted to'],      ['allowedsections','Sections slot is restricted to'],
Line 2781  sub csv_upload_assign { Line 2751  sub csv_upload_assign {
  }   }
   
  if ($entries{$fields{'startreserve'}}) {   if ($entries{$fields{'startreserve'}}) {
             my $date = &UnixDate($entries{$fields{'startreserve'}},"%s");      $slot{'startreserve'}=
             if ($date eq '') {   &UnixDate($entries{$fields{'startreserve'}},"%s");
                 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 2795  sub csv_upload_assign { Line 2761  sub csv_upload_assign {
  }   }
   
         if ($entries{$fields{'endreserve'}}) {          if ($entries{$fields{'endreserve'}}) {
             my $date = &UnixDate($entries{$fields{'endreserve'}},"%s");              $slot{'endreserve'}=
             if ($date eq '') {                  &UnixDate($entries{$fields{'endreserve'}},"%s");
                 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 2860  sub csv_upload_assign { Line 2822  sub csv_upload_assign {
             }              }
         }          }
  if ($entries{$fields{'uniqueperiod'}}) {   if ($entries{$fields{'uniqueperiod'}}) {
             my ($start,$end)= map { &UnixDate($_,"%s"); } split(',',$entries{$fields{'uniqueperiod'}});      my ($start,$end)=split(',',$entries{$fields{'uniqueperiod'}});
             if (($start ne '') && ($end ne '')) {      my @times=(&UnixDate($start,"%s"),
                 $slot{'uniqueperiod'}=[$start,$end];         &UnixDate($end,"%s"));
             } else {      $slot{'uniqueperiod'}=\@times;
                 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 (ref($slot{'uniqueperiod'}) eq 'ARRAY'    if (defined($slot{'uniqueperiod'})
     && $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;
Line 3030  sub handler { Line 2990  sub handler {
     }      }
     &csv_upload_map($r);      &csv_upload_map($r);
  }   }
     } elsif (($env{'form.command'} eq 'slotlog') && ($vgr eq 'F')) {      } elsif ($env{'form.command'} eq 'slotlog' && $mgr eq 'F') {
         &show_reservations_log($r);          &show_reservations_log($r);
     } else {      } else {
  my $symb=&unescape($env{'form.symb'});   my $symb=&unescape($env{'form.symb'});

Removed from v.1.125.2.4  
changed lines
  Added in v.1.126


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