[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm

foxr foxr@source.lon-capa.org
Mon, 23 May 2011 09:31:22 -0000


foxr		Mon May 23 09:31:22 2011 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm 
  Log:
  3462 - Add more print selectivity:
        * If the user has appropriate perms they can always print regardless
          of print open/close dates.
        * If the current resource is not printable show no radio button.
  
  NOTE:  This is not yet useable.  There is evidently still some detritus from not yet completing code for BZ5209  .. do not promote this to production.
  
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.588 loncom/interface/lonprintout.pm:1.589
--- loncom/interface/lonprintout.pm:1.588	Wed May 18 11:26:44 2011
+++ loncom/interface/lonprintout.pm	Mon May 23 09:31:21 2011
@@ -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 @@
     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 @@
 	    ($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 @@
             $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 @@
     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}, ["<b><i>$resourceTitle</i></b> (".&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');