--- loncom/interface/lonfeedback.pm 2017/05/30 02:17:45 1.370.2.1 +++ loncom/interface/lonfeedback.pm 2019/08/12 16:45:48 1.383 @@ -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.383 2019/08/12 16:45:48 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)=@_; @@ -674,7 +674,7 @@ END $newpostsflag,$group, $prevread,$markondisp,$seehidden); $discussion .= "\n"; - } + } if ($outputtarget eq 'export') { if ($manifestok) { while ($currdepth > 0) { @@ -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, ''.&mt('Post Discussion').'', + '" />'.&mt('Post Discussion').'', 'replydisc'). ''; } @@ -858,7 +866,7 @@ sub send_message_link { &discussion_link($ressymb, ''.&mt('Send Feedback').'', + '" />'.&mt('Send Feedback').'', 'sendmessageonly'). ''; return $output; @@ -933,7 +941,7 @@ sub postingform_display { $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', @@ -952,9 +960,14 @@ sub postingform_display { } } } + my $postanon; + if (&Apache::lonnet::allowed('pac',$env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { + $postanon = ''; + } $postingform .= (< - +$postanon @@ -1768,14 +1781,11 @@ sub mail_screen { my %lt = &Apache::lonlocal::texthash( 'myqu' => 'Question/comment/feedback:', - 'title' => 'Title', 'reta' => 'Retained attachments', 'atta' => 'Attachment', ); - if($env{'form.editdisc'} || $env{'form.replydisc'}){ - %lt = &Apache::lonlocal::texthash( - 'myqu' => 'Post Discussion', - ); + if ($env{'form.editdisc'} || $env{'form.replydisc'}){ + $lt{'myqu'} = &mt('Post Discussion'); } my $restitle = &get_resource_title($caller_symb,$feedurl); my $quote=''; @@ -1942,6 +1952,7 @@ END $anonscript //--> + END my ($textareaheader,$textareaclass); @@ -2049,7 +2060,8 @@ END } else { $r->print(< -$lt{'atta'} $attachmaxtext: +$lt{'atta'} $attachmaxtext: +

END } @@ -2060,7 +2072,7 @@ END $r->print(''); } $r->print(< +

END @@ -2825,6 +2837,10 @@ sub redirect_back { my $start_page= &Apache::loncommon::start_page('Feedback sent',undef,\%parms); my $end_page = &Apache::loncommon::end_page(); + my $windowname = 'loncapaclient'; + if ($env{'request.lti.login'}) { + $windowname .= 'lti'; + } $r->print(< @@ -2833,7 +2849,7 @@ $typestyle $blog $toolarge $status -
+ $prevtag $sorttag $statustag @@ -2935,12 +2951,16 @@ sub screen_header { $env{'request.course.id'}. ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) || (($group ne '') && ($symb =~ m{^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$}) && (&check_group_priv($group,'pgd') eq 'ok')))) { - $discussoptions='
'. - ''.&mt('Change Screenname').''; + $discussoptions=''; + if (&Apache::lonnet::allowed('pac',$env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { + $discussoptions .= '
'. + ''.&mt('Change Screenname').''; + } my $blockblog = &Apache::loncommon::blocking_status('blogs'); if (!$blockblog) { $discussoptions.= &add_blog_checkbox($crstype); @@ -3498,6 +3518,7 @@ sub modify_attachments { document.modattachments.submit(); } + END # Breadcrumbs @@ -3539,7 +3560,10 @@ END $r->print(''.$subject.''); $r->print(&Apache::lonhtmlcommon::row_closure()); $r->print(&Apache::lonhtmlcommon::row_title($lt{'adda'})); - $r->print(' '.$attachmaxtext); + $r->print('' + .'' + .' '.$attachmaxtext); if(($idx)||(ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)){ $r->print(&Apache::lonhtmlcommon::row_closure()); $r->print(&Apache::lonhtmlcommon::row_title(&mt('Attachments'))); @@ -4024,11 +4048,15 @@ sub handler { 'only_body' => 1, 'add_entries' => \%onload}); my $end_page = &Apache::loncommon::end_page(); + my $windowname = 'loncapaclient'; + if ($env{'request.lti.login'}) { + $windowname .= 'lti'; + } $r->print (< $textline - +
$end_page @@ -4529,6 +4557,8 @@ ENDREDIR ($env{'request.course.id'} && ($feedurl!~m:^/adm:)) || ($env{'request.course.id'} && ($symb=~/^bulletin\_\_\_/)) + || + (($env{'request.course.id'} && ($feedurl =~ /ext\.tool$/))) ) { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; @@ -4630,7 +4660,11 @@ ENDREDIR && $env{'form.discuss'} !~ /^(?:author|question|course|policy)/) || $env{'form.anondiscuss'} ne '') { my $subject = &clear_out_html($env{'form.subject'}); - my $anonmode=($env{'form.discuss'} eq 'anon' || $env{'form.anondiscuss'} ); + my $anonmode; + if (&Apache::lonnet::allowed('pac',$env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { + $anonmode=($env{'form.discuss'} eq 'anon' || $env{'form.anondiscuss'} ); + } $typestyle.=&adddiscuss($symb,$message,$anonmode,$attachmenturl, $subject,$group); $numpost++;