--- loncom/interface/lonfeedback.pm 2021/01/04 03:43:30 1.370.2.5 +++ loncom/interface/lonfeedback.pm 2017/05/30 00:01:32 1.373 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.370.2.5 2021/01/04 03:43:30 raeburn Exp $ +# $Id: lonfeedback.pm,v 1.373 2017/05/30 00:01:32 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 Archive::Zip qw( :ERROR_CODES ); -use LONCAPA qw(:DEFAULT :match); +use Cwd; +use LONCAPA; sub discussion_open { my ($status,$symb)=@_; @@ -696,29 +696,21 @@ END #Create zip file in prtspool - 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]', + 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]', '','').'
'; - } 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.').'

'; + if ($copyresult) { + $discussion .= ''. + &mt('The following errors occurred during export:'). + '
'.$copyresult; } } } else { @@ -855,7 +847,7 @@ sub send_feedback_link { &discussion_link($ressymb, ''.&mt('Post Discussion').'', + '" border="0" />'.&mt('Post Discussion').'', 'replydisc'). ''; } @@ -866,7 +858,7 @@ sub send_message_link { &discussion_link($ressymb, ''.&mt('Send Feedback').'', + '" border="0" />'.&mt('Send Feedback').'', 'sendmessageonly'). ''; return $output; @@ -960,9 +952,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 @@ -1776,11 +1773,14 @@ 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{'myqu'} = &mt('Post Discussion'); + if($env{'form.editdisc'} || $env{'form.replydisc'}){ + %lt = &Apache::lonlocal::texthash( + 'myqu' => 'Post Discussion', + ); } my $restitle = &get_resource_title($caller_symb,$feedurl); my $quote=''; @@ -2055,8 +2055,8 @@ END } else { $r->print(< -$lt{'atta'} $attachmaxtext: - +$lt{'atta'} $attachmaxtext: +

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

END @@ -2942,12 +2942,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); @@ -3170,7 +3174,7 @@ sub adddiscuss { if (($symb) && ($email)) { my $now = time; if ($env{'form.editdisc'}) { - $contrib{'ip'}=&Apache::lonnet::get_requestor_ip(); + $contrib{'ip'}=$ENV{'REMOTE_ADDR'}; $contrib{'host'}=$Apache::lonnet::perlvar{'lonHostID'}; $contrib{'timestamp'} = $now; $contrib{'history'} = ''; @@ -3504,7 +3508,7 @@ sub modify_attachments { document.modattachments.action = document.modattachments.origpage.value; document.modattachments.submit(); } - + END @@ -3547,8 +3551,8 @@ END $r->print(''.$subject.''); $r->print(&Apache::lonhtmlcommon::row_closure()); $r->print(&Apache::lonhtmlcommon::row_title($lt{'adda'})); - $r->print('' - .'' + $r->print('' + .'' .' '.$attachmaxtext); if(($idx)||(ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)){ @@ -4641,7 +4645,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++;