[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface lonfeedback.pm

raeburn raeburn at source.lon-capa.org
Fri Sep 14 11:32:55 EDT 2018


raeburn		Fri Sep 14 15:32:55 2018 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	lonfeedback.pm 
  Log:
  - For 2.11
    Backport 1.374, 1.375, 1.376.
  
  
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.370.2.1 loncom/interface/lonfeedback.pm:1.370.2.2
--- loncom/interface/lonfeedback.pm:1.370.2.1	Tue May 30 02:17:45 2017
+++ loncom/interface/lonfeedback.pm	Fri Sep 14 15:32:55 2018
@@ -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.2 2018/09/14 15:32:55 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -44,8 +44,8 @@
 #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 @@
 
 #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]',
                                            '<a href="'.$imszipfile.'">','</a>').'<br />';
-                    if ($copyresult) {
-                        $discussion .= '<span class="LC_error">'.
-                                       &mt('The following errors occurred during export:').
-                                       '</span><br />'.$copyresult;
+                        } else {
+                            $discussion .=  &mt('Failed to create zip file').'<br />';
+                        }
+                        if ($copyresult) {
+                            $discussion .= '<span class="LC_error">'.
+                                           &mt('The following errors occurred during export:').
+                                           '</span><br />'.$copyresult;
+                        }
+                    } else {
+                        $discussion .= '<p class="LC_error">'.
+                                       &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.').'</p>';
                     }
                 }
             } else {
@@ -847,7 +855,7 @@
                  &discussion_link($ressymb,
                     '<img alt="" class="LC_noBorder" src="'.
                     &Apache::loncommon::lonhttpdurl('/adm/lonMisc/chat.gif').
-                    '" border="0" /><span class="LC_menubuttons_inline_text">'.&mt('Post Discussion').'</span>',
+                    '" /><span class="LC_menubuttons_inline_text">'.&mt('Post Discussion').'</span>',
                     'replydisc').
            '</span>';
 }
@@ -858,7 +866,7 @@
                  &discussion_link($ressymb,
                     '<img alt="" class="LC_noBorder" src="'.
                     &Apache::loncommon::lonhttpdurl('/res/adm/pages/feedback.png').
-                    '" border="0" /><span class="LC_menubuttons_inline_text">'.&mt('Send Feedback').'</span>',
+                    '" /><span class="LC_menubuttons_inline_text">'.&mt('Send Feedback').'</span>',
                     'sendmessageonly').
                  '</span>';
     return $output;
@@ -933,7 +941,7 @@
         $currnewattach,$currdelold,$group,$crstype) = @_;
     my $newattachmsg;
     my %lt = &Apache::lonlocal::texthash(
-              'note' => 'Note: in anonymous discussion, your name is visible only to course faculty',
+             'note' => 'Note: in anonymous discussion, your name is visible only to course faculty',
              'title' => 'Title',
              'podi' => 'Post Discussion',
              'poan' => 'Post Anonymous Discussion',




More information about the LON-CAPA-cvs mailing list