Diff for /loncom/interface/lonprintout.pm between versions 1.627.2.8 and 1.627.2.9

version 1.627.2.8, 2013/08/28 14:31:54 version 1.627.2.9, 2014/01/20 06:09:58
Line 27 Line 27
 #  #
 package Apache::lonprintout;  package Apache::lonprintout;
 use strict;  use strict;
 use POSIX;  
 use Apache::Constants qw(:common :http);  use Apache::Constants qw(:common :http);
 use Apache::lonxml;  use Apache::lonxml;
 use Apache::lonnet;  use Apache::lonnet;
Line 47  use File::Basename; Line 46  use File::Basename;
   
 use HTTP::Response;  use HTTP::Response;
 use LONCAPA::map();  use LONCAPA::map();
 use POSIX qw(ctime);  
 use Apache::lonlocal;  use Apache::lonlocal;
 use Carp;  use Carp;
 use LONCAPA;  use LONCAPA;
Line 494  RESOURCE_SELECTOR Line 492  RESOURCE_SELECTOR
 #  #
 # @return ($open, $close)   # @return ($open, $close) 
 #  #
 # @note If open/close dates are not defined they will be retunred as undef  # @note If open/close dates are not defined they will be returned as undef
 # @note It is possible for there to be no overlap in which case -1,-1   # @note It is possible for there to be no overlap in which case -1,-1 
 #       will be returned.  #       will be returned.
 # @note The algorithm used is to take the latest open date and the earliest end date.  # @note The algorithm used is to take the latest open date and the earliest end date.
Line 524  sub compute_open_window { Line 522  sub compute_open_window {
   
     # If no overlap...both are -1 as promised.      # If no overlap...both are -1 as promised.
   
     if (defined($earliest_close) && defined($latest_open)      if (($earliest_close ne '') && ($latest_open ne '')
  && ($earliest_close < $latest_open)) {   && ($earliest_close < $latest_open)) {
  $latest_open  = -1;   $latest_open  = -1;
  $earliest_close = -1;   $earliest_close = -1;
Line 572  sub printable { Line 570  sub printable {
 #  #
 # @return (opendate, closedate)  # @return (opendate, closedate)
 #  #
 # @note If open/close dates are not defined they will be retunred as undef  # @note If open/close dates are not defined they will be returned as undef
 # @note It is possible for there to be no overlap in which case -1,-1   # @note It is possible for there to be no overlap in which case -1,-1 
 #       will be returned.  #       will be returned.
 # @note The algorithm used is to take the latest open date and the earliest end date.  # @note The algorithm used is to take the latest open date and the earliest end date.
 #  #       For consistency with &printable() in lonnavmaps.pm determination of start
   #       date for printing checks printstartdate param first, then, if not set,
   #       opendate param, then, if not set, contentopen param.
   
   
 sub get_print_dates {  sub get_print_dates {
     my $res = shift;      my $res = shift;
Line 595  sub get_print_dates { Line 596  sub get_print_dates {
  foreach my $part (@parts) {   foreach my $part (@parts) {
     my $partopen  = $res->parmval('printstartdate', $part);      my $partopen  = $res->parmval('printstartdate', $part);
     my $partclose = $res->parmval('printenddate',  $part);      my $partclose = $res->parmval('printenddate',  $part);
               if (!$partopen) {
                   $partopen = $res->parmval('opendate',$part);
               }
               if (!$partopen) {
                   $partopen = $res->parmval('contentopen',$part);
               }
               if ($partopen) {
                   push(@open_dates, $partopen);
               }
               if ($partclose) {
                   push(@close_dates, $partclose);
               }
     push(@open_dates, $partopen);      push(@open_dates, $partopen);
     push(@close_dates, $partclose);      push(@close_dates, $partclose);
  }   }
Line 603  sub get_print_dates { Line 615  sub get_print_dates {
   
     ($open_date, $close_date)  = &compute_open_window(\@open_dates, \@close_dates);      ($open_date, $close_date)  = &compute_open_window(\@open_dates, \@close_dates);
   
     if ($open_date) {  
  $open_date  = POSIX::strftime('%D', localtime($open_date));  
     }  
     if ($close_date) {  
  $close_date = POSIX::strftime('%D', localtime($close_date));  
     }  
   
     return ($open_date, $close_date);      return ($open_date, $close_date);
 }  }
   
Line 4062  sub printHelper { Line 4067  sub printHelper {
  &Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($url));   &Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($url));
     my $navmap = Apache::lonnavmaps::navmap->new();      my $navmap = Apache::lonnavmaps::navmap->new();
     my $res   = $navmap->getBySymb($symb);      my $res   = $navmap->getBySymb($symb);
     $res_printable  = $res->resprintable() | $userCanPrint; #printability in course context      $res_printable  = $res->resprintable() || $userCanPrint; #printability in course context
     ($res_printstartdate, $res_printenddate) = &get_print_dates($res);      ($res_printstartdate, $res_printenddate) = &get_print_dates($res);
     ($course_open, $course_close) = &course_print_dates($res);      ($course_open, $course_close) = &course_print_dates($res);
     ($map_open, $map_close)       = &map_print_dates($res);      ($map_open, $map_close)       = &map_print_dates($res);
Line 4667  CHOOSE_FROM_ANY_SEQUENCE Line 4672  CHOOSE_FROM_ANY_SEQUENCE
     # Generate the first state, to select which resources get printed.      # Generate the first state, to select which resources get printed.
     Apache::lonhelper::state->new("START", "Select Printing Options:");      Apache::lonhelper::state->new("START", "Select Printing Options:");
     if (!$res_printable) {      if (!$res_printable) {
  $paramHash = Apache::lonhelper::getParamHash();          my $now = time;
  $paramHash->{MESSAGE_TEXT} =          my $shownprintstart = &Apache::lonlocal::locallocaltime($res_printstartdate);
             '<p class="LC_info">'          my $shownprintend = &Apache::lonlocal::locallocaltime($res_printenddate);
            .&mt('Printing for current resource is only possible between [_1] and [_2]',          my $noprintmsg;
                 $res_printstartdate, $res_printenddate).'</p>';          if (($res_printenddate) && ($res_printenddate < $now)) {
  Apache::lonhelper::message->new();                  $noprintmsg = &mt('Printing for current resource no longer available (ended: [_1])',
                                     $shownprintend);
           } else {
               if (($res_printstartdate) && ($res_printstartdate > $now)) {
                   if (($res_printenddate) && ($res_printenddate > $now) && ($res_printenddate > $res_printstartdate)) {
                       $noprintmsg = &mt('Printing for current resource is only possible between [_1] and [_2]',
                                     $shownprintstart,$shownprintend);
                   } elsif (!$res_printenddate) {
                       $noprintmsg = &mt('Printing for current resource will only be possible starting [_1]',
                                         $shownprintstart);
                   } else {
                       $noprintmsg = &mt('Printing for current resource is unavailable');
                   }
               }
           }
   
           if ($noprintmsg) {
               $paramHash = Apache::lonhelper::getParamHash();
               $paramHash->{MESSAGE_TEXT} =
                   '<p class="LC_info">'.$noprintmsg.'</p>';
               Apache::lonhelper::message->new();
           }
     }      }
     $paramHash = Apache::lonhelper::getParamHash();      $paramHash = Apache::lonhelper::getParamHash();
     $paramHash = Apache::lonhelper::getParamHash();      $paramHash = Apache::lonhelper::getParamHash();

Removed from v.1.627.2.8  
changed lines
  Added in v.1.627.2.9


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