[LON-CAPA-cvs] cvs: loncom /auth roles.tab rolesplain.tab /interface lonprintout.pm printout.pl

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 31 Oct 2005 21:48:16 -0000


This is a MIME encoded message

--albertel1130795296
Content-Type: text/plain

albertel		Mon Oct 31 16:48:16 2005 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm printout.pl 
    /loncom/auth	roles.tab rolesplain.tab 
  Log:
  - BUG#4321, stop checnking request.role.adv for wheterh advanced printing can be done, 2 new privledges 'pfo' Print for otheres, and 'pav' advanced printing options (i.e with answers etc.)
  
  
  
  
--albertel1130795296
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20051031164816.txt"

Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.396 loncom/interface/lonprintout.pm:1.397
--- loncom/interface/lonprintout.pm:1.396	Mon Oct 31 16:06:35 2005
+++ loncom/interface/lonprintout.pm	Mon Oct 31 16:48:07 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.396 2005/10/31 21:06:35 albertel Exp $
+# $Id: lonprintout.pm,v 1.397 2005/10/31 21:48:07 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -42,6 +42,8 @@
 use POSIX qw(strftime);
 use Apache::lonlocal;
 
+my %perm;
+
 #
 #   Convert a numeric code to letters
 #
@@ -815,7 +817,7 @@
 sub print_latex_header {
     my $mode=shift;
     my $output='\documentclass[letterpaper]{article}';
-    if (($mode eq 'batchmode') || (!$env{'request.role.adv'})) {
+    if (($mode eq 'batchmode') || (!$perm{'pav'})) {
 	$output.='\batchmode';
     }
     $output.='\newcommand{\keephidden}[1]{}\renewcommand{\deg}{$^{\circ}$}'."\n".
@@ -1634,7 +1636,7 @@
                             'cgi.'.$identifier.'.selection' => $selectionmade,
 			    'cgi.'.$identifier.'.tableofcontents' => $helper->{'VARS'}->{'TABLE_CONTENTS'},
 			    'cgi.'.$identifier.'.tableofindex' => $helper->{'VARS'}->{'TABLE_INDEX'},
-			    'cgi.'.$identifier.'.role' => $env{'request.role.adv'},
+			    'cgi.'.$identifier.'.role' => $perm{'pav'},
                             'cgi.'.$identifier.'.numberoffiles' => $#print_array,
                             'cgi.'.$identifier.'.studentnames' => $student_names,
                             'cgi.'.$identifier.'.backref' => $URLback,);
@@ -1781,7 +1783,8 @@
 sub handler {
 
     my $r = shift;
-    my $helper;
+    
+    &init_perm();
 
 #    my $loaderror=&Apache::lonnet::overloaderror($r);
 #    if ($loaderror) { return $loaderror; }
@@ -1790,11 +1793,10 @@
 #         $env{'course.'.$env{'request.course.id'}.'.home'});
 #    if ($loaderror) { return $loaderror; }
 
-    my $result = printHelper($r);
-    if (!ref($result)) {
-	return $result;
+    my $helper = printHelper($r);
+    if (!ref($helper)) {
+	return $helper;
     }
-    $helper = $result;
    
 #	my $key; 
 #	foreach $key (keys %{$helper->{'VARS'}}) {
@@ -1837,6 +1839,20 @@
 
 use Data::Dumper;
 
+sub init_perm {
+    undef(%perm);
+    $perm{'pav'}=&Apache::lonnet::allowed('pav',$env{'request.course.id'});
+    if (!$perm{'pav'}) {
+	$perm{'pav'}=&Apache::lonnet::allowed('pav',
+		  $env{'request.course.id'}.'/'.$env{'request.course.sec'});
+    }
+    $perm{'pfo'}=&Apache::lonnet::allowed('pav',$env{'request.course.id'});
+    if (!$perm{'pfo'}) {
+	$perm{'pfo'}=&Apache::lonnet::allowed('pfo',
+		  $env{'request.course.id'}.'/'.$env{'request.course.sec'});
+    }
+}
+
 sub printHelper {
     my $r = shift;
 
@@ -1965,9 +1981,6 @@
     }
 
     my $userCanSeeHidden = Apache::lonnavmaps::advancedUser();
-    my $userPriviledged = ($env{'request.role'}=~m/^cc\./ or
-			   $env{'request.role'}=~m/^in\./ or
-			   $env{'request.role'}=~m/^ta\./);
 
     Apache::lonhelper::registerHelperTags();
 
@@ -2052,9 +2065,9 @@
 	&Apache::lonxml::xmlparse($r, 'helper', $helperFragment);
     }
 
-    # If the user is privileged, allow them to print all 
+    # If the user has pfo (print for otheres) allow them to print all 
     # problems and resources  in the entier course, optionally for selected students
-    if ($userPriviledged && 
+    if ($perm{'pfo'} && 
         ($helper->{VARS}->{'postdata'}=~/\/res\// || $helper->{VARS}->{'postdata'}=~/\/(syllabus|smppg|aboutme|bulletinboard)$/)) { 
 
         push @{$printChoices}, ['<b>Problems</b> from <b>entire course</b>', 'all_problems', 'ALL_PROBLEMS'];
@@ -2316,7 +2329,7 @@
     }
 
     # FIXME: That RE should come from a library somewhere.
-    if ((((&Apache::lonnet::allowed('bre',$subdir) eq 'F') and ($helper->{VARS}->{'postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/)) or defined $helper->{'VARS'}->{'construction'}) and $env{'request.role.adv'} and $subdir ne $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/') {    
+    if ((((&Apache::lonnet::allowed('bre',$subdir) eq 'F') and ($helper->{VARS}->{'postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/)) or defined $helper->{'VARS'}->{'construction'}) and $perm{'pav'} and $subdir ne $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/') {    
         push @{$printChoices}, ["<b>".&mt('Problems')."</b> ".&mt('from current subdirectory')." <b><i>$subdir</i></b>", 'problems_from_directory', 'CHOOSE_FROM_SUBDIR'];
 
         my $f = '$filename';
@@ -2388,7 +2401,7 @@
     my $startedTable = 0; # have we started an HTML table yet? (need
                           # to close it later)
 
-    if (($env{'request.role.adv'} and &Apache::lonnet::allowed('vgr',$env{'request.course.id'})) or 
+    if (($perm{'pav'} and &Apache::lonnet::allowed('vgr',$env{'request.course.id'})) or 
 	($helper->{VARS}->{'construction'} eq '1')) {
 	addMessage("<hr width='33%' /><table><tr><td align='right'>Print: </td><td>");
         $paramHash = Apache::lonhelper::getParamHash();
@@ -2404,7 +2417,7 @@
 	$startedTable = 1;
     }
 
-    if ($env{'request.role.adv'}) {
+    if ($perm{'pav'}) {
 	if (!$startedTable) {
 	    addMessage("<hr width='33%' /><table><tr><td align='right'>LaTeX mode: </td><td>");
 	    $startedTable = 1;
@@ -2455,19 +2468,14 @@
 	    Apache::lonhelper::dropdown->new();
 	    addMessage("</td></tr>");
 
-            #  If advanced roles, then allow to show all foils.
-
-            if ($env{'request.role.adv'}) {
-		addMessage("<tr><td align = 'right'>  </td><td>");
-		$paramHash = Apache::lonhelper::getParamHash();
-		$paramHash->{'multichoice'} = "true";
-		$paramHash->{'allowempty'}  = "true";
-		$paramHash->{'variable'}   = "showallfoils";
-		$paramHash->{'CHOICES'} = [ ["Show all foils", "1"] ];
-		Apache::lonhelper::choices->new();
-		addMessage("</td></tr>");
-            }
-
+	    addMessage("<tr><td align = 'right'>  </td><td>");
+	    $paramHash = Apache::lonhelper::getParamHash();
+	    $paramHash->{'multichoice'} = "true";
+	    $paramHash->{'allowempty'}  = "true";
+	    $paramHash->{'variable'}   = "showallfoils";
+	    $paramHash->{'CHOICES'} = [ ["Show all foils", "1"] ];
+	    Apache::lonhelper::choices->new();
+	    addMessage("</td></tr>");
 	}
 
 	if ($helper->{'VARS'}->{'construction'}) { 
Index: loncom/interface/printout.pl
diff -u loncom/interface/printout.pl:1.91 loncom/interface/printout.pl:1.92
--- loncom/interface/printout.pl:1.91	Fri Sep 16 15:36:08 2005
+++ loncom/interface/printout.pl	Mon Oct 31 16:48:07 2005
@@ -41,19 +41,14 @@
 use strict;
 
 
-#
 #   Determine if a user is operating as a student for this course/domain.
-#
-#
 #Parameters:
-#   course  - The course id.
-#   cdom    - The course domain.
-#
+#    none
 #Implicit:
 #    $env{request.role} contains the role under which this user operated this
 #                       this request.
 sub is_student {
-    return (! $env{'request.role.adv'});
+    return ($env{'request.role'}=~/^st\./);
 }
 
 #
@@ -112,7 +107,7 @@
 	#  The user is a student in the course:
 	#
 	
-	if (&is_student( $courseid, $coursedom)) {
+	if (&is_student()) {
 	    # build the subject and message body:
 	    # print "sending message to course coordinators.<br />";
 
@@ -182,8 +177,6 @@
   my $student_names = $env{'cgi.'.$identifier.'.studentnames'};
   my $backref = &Apache::lonnet::unescape($env{'cgi.'.$identifier.'.backref'});
 
-
-  my $adv = $env{'request.role.adv'};
   
   my @names_pack=();
   if ($student_names=~/_END_/) {  
@@ -204,7 +197,7 @@
       close $temporary_file;  
       my $noteps;
       my %prog_state;
-      if ($adv) { %prog_state=&Apache::lonhtmlcommon::Create_PrgWin('','Coverting Images to EPS','Picture Conversion Status',$#content_of_file,'inline','80');  }
+      if ($advanced_role) { %prog_state=&Apache::lonhtmlcommon::Create_PrgWin('','Coverting Images to EPS','Picture Conversion Status',$#content_of_file,'inline','80');  }
       foreach my $not_eps (@content_of_file) {
 	  chomp($not_eps);
 	  if ($not_eps ne '') {
@@ -234,7 +227,7 @@
 	      $not_eps =~ s/\s+$//;
 	      $not_eps =~ s/ /\\ /g;
 	      if ( exists($done_conversion{$not_eps})) { next; }
-	      if ($adv) {
+	      if ($advanced_role) {
 		  my $prettyname=$not_eps;
 		  $prettyname=~s|/home/([^/]+)/public_html|/priv/$1|;
 		  $prettyname=~s|$Apache::lonnet::perlvar{'lonDocRoot'}/|/|;
@@ -254,7 +247,7 @@
 	      }  
 	  }
       }
-      if ($adv) { 
+      if ($advanced_role) { 
 	  &Apache::lonhtmlcommon::Close_PrgWin('',\%prog_state); 
       }
       unlink($figfile);
@@ -274,7 +267,7 @@
 my $ind=-1;
 my %prog_state;
 print "<a href=\"$backref\"><b>Return</b></a> to last resource.<br /><br />";
-if ($adv) { %prog_state=&Apache::lonhtmlcommon::Create_PrgWin('','Print Status','Class Print Status',$number_of_files,'inline','80'); }
+if ($advanced_role) { %prog_state=&Apache::lonhtmlcommon::Create_PrgWin('','Print Status','Class Print Status',$number_of_files,'inline','80'); }
 print "<br />";
 my $num_files = @texfile;
 foreach $texfile (@texfile) {
@@ -318,7 +311,7 @@
   }
   $name_range =~ s/'//g;	# O'Neil -> ONeil e.g.
   print "<br/>";
-  if ($adv) { &Apache::lonhtmlcommon::Update_PrgWin('',\%prog_state,'Creating PDF for '.$status_statement); }
+  if ($advanced_role) { &Apache::lonhtmlcommon::Update_PrgWin('',\%prog_state,'Creating PDF for '.$status_statement); }
   #  This little piece of dirt puts username ranges into the original tex
   #  Tex filename from which they'll propagate into the other filenames as well.
   #
@@ -608,7 +601,7 @@
     $zipfile=~s/\/home\/httpd//;
     print "<br /> A <a href=\"$zipfile\">ZIP file</a> of all the PDFs.";
 }
-if ($adv) { &Apache::lonhtmlcommon::Close_PrgWin('',\%prog_state); }
+if ($advanced_role) { &Apache::lonhtmlcommon::Close_PrgWin('',\%prog_state); }
 
 my $done;
 sub REAPER {
@@ -621,7 +614,7 @@
     $SIG{CHLD} = \&REAPER;
     $done=0;
     my $pid=open(CMD,"$command |");
-    if ($adv) {
+    if ($advanced_role) {
 	&Apache::lonhtmlcommon::Update_PrgWin('',$progress_win,$message);
     }
     while(!$done) {
@@ -631,7 +624,7 @@
 	    my $size=(stat($output_file))[7];
 	    $extra_msg=", $size bytes generated";
 	}
-	if ($adv) {
+	if ($advanced_role) {
 	    &Apache::lonhtmlcommon::Update_PrgWin('',$progress_win,
 						  $message.$extra_msg);
 	}
Index: loncom/auth/roles.tab
diff -u loncom/auth/roles.tab:1.41 loncom/auth/roles.tab:1.42
--- loncom/auth/roles.tab:1.41	Thu Oct 27 19:33:25 2005
+++ loncom/auth/roles.tab	Mon Oct 31 16:48:15 2005
@@ -2,17 +2,19 @@
 dc:s bre:sma:adv:mcr
 dc:d cli&UIK:cau&UIK:cca&UIK:caa&UIK:cdg&UIK:mau:ccc&U:cin&UIK:cta&UIK:cep&UIK:ccr&UIK:cst&UIK:cad&UIK:csc&UIK:dro:mky:psa:usc
 cc:s bre:sma:mcr:vsa:adv:vcl
-cc:c cin&IK:cta&IK:cep&IK:ccr&IK:cst&IK:are:cre:ere:vgr:gan:srm:opa:mgr:mgq:rin:pch:plc:mdc:usc:vsa:vcl:mdg
+cc:c cin&IK:cta&IK:cep&IK:ccr&IK:cst&IK:are:cre:ere:vgr:gan:srm:opa:mgr:mgq:rin:pch:plc:mdc:usc:vsa:vcl:mdg:pav:pfo
 in:s sma:vgr:mgr:adv:vcl
+in:c vgr:mgr:mgq:gan:dcm:srm:pch&C:plc&C:dch:pac:rin:las:opa:bre:vcl:vcg:pav:pfo
 in:c vgr:mgr:mgq:gan:dcm:srm:pch&C:plc&C:dch:pac:rin:las:opa:bre:vcl:vcg
 ta:d sma
+ta:c bre&RL:vgr&CR:mgr&CR:srm:pch&C:plc&C:dch:pac:vcg:pfo
 ta:c bre&RL:vgr&CR:mgr&CR:srm:pch&C:plc&C:dch:pac:vcg
 ep:s adv
 ep:d sma
-ep:c bre&R:mgr&R:dcm:las
+ep:c bre&R:mgr&R:dcm:las:pav:pfo
 cr:s adv&SR:bre&S
 cr:d sma
-cr:c bre&R:vgr&SCR:mgr&SCR:mgq&SCR:gan&SCR:dcm&SC:srm&SC:pch:plc:dch&S:pac:rin&S:las&SR:opa&SR:mdc&SR:cst&IK
+cr:c bre&R:vgr&SCR:mgr&SCR:mgq&SCR:gan&SCR:dcm&SC:srm&SC:pch:plc:dch&S:pac:rin&S:las&SR:opa&SR:mdc&SR:cst&IK:pav&C:pfo&C
 st:d sma&L
 st:c bre&RXL:pch&CL:plc&CL:pac&CL
 ad:s adv
Index: loncom/auth/rolesplain.tab
diff -u loncom/auth/rolesplain.tab:1.17 loncom/auth/rolesplain.tab:1.18
--- loncom/auth/rolesplain.tab:1.17	Thu Oct 27 19:33:25 2005
+++ loncom/auth/rolesplain.tab	Mon Oct 31 16:48:15 2005
@@ -72,4 +72,6 @@
 ain:Assume a student's identity
 psa:Post system frontpage announcements
 usc:Upload Scantron data
+pfo:Print for other users and entire course
+pad:Advanced printing options (with answers, discussions, all foils, ...)
 adv:Advanced Role

--albertel1130795296--