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

foxr lon-capa-cvs@mail.lon-capa.org
Mon, 24 Jul 2006 22:13:58 -0000


foxr		Mon Jul 24 18:13:58 2006 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm 
  Log:
  Skip page margin settings and default if user does not have pav privilege.
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.466 loncom/interface/lonprintout.pm:1.467
--- loncom/interface/lonprintout.pm:1.466	Wed Jul 19 23:47:09 2006
+++ loncom/interface/lonprintout.pm	Mon Jul 24 18:13:58 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.466 2006/07/20 03:47:09 albertel Exp $
+# $Id: lonprintout.pm,v 1.467 2006/07/24 22:13:58 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2975,6 +2975,7 @@
 
     $self->{NEXTSTATE} = shift;
     bless($self);
+
     return $self;
 }
 
@@ -2984,6 +2985,8 @@
     my $result = '';
     my $var = $self->{'variable'};
 
+
+
     if (defined $self->{ERROR_MSG}) {
         $result .= '<br /><span class="LC_error">' . $self->{ERROR_MSG} . '</span><br />';
     }
@@ -3073,6 +3076,46 @@
     my $helper = Apache::lonhelper::getHelper();
 
     my $format = $helper->{VARS}->{$self->{'formatvar'}};
+
+    #  If the user does not have 'pav' privilege, set default widths and
+    #  on to the next state right away.
+    #
+    if (!$perm{'pav'}) {
+	my $var = $self->{'variable'};
+	my $format = $helper->{VARS}->{$self->{'formatvar'}};
+	
+	my ($laystyle, $cols, $papersize) = split(/\|/, $format);
+	($papersize)                      = split(/ /, $papersize);
+	
+	
+	if ($laystyle eq 'L') {
+	    $laystyle = 'album';
+	} else {
+	    $laystyle = 'book';
+	}
+	#  Figure out some good defaults for the print out and set them:
+	
+	my %size;
+	($size{'width'},
+	 $size{'height'},
+	 $size{'lmargin'})=
+	     &Apache::lonprintout::page_format($papersize, $laystyle, $cols);
+	
+	foreach my $dim ('width', 'height', 'lmargin') {
+	    my ($value, $units) = split(/ /, $size{$dim});
+	    
+	    &Apache::lonnet::logthis("$dim : $value : $units");
+	    
+	    $helper->{VARS}->{"$var.".$dim}      = $value;
+	    $helper->{VARS}->{"$var.".$dim.'unit'} = $units;
+	    
+	}
+	
+
+	# Transition to the next state
+
+	$helper->changeState($self->{NEXTSTATE});
+    }
    
     return 1;
 }