--- loncom/interface/lonprintout.pm 2018/09/04 14:35:21 1.627.2.24 +++ loncom/interface/lonprintout.pm 2018/10/02 19:25:30 1.627.2.25 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.627.2.24 2018/09/04 14:35:21 raeburn Exp $ +# $Id: lonprintout.pm,v 1.627.2.25 2018/10/02 19:25:30 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -4077,6 +4077,7 @@ sub printHelper { my $subdir; my $is_published=0; # True when printing from resource space. my $res_printable = 1; # By default the current resource is printable. + my $res_error; my $userCanPrint = ($perm{'pav'} || $perm{'pfo'}); my $res_printstartdate; my $res_printenddate; @@ -4098,13 +4099,22 @@ sub printHelper { ($map, $id, $url) = &Apache::lonnet::decode_symb($symb); $helper->{VARS}->{'postdata'} = &Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($url)); - my $navmap = Apache::lonnavmaps::navmap->new(); - my $res = $navmap->getBySymb($symb); - $res_printable = $res->resprintable() || $userCanPrint; #printability in course context - ($res_printstartdate, $res_printenddate) = &get_print_dates($res); - ($course_open, $course_close) = &course_print_dates($res); - ($map_open, $map_close) = &map_print_dates($res); - + if (!$userCanPrint) { + my $navmap = Apache::lonnavmaps::navmap->new(); + if (ref($navmap)) { + my $res = $navmap->getBySymb($symb); + if (ref($res)) { + $res_printable = $res->resprintable(); #printability in course context + ($res_printstartdate, $res_printenddate) = &get_print_dates($res); + ($course_open, $course_close) = &course_print_dates($res); + ($map_open, $map_close) = &map_print_dates($res); + } else { + $res_error = 1; + } + } else { + $res_error = 1; + } + } } else { # Resource space. @@ -4705,23 +4715,27 @@ CHOOSE_FROM_ANY_SEQUENCE # Generate the first state, to select which resources get printed. Apache::lonhelper::state->new("START", "Select Printing Options:"); if (!$res_printable) { - my $now = time; - my $shownprintstart = &Apache::lonlocal::locallocaltime($res_printstartdate); - my $shownprintend = &Apache::lonlocal::locallocaltime($res_printenddate); my $noprintmsg; - if (($res_printenddate) && ($res_printenddate < $now)) { + if ($res_error) { + $noprintmsg = &mt('Print availability for current resource could not be determined'); + } else { + my $now = time; + my $shownprintstart = &Apache::lonlocal::locallocaltime($res_printstartdate); + my $shownprintend = &Apache::lonlocal::locallocaltime($res_printenddate); + if (($res_printenddate) && ($res_printenddate < $now)) { $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'); + } 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'); + } } } }