Diff for /loncom/interface/lonprintout.pm between versions 1.614 and 1.615

version 1.614, 2012/04/04 21:04:56 version 1.615, 2012/04/10 09:49:36
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 434  RESOURCE_SELECTOR Line 435  RESOURCE_SELECTOR
   
 #-----------------------------------------------------------------------  #-----------------------------------------------------------------------
   
   ##
   # Returns the innermost print start/print end dates for a resource.
   # This is done by looking at the start/end dates for its parts and choosing
   # the intersection of those dates.
   # 
   # @param res - lonnvamaps::resource object that represents the resource.
   #
   # @return (opendate, closedate)
   #
   # @note If open/close dates are not defined they will be retunred as undef
   # @note It is possible for there to be no overlap in which case -1,-1 
   #       will be returned.
   # @note The algorithm used is to take the latest open date and the earliest end date.
   #
   
   sub get_print_dates {
       my $res = shift;
       my $partsref = $res->parts();
       my @parts   = @$partsref;
       my $open_date;
       my $close_date;
   
       if (defined(@parts) && (scalar(@parts) > 0)) {
    foreach my $part (@parts) {
       my $partopen  = $res->parmval('printstartdate', $part);
       my $partclose = $res->parmval('printenddate',  $part);
       
       $open_date  = POSIX::strftime('%D', localtime($partopen));
       $close_date = POSIX::strftime('%D', localtime($partclose));
       
       # TODO: Complete this function and use it to tailor the
       #       can't print current resource message.
       #
       
    }
       }
   
       return ($open_date, $close_date);
   }
   
 # Determine if a resource is incomplete given the map:  # Determine if a resource is incomplete given the map:
 # Parameters:  # Parameters:
 #   $username - Name of user for whom we are checking.  #   $username - Name of user for whom we are checking.
Line 3713  sub printHelper { Line 3754  sub printHelper {
     my $is_published=0; # True when printing from resource space.      my $is_published=0; # True when printing from resource space.
     my $res_printable = 1; # By default the current resource is printable.          my $res_printable = 1; # By default the current resource is printable.    
     my $userCanPrint = ($perm{'pav'} || $perm{'pfo'});      my $userCanPrint = ($perm{'pav'} || $perm{'pfo'});
       my $res_printstartdate;
       my $res_printenddate;
   
     # Get the resource name from construction space      # Get the resource name from construction space
     if ($helper->{VARS}->{'construction'}) {      if ($helper->{VARS}->{'construction'}) {
Line 3729  sub printHelper { Line 3772  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);
  } else {   } else {
     # Resource space.      # Resource space.
   
Line 3778  sub printHelper { Line 3822  sub printHelper {
   
     if ($resourceTitle && $res_printable) {      if ($resourceTitle && $res_printable) {
         push @{$printChoices}, ["<b><i>$resourceTitle</i></b> (".&mt('the resource you just saw on the screen').")", 'current_document', 'PAGESIZE'];          push @{$printChoices}, ["<b><i>$resourceTitle</i></b> (".&mt('the resource you just saw on the screen').")", 'current_document', 'PAGESIZE'];
     }      } 
       
   
     # Useful filter strings      # Useful filter strings
   
Line 4321  CHOOSE_FROM_ANY_SEQUENCE Line 4364  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) {
    $paramHash = Apache::lonhelper::getParamHash();
    $paramHash->{MESSAGE_TEXT} = 
       &mt('<p><b>Printing for current resource is only possible between [_1] and [_1]</b></p>',
       $res_printstartdate, $res_printenddate);
    Apache::lonhelper::message->new();
       }
       $paramHash = Apache::lonhelper::getParamHash();
     $paramHash = Apache::lonhelper::getParamHash();      $paramHash = Apache::lonhelper::getParamHash();
     $paramHash->{MESSAGE_TEXT} = "";      $paramHash->{MESSAGE_TEXT} = "";
     Apache::lonhelper::message->new();      Apache::lonhelper::message->new();

Removed from v.1.614  
changed lines
  Added in v.1.615


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