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

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 23 Dec 2002 19:11:33 -0000


albertel		Mon Dec 23 14:11:33 2002 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm 
  Log:
  Many small fixes
  - eliminated almost all uses of request.role
  - when using a file name as a regexp you probably want to do \Q \E ( I have
     a greate testing file called ).problem)
  - eliminated the http://servername part of the url that is sent in CSTR space
    (&Apache::lonnet::filelocation()  doesn't deal well with that)
  - &Apache::lonnet::dirlist of a CSTR space needs to be sent the username/domain
    of the owner of the CSTR space not the user requesting it
  - use the URL to decide if we are in CSTR space or dealing with resources in 
    a course
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.99 loncom/interface/lonprintout.pm:1.100
--- loncom/interface/lonprintout.pm:1.99	Wed Dec 11 17:06:55 2002
+++ loncom/interface/lonprintout.pm	Mon Dec 23 14:11:33 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.99 2002/12/11 22:06:55 albertel Exp $
+# $Id: lonprintout.pm,v 1.100 2002/12/23 19:11:33 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -66,11 +66,12 @@
 <body bgcolor="FFFFFF">
 <form method="post" enctype="multipart/form-data" action="/adm/printout" name="printform">
 ENDHEADER
-    if ($ENV{'request.role'}=~m/^cc\./ or $ENV{'request.role'}=~m/^in\./ or $ENV{'request.role'}=~m/^ta\./) { 
-    $r->print(<<ENDHEADER1);
+
+    if ($ENV{'form.postdata'}=~m|^/res/|) {
+	$r->print(<<ENDHEADER1);
 <b>Path to current document: </b><tt>$ENV{'form.postdata'}</tt><p>
 ENDHEADER1
-}
+    }
 }
 
 
@@ -81,9 +82,10 @@
     if ($title_for_single_resource ne '') {$title_for_single_resource = '"'.$title_for_single_resource.'"';}
     if ($title_for_sequence ne '') {$title_for_sequence = '"'.$title_for_sequence.'"';}
     if ($title_for_main_map ne '') {$title_for_main_map = '"'.$title_for_main_map.'"';}
+    $ENV{'form.postdata'} =~ s|http://[^/]+||;
     my $subdir_to_print = $ENV{'form.postdata'};
     $subdir_to_print =~ m/\/([^\/]+)$/;
-    $subdir_to_print =~ s/$1//;
+    $subdir_to_print =~ s/\Q$1\E//;
     $r->print(<<ENDMENUOUT1);
 <h1>What do you want to print? Make a choice.</h1><br />
 <input type="hidden" name="phase" value="two">
@@ -217,14 +219,13 @@
     my $subdirtoprint = &Apache::lonnet::filelocation("",$ENV{'form.url'});
     $subdirtoprint =~ s/\/[^\/]+$//;
     my @list_of_files = ();
-    if ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./) {
-	$subdirtoprint =~ s/^[^~]*~(\w+)\//\/home\/$1\/public_html\//;
-    } else {
-	$subdirtoprint =~ s/.*(\/res\/)/$1/;
-    }
     my @content_directory = ();
-    if ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./) {
-	@content_directory = &Apache::lonnet::dirlist($subdirtoprint,$ENV{'user.domain'}, $ENV{'user.name'},'');
+    if ($subdirtoprint =~ m|/home/([^/]+)/public_html|) {
+	#localmachine CSTR space
+	my $user=$1;
+	my $domain=$Apache::lonnet::perlvar{'lonDefDomain'};
+	@content_directory = &Apache::lonnet::dirlist($subdirtoprint,
+						      $domain, $user,'');
     } else {
 	@content_directory = &Apache::lonnet::dirlist($subdirtoprint);
     }
@@ -431,7 +432,8 @@
 	if ($ENV{'form.papersize'} eq '') {$papersize = 'Letter [8 1/2x11 in]';}
 	if ($ENV{'form.numberofcolumns'} eq '') {$numberofcolumns = 2;}
     }
-    if (($choice eq 'Standard LaTeX output for current document') && ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./)) {
+    if (($choice eq 'Standard LaTeX output for current document') &&
+	($ENV{'form.url'}=~m|^/~|)) {
 	if ($ENV{'form.layout'} eq '') {$layout = 'CAPA';}
 	if ($ENV{'form.papersize'} eq '') {$papersize = 'Letter [8 1/2x11 in]';}
 	if ($ENV{'form.numberofcolumns'} eq '') {$numberofcolumns = 2;}
@@ -616,8 +618,8 @@
 		$moreenv{'form.grade_target'}='tex';
 		$moreenv{'form.textwidth'}=$LaTeXwidth;
 		&Apache::lonnet::appenv(%moreenv);
-		if ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./) { 
-		    $urlp =~ s/\/home\/([^\/]*)\/public_html/\/~$1/; 
+		if ($urlp =~ m|/home/([^/]+)/public_html|) {
+		    $urlp =~ s|/home/([^/]*)/public_html|/~$1|;
 		}
 		my $texversion=&Apache::lonnet::ssi($urlp);
 		&Apache::lonnet::delenv('form.grade_target','form.textwidth');