--- loncom/interface/lonfeedback.pm 2016/03/23 02:19:09 1.372 +++ loncom/interface/lonfeedback.pm 2021/10/20 16:15:04 1.386 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.372 2016/03/23 02:19:09 raeburn Exp $ +# $Id: lonfeedback.pm,v 1.386 2021/10/20 16:15:04 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)=@_; @@ -118,10 +118,16 @@ sub list_discussion { $outputtarget = 'export'; } } + my ($nofooter,$nodisclink,$nofdbklink); if (not &discussion_visible($status)) { if ($mode ne 'board') { - &Apache::lonenc::check_encrypt(\$ressymb); - return '
"; + ($nofooter,$nodisclink,$nofdbklink) = &check_menucoll(); + if ($nofooter || $nofdbklink) { + return '
'; + } else { + &Apache::lonenc::check_encrypt(\$ressymb); + return '
"; + } } } if ($group ne '' && $mode eq 'board') { @@ -130,17 +136,27 @@ sub list_discussion { } } - my ($blocked,$blocktext) = - &Apache::loncommon::blocking_status('boards'); - if ($blocked) { - $blocktext = '
'; - }else{ - $blocktext.=""; + unless ($outputtarget eq 'export') { + ($nofooter,$nodisclink,$nofdbklink) = &check_menucoll(); + } + + unless ($nofooter) { + my ($blocked,$blocktext) = + &Apache::loncommon::blocking_status('boards'); + if ($blocked) { + my $footer = '
'; + return $footer; } - return $blocktext; } my @bgcols = ("LC_disc_old_item","LC_disc_new_item"); @@ -674,7 +690,7 @@ END $newpostsflag,$group, $prevread,$markondisp,$seehidden); $discussion .= "\n"; - } + } if ($outputtarget eq 'export') { if ($manifestok) { while ($currdepth > 0) { @@ -696,21 +712,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 { @@ -766,33 +790,60 @@ END &mt('This discussion is closed.').''; } } elsif ($outputtarget ne 'tex') { - $discussion.=''; } return $discussion; } +sub check_menucoll { + my ($nofooter,$nodisclink,$nofdbklink); + my ($menucoll,$deeplinkmenu,$menuref) = &Apache::loncommon::menucoll_in_effect(); + if ($menucoll) { + if (ref($menuref) eq 'HASH') { + if ($menuref->{'foot'} eq 'n') { + $nofooter = 1; + } else { + unless ($menuref->{'disc'}) { + $nodisclink = 1; + } + unless ($menuref->{'fdbk'}) { + $nofdbklink = 1; + } + } + } + } + return ($nofooter,$nodisclink,$nofdbklink); +} + sub can_see_hidden { my ($mode,$ressymb,$feedurl,$group,$cdom,$cnum,$crs) = @_; my $seehidden; @@ -847,7 +898,7 @@ sub send_feedback_link { &discussion_link($ressymb, ''.&mt('Post Discussion').'', + '" />'.&mt('Post Discussion').'', 'replydisc'). ''; } @@ -858,7 +909,7 @@ sub send_message_link { &discussion_link($ressymb, ''.&mt('Send Feedback').'', + '" />'.&mt('Send Feedback').'', 'sendmessageonly'). ''; return $output; @@ -1290,7 +1341,7 @@ sub build_posting_display { if (&editing_allowed($escsymb.':::'.$idx,$group)) { if (($env{'user.domain'} eq $contrib{$idx.':senderdomain'}) && ($env{'user.name'} eq $contrib{$idx.':sendername'})) { $sender.=' '. - &discussion_link($symb,&mt('Edit'),'editdisc',$idx,$$newpostsflag,$prevread,&group_args($group)); + &discussion_link($ressymb,&mt('Edit'),'editdisc',$idx,$$newpostsflag,$prevread,&group_args($group)); unless ($seehidden) { my $grpargs = &group_args($group); $sender.=" '; } else { - $$discussionitems[$idx].=' '.&discussion_link($symb,''.&mt('Like').'','like',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Like this posting")); + $$discussionitems[$idx].=' '.&discussion_link($ressymb,''.&mt('Like').'','like',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Like this posting")); } if ($userunlikes{$idx}) { $$discussionitems[$idx].=''.&mt('You unlike this posting').''; } else { - $$discussionitems[$idx].=' '.&discussion_link($symb,''.&mt('Unlike').'','unlike',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Unlike this posting")); + $$discussionitems[$idx].=' '.&discussion_link($ressymb,''.&mt('Unlike').'','unlike',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Unlike this posting")); } } } @@ -1541,7 +1592,7 @@ sub build_posting_display { $$discussionitems[$idx] .= '  '.&mt('This post has been edited by the author.'); if ($seehidden) { $$discussionitems[$idx] .= '  '. - &discussion_link($symb,&mt('Display all versions'),'allversions',$idx,$$newpostsflag,$prevread,&group_args($group)); + &discussion_link($ressymb,&mt('Display all versions'),'allversions',$idx,$$newpostsflag,$prevread,&group_args($group)); } $$discussionitems[$idx].='
'.&mt('Earlier version(s) were posted on: '); if ($contrib{$idx.':history'} =~ m/:/) { @@ -1773,14 +1824,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=''; @@ -2055,8 +2103,8 @@ END } else { $r->print(< -$lt{'atta'} $attachmaxtext: - +$lt{'atta'} $attachmaxtext: +

END } @@ -2832,6 +2880,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(< @@ -2840,7 +2892,7 @@ $typestyle $blog $toolarge $status -
+ $prevtag $sorttag $statustag @@ -3174,7 +3226,7 @@ sub adddiscuss { if (($symb) && ($email)) { my $now = time; if ($env{'form.editdisc'}) { - $contrib{'ip'}=$ENV{'REMOTE_ADDR'}; + $contrib{'ip'}=&Apache::lonnet::get_requestor_ip(); $contrib{'host'}=$Apache::lonnet::perlvar{'lonHostID'}; $contrib{'timestamp'} = $now; $contrib{'history'} = ''; @@ -3551,8 +3603,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)){ @@ -4039,11 +4091,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 @@ -4544,6 +4600,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;