--- loncom/interface/lonfeedback.pm 2017/05/30 02:17:45 1.370.2.1
+++ loncom/interface/lonfeedback.pm 2017/11/16 16:02:58 1.370.2.1.2.1
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.370.2.1 2017/05/30 02:17:45 raeburn Exp $
+# $Id: lonfeedback.pm,v 1.370.2.1.2.1 2017/11/16 16:02:58 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -44,8 +44,8 @@ use HTML::LCParser();
#use HTML::Tidy::libXML;
use Apache::lonspeller();
use Apache::longroup;
-use Cwd;
-use LONCAPA;
+use Archive::Zip qw( :ERROR_CODES );
+use LONCAPA qw(:DEFAULT :match);
sub discussion_open {
my ($status,$symb)=@_;
@@ -696,21 +696,29 @@ END
#Create zip file in prtspool
- my $imszipfile = '/prtspool/'.
- $env{'user.name'}.'_'.$env{'user.domain'}.'_'.
- time.'_'.rand(1000000000).'.zip';
- my $cwd = &getcwd();
- my $imszip = '/home/httpd/'.$imszipfile;
- chdir $tempexport;
- open(OUTPUT, "zip -r $imszip * 2> /dev/null |");
- close(OUTPUT);
- chdir $cwd;
- $discussion .= &mt('Download the zip file from [_1]Discussion Posting Archive[_2]',
+ if (($env{'user.name'} =~ /^$match_username$/)
+ && ($env{'user.domain'} =~ /^$match_domain$/)) {
+ my $now = time();
+ my $imszipfile = '/prtspool/'.
+ join('_',$env{'user.name'},$env{'user.domain'},$now).
+ '_'.rand(1000000000).'.zip';
+ my $zip = Archive::Zip->new();
+ $zip->addTree($tempexport);
+ my $imszip = '/home/httpd/'.$imszipfile;
+ if ($zip->writeToFileNamed($imszip) == AZ_OK) {
+ $discussion .= &mt('Download the zip file from [_1]Discussion Posting Archive[_2]',
'','').'
';
- if ($copyresult) {
- $discussion .= ''.
- &mt('The following errors occurred during export:').
- '
'.$copyresult;
+ } else {
+ $discussion .= &mt('Failed to create zip file').'
';
+ }
+ if ($copyresult) {
+ $discussion .= ''.
+ &mt('The following errors occurred during export:').
+ '
'.$copyresult;
+ }
+ } else {
+ $discussion .= '
'. + &mt('Unfortunately you will not be able to retrieve an archive of the discussion posts at this time, because there was a problem creating the zip file.').'
'; } } } else { @@ -847,7 +855,7 @@ sub send_feedback_link { &discussion_link($ressymb, '