[LON-CAPA-cvs] cvs: loncom /publisher loncleanup.pm
raeburn
raeburn at source.lon-capa.org
Sat Oct 29 15:17:09 EDT 2011
raeburn Sat Oct 29 19:17:09 2011 EDT
Modified files:
/loncom/publisher loncleanup.pm
Log:
- Bug 1320 - replace '/~' with /priv/$udom when constructing $uri.
- replace \~($LONCAPA::username_re) with /priv in regexps
- use lonDocRoot perlvar in place of static string: '/home/httpd/html'
- eliminate // when constructing links.
- coding style: eliminate leaning toothpicks.
Index: loncom/publisher/loncleanup.pm
diff -u loncom/publisher/loncleanup.pm:1.13 loncom/publisher/loncleanup.pm:1.14
--- loncom/publisher/loncleanup.pm:1.13 Mon Oct 24 22:39:21 2011
+++ loncom/publisher/loncleanup.pm Sat Oct 29 19:17:09 2011
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to cleanup XML files
#
-# $Id: loncleanup.pm,v 1.13 2011/10/24 22:39:21 www Exp $
+# $Id: loncleanup.pm,v 1.14 2011/10/29 19:17:09 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -278,13 +278,15 @@
sub phasetwo {
# Check original file
my ($r,$fn,$uname,$udom)=@_;
- open(IN,'/home/httpd/html/priv/'.$udom.'/'.$uname.'/'.$fn);
my $text='';
- while (my $line=<IN>) {
- $text.=$line;
+ my $londocroot = $r->dir_config('lonDocRoot');
+ if (open(IN,"<$londocroot/priv/$udom/$uname".$fn)) {
+ while (my $line=<IN>) {
+ $text.=$line;
+ }
+ close(IN);
}
- close(IN);
- my $uri='/~'.$uname.$fn;
+ my $uri="/priv/$udom/$uname".$fn;
my $result=&Apache::lonnet::ssi_body($uri,
('grade_target'=>'web',
'return_only_error_and_warning_counts' => 1));
@@ -310,10 +312,11 @@
($env{'form.symbol'} ne 'on'));
my ($main,$ext)=($fn=~/^(.*)\.(\w+)/);
my $newfn=$main.'_Auto_Cleaned_Up.'.$ext;
- open(OUT,'>/home/httpd/html/priv/'.$udom.'/'.$uname.'/'.$newfn);
- print OUT $text;
- close(OUT);
- my $newuri='/~'.$uname.$newfn;
+ if (open(OUT,">$londocroot/priv/$udom/$uname".$newfn)) {
+ print OUT $text;
+ close(OUT);
+ }
+ my $newuri="/priv/$udom/$uname".$newfn;
$result=&Apache::lonnet::ssi_body($newuri,
('grade_target'=>'web',
'return_only_error_and_warning_counts' => 1));
@@ -356,10 +359,10 @@
sub phasethree {
my ($r,$fn,$uname,$udom)=@_;
- my $old='/home/httpd/html/priv/'.$udom.'/'.$uname.'/'.$fn;
+ my $old=$r->dir_config('lonDocRoot')."/priv/$udom/$uname".$fn;
my ($main,$ext)=($fn=~/^(.*)\.(\w+)/);
my $newfn=$main.'_Auto_Cleaned_Up.'.$ext;
- my $new='/home/httpd/html/priv/'.$udom.'/'.$uname.'/'.$newfn;
+ my $new=$r->dir_config('lonDocRoot')."/priv/$udom/$uname".$newfn;
if ($env{'form.accept'}) {
$r->print(
'<p class="LC_info">'
@@ -416,7 +419,7 @@
return HTTP_NOT_ACCEPTABLE;
}
- $fn=~s{/~($LONCAPA::username_re)}{};
+ $fn=~s{^/priv/$LONCAPA::domain_re/$LONCAPA::username_re}{};
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
@@ -445,14 +448,14 @@
}
}
my $dir=$fn;
- $dir=~s/\/[^\/]+$/\//;
+ $dir=~s{[^/]+$}{};
$r->print(
'</form>'
.&Apache::lonhtmlcommon::start_funclist()
.&Apache::lonhtmlcommon::add_item_funclist(
- '<a href="/priv/'.$udom.'/'.$uname.'/'.$fn.'">'.&mt('Back to Source File').'</a>')
+ '<a href="/priv/'.$udom.'/'.$uname.$fn.'">'.&mt('Back to Source File').'</a>')
.&Apache::lonhtmlcommon::add_item_funclist(
- '<a href="/priv/'.$udom.'/'.$uname.'/'.$dir.'">'.&mt('Back to Source Directory').'</a>')
+ '<a href="/priv/'.$udom.'/'.$uname.$dir.'">'.&mt('Back to Source Directory').'</a>')
.&Apache::lonhtmlcommon::end_funclist()
.&Apache::loncommon::end_page()
);
More information about the LON-CAPA-cvs
mailing list