Diff for /loncom/interface/lonprintout.pm between versions 1.396 and 1.397

version 1.396, 2005/10/31 21:06:35 version 1.397, 2005/10/31 21:48:07
Line 42  use Apache::lonratedt; Line 42  use Apache::lonratedt;
 use POSIX qw(strftime);  use POSIX qw(strftime);
 use Apache::lonlocal;  use Apache::lonlocal;
   
   my %perm;
   
 #  #
 #   Convert a numeric code to letters  #   Convert a numeric code to letters
 #  #
Line 815  sub IndexCreation { Line 817  sub IndexCreation {
 sub print_latex_header {  sub print_latex_header {
     my $mode=shift;      my $mode=shift;
     my $output='\documentclass[letterpaper]{article}';      my $output='\documentclass[letterpaper]{article}';
     if (($mode eq 'batchmode') || (!$env{'request.role.adv'})) {      if (($mode eq 'batchmode') || (!$perm{'pav'})) {
  $output.='\batchmode';   $output.='\batchmode';
     }      }
     $output.='\newcommand{\keephidden}[1]{}\renewcommand{\deg}{$^{\circ}$}'."\n".      $output.='\newcommand{\keephidden}[1]{}\renewcommand{\deg}{$^{\circ}$}'."\n".
Line 1634  ENDPART Line 1636  ENDPART
                             'cgi.'.$identifier.'.selection' => $selectionmade,                              'cgi.'.$identifier.'.selection' => $selectionmade,
     'cgi.'.$identifier.'.tableofcontents' => $helper->{'VARS'}->{'TABLE_CONTENTS'},      'cgi.'.$identifier.'.tableofcontents' => $helper->{'VARS'}->{'TABLE_CONTENTS'},
     'cgi.'.$identifier.'.tableofindex' => $helper->{'VARS'}->{'TABLE_INDEX'},      '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.'.numberoffiles' => $#print_array,
                             'cgi.'.$identifier.'.studentnames' => $student_names,                              'cgi.'.$identifier.'.studentnames' => $student_names,
                             'cgi.'.$identifier.'.backref' => $URLback,);                              'cgi.'.$identifier.'.backref' => $URLback,);
Line 1781  sub print_resources { Line 1783  sub print_resources {
 sub handler {  sub handler {
   
     my $r = shift;      my $r = shift;
     my $helper;      
       &init_perm();
   
 #    my $loaderror=&Apache::lonnet::overloaderror($r);  #    my $loaderror=&Apache::lonnet::overloaderror($r);
 #    if ($loaderror) { return $loaderror; }  #    if ($loaderror) { return $loaderror; }
Line 1790  sub handler { Line 1793  sub handler {
 #         $env{'course.'.$env{'request.course.id'}.'.home'});  #         $env{'course.'.$env{'request.course.id'}.'.home'});
 #    if ($loaderror) { return $loaderror; }  #    if ($loaderror) { return $loaderror; }
   
     my $result = printHelper($r);      my $helper = printHelper($r);
     if (!ref($result)) {      if (!ref($helper)) {
  return $result;   return $helper;
     }      }
     $helper = $result;  
         
 # my $key;   # my $key; 
 # foreach $key (keys %{$helper->{'VARS'}}) {  # foreach $key (keys %{$helper->{'VARS'}}) {
Line 1837  sub addMessage { Line 1839  sub addMessage {
   
 use Data::Dumper;  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 {  sub printHelper {
     my $r = shift;      my $r = shift;
   
Line 1965  sub printHelper { Line 1981  sub printHelper {
     }      }
   
     my $userCanSeeHidden = Apache::lonnavmaps::advancedUser();      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();      Apache::lonhelper::registerHelperTags();
   
Line 2052  HELPERFRAGMENT Line 2065  HELPERFRAGMENT
  &Apache::lonxml::xmlparse($r, 'helper', $helperFragment);   &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      # 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)$/)) {           ($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'];          push @{$printChoices}, ['<b>Problems</b> from <b>entire course</b>', 'all_problems', 'ALL_PROBLEMS'];
Line 2316  CHOOSE_ANON2 Line 2329  CHOOSE_ANON2
     }      }
   
     # FIXME: That RE should come from a library somewhere.      # 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'];          push @{$printChoices}, ["<b>".&mt('Problems')."</b> ".&mt('from current subdirectory')." <b><i>$subdir</i></b>", 'problems_from_directory', 'CHOOSE_FROM_SUBDIR'];
   
         my $f = '$filename';          my $f = '$filename';
Line 2388  CHOOSE_FROM_ANY_SEQUENCE Line 2401  CHOOSE_FROM_ANY_SEQUENCE
     my $startedTable = 0; # have we started an HTML table yet? (need      my $startedTable = 0; # have we started an HTML table yet? (need
                           # to close it later)                            # 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')) {   ($helper->{VARS}->{'construction'} eq '1')) {
  addMessage("<hr width='33%' /><table><tr><td align='right'>Print: </td><td>");   addMessage("<hr width='33%' /><table><tr><td align='right'>Print: </td><td>");
         $paramHash = Apache::lonhelper::getParamHash();          $paramHash = Apache::lonhelper::getParamHash();
Line 2404  CHOOSE_FROM_ANY_SEQUENCE Line 2417  CHOOSE_FROM_ANY_SEQUENCE
  $startedTable = 1;   $startedTable = 1;
     }      }
   
     if ($env{'request.role.adv'}) {      if ($perm{'pav'}) {
  if (!$startedTable) {   if (!$startedTable) {
     addMessage("<hr width='33%' /><table><tr><td align='right'>LaTeX mode: </td><td>");      addMessage("<hr width='33%' /><table><tr><td align='right'>LaTeX mode: </td><td>");
     $startedTable = 1;      $startedTable = 1;
Line 2455  CHOOSE_FROM_ANY_SEQUENCE Line 2468  CHOOSE_FROM_ANY_SEQUENCE
     Apache::lonhelper::dropdown->new();      Apache::lonhelper::dropdown->new();
     addMessage("</td></tr>");      addMessage("</td></tr>");
   
             #  If advanced roles, then allow to show all foils.      addMessage("<tr><td align = 'right'>  </td><td>");
       $paramHash = Apache::lonhelper::getParamHash();
             if ($env{'request.role.adv'}) {      $paramHash->{'multichoice'} = "true";
  addMessage("<tr><td align = 'right'>  </td><td>");      $paramHash->{'allowempty'}  = "true";
  $paramHash = Apache::lonhelper::getParamHash();      $paramHash->{'variable'}   = "showallfoils";
  $paramHash->{'multichoice'} = "true";      $paramHash->{'CHOICES'} = [ ["Show all foils", "1"] ];
  $paramHash->{'allowempty'}  = "true";      Apache::lonhelper::choices->new();
  $paramHash->{'variable'}   = "showallfoils";      addMessage("</td></tr>");
  $paramHash->{'CHOICES'} = [ ["Show all foils", "1"] ];  
  Apache::lonhelper::choices->new();  
  addMessage("</td></tr>");  
             }  
   
  }   }
   
  if ($helper->{'VARS'}->{'construction'}) {    if ($helper->{'VARS'}->{'construction'}) { 

Removed from v.1.396  
changed lines
  Added in v.1.397


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>