--- loncom/interface/lonprintout.pm 2011/05/18 11:26:44 1.588 +++ loncom/interface/lonprintout.pm 2011/05/23 09:31:21 1.589 @@ -2,7 +2,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.588 2011/05/18 11:26:44 foxr Exp $ +# $Id: lonprintout.pm,v 1.589 2011/05/23 09:31:21 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -3346,6 +3346,8 @@ sub printHelper { my ($map, $id, $url); my $subdir; my $is_published=0; # True when printing from resource space. + my $res_printable = 1; # By default the current resource is printable. + my $userCanPrint = ($perm{'pav'} || $perm{'pfo'}); # Get the resource name from construction space if ($helper->{VARS}->{'construction'}) { @@ -3360,7 +3362,12 @@ 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 } else { + # Resource space. + $url = $helper->{VARS}->{'postdata'}; $is_published=1; # From resource space. } @@ -3370,6 +3377,8 @@ sub printHelper { $resourceTitle = substr($postdata, rindex($postdata, '/') + 1); } $subdir = &Apache::lonnet::filelocation("", $url); + + } if (!$helper->{VARS}->{'curseed'} && $env{'form.curseed'}) { $helper->{VARS}->{'curseed'}=$env{'form.curseed'}; @@ -3399,18 +3408,29 @@ sub printHelper { my $printChoices = []; my $paramHash; - if ($resourceTitle) { + # If there is a current resource and it is printable + # Give that as a choice. + + if ($resourceTitle && $res_printable) { push @{$printChoices}, ["$resourceTitle (".&mt('the resource you just saw on the screen').")", 'current_document', 'PAGESIZE']; } # Useful filter strings - my $isProblem = '(($res->is_problem()||$res->contains_problem||$res->is_practice())) && $res->resprintable() '; + + my $isPrintable = ' && $res->resprintable()'; + + my $isProblem = '(($res->is_problem()||$res->contains_problem||$res->is_practice()))'; + $isProblem .= $isPrintable unless $userCanPrint; $isProblem .= ' && !$res->randomout()' if !$userCanSeeHidden; - my $isProblemOrMap = '($res->is_problem() || $res->contains_problem() || $res->is_sequence() || $res->is_practice()) && $res->resprintable()'; - my $isNotMap = '(!$res->is_sequence()) && $res->resprintable()'; + my $isProblemOrMap = '($res->is_problem() || $res->contains_problem() || $res->is_sequence() || $res->is_practice())'; + $isProblemOrMap .= $isPrintable unless $userCanPrint; + my $isNotMap = '(!$res->is_sequence())'; + $isNotMap .= $isPrintable unless $userCanPrint; $isNotMap .= ' && !$res->randomout()' if !$userCanSeeHidden; - my $isMap = '$res->is_map() && $res->resprintable()'; - my $symbFilter = '$res->shown_symb() && $res->resprintable()'; + my $isMap = '$res->is_map()'; + $isMap .= $isPrintable unless $userCanPrint; + my $symbFilter = '$res->shown_symb() '; + $symbFilter .= $isPrintable unless $userCanPrint; my $urlValue = '$res->link()'; $helper->declareVar('SEQUENCE');