--- loncom/publisher/londiff.pm 2001/05/03 11:04:07 1.4
+++ loncom/publisher/londiff.pm 2001/05/09 17:38:12 1.5
@@ -15,7 +15,7 @@
#
# 03/31,04/03 Gerd Kortemeyer)
#
-# 05/02/01 Gerd Kortemeyer
+# 05/02/01,05/09 Gerd Kortemeyer
package Apache::londiff;
@@ -24,7 +24,7 @@ use Apache::File;
use File::Copy;
use Algorithm::Diff qw(diff);
use Apache::Constants qw(:common :http :methods);
-
+use Apache::loncacc;
sub handler {
@@ -46,6 +46,23 @@ sub handler {
# Get the files
+ my $cuname=$ENV{'user.name'};
+ my $cudom=$ENV{'user.domain'};
+
+ unless (($cuname,$cudom)=
+ &Apache::loncacc::constructaccess($ENV{'form.filename'},
+ $r->dir_config('lonDefDomain'))) {
+ $r->log_reason($cuname.' at '.$cudom.
+ ' trying to get diffs file '.$ENV{'form.filename'}.
+ ' - not authorized',
+ $r->filename);
+ return HTTP_NOT_ACCEPTABLE;
+ }
+
+ my $efn=$ENV{'form.filename'};
+
+ $efn=~s/\/\~(\w+)//g;
+
my @f1=();
my @f2=();
@@ -57,12 +74,18 @@ sub handler {
$r->print('
');
- $r->print('Compare versions of '.$ENV{'form.filename'}.'
');
+ $r->print('Compare versions of '.$efn.'
');
+
+ if (($cuname ne $ENV{'user.name'}) || ($cudom ne $ENV{'user.domain'})) {
+ $r->print('Co-Author: '.$cuname.' at '.$cudom.
+ '
');
+ }
+
- if (&Apache::lonnet::fileembstyle(($ENV{'form.filename'}=~/\.(\w+)$/)) eq
+ if (&Apache::lonnet::fileembstyle(($efn=~/\.(\w+)$/)) eq
'ssi') {
if ($ENV{'form.versionone'} eq 'priv') {
- my $fn='/home/'.$ENV{'user.name'}.'/public_html/'.$ENV{'form.filename'};
+ my $fn='/home/'.$cuname.'/public_html/'.$efn;
if (-e $fn) {
my $fh=Apache::File->new($fn);
my $line;
@@ -74,13 +97,13 @@ sub handler {
$r->print('Construction Space Version
');
} else {
my $fn=
- '/home/httpd/html//res/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/';
+ '/home/httpd/html//res/'.$cudom.'/'.$cuname.'/';
if ($ENV{'form.versionone'}) {
- my ($main,$suffix)=($ENV{'form.filename'}=~/^(.+)\.(\w+)$/);
+ my ($main,$suffix)=($efn=~/^(.+)\.(\w+)$/);
$fn.=$main.'.'.$ENV{'form.versionone'}.'.'.$suffix;
$r->print('Version '.$ENV{'form.versionone'}.'
');
} else {
- $fn.=$ENV{'form.filename'};
+ $fn.=$efn;
$r->print('Current Version
');
}
@f1=split(/\n/,&Apache::lonnet::getfile($fn));
@@ -89,7 +112,7 @@ sub handler {
$r->print('versus');
if ($ENV{'form.versiontwo'} eq 'priv') {
- my $fn='/home/'.$ENV{'user.name'}.'/public_html/'.$ENV{'form.filename'};
+ my $fn='/home/'.$cuname.'/public_html/'.$efn;
if (-e $fn) {
my $fh=Apache::File->new($fn);
my $line;
@@ -101,13 +124,13 @@ sub handler {
$r->print('Construction Space Version
');
} else {
my $fn=
- '/home/httpd/html/res/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/';
+ '/home/httpd/html/res/'.$cudom.'/'.$cuname.'/';
if ($ENV{'form.versiontwo'}) {
- my ($main,$suffix)=($ENV{'form.filename'}=~/^(.+)\.(\w+)$/);
+ my ($main,$suffix)=($efn=~/^(.+)\.(\w+)$/);
$fn.=$main.'.'.$ENV{'form.versiontwo'}.'.'.$suffix;
$r->print('Version '.$ENV{'form.versiontwo'}.'
');
} else {
- $fn.=$ENV{'form.filename'};
+ $fn.=$efn;
$r->print('Current Version
');
}
@f2=split(/\n/,&Apache::lonnet::getfile($fn));