--- loncom/interface/lonfeedback.pm 2021/12/31 20:39:00 1.370.2.5.2.1
+++ loncom/interface/lonfeedback.pm 2017/11/03 21:36:27 1.374
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.370.2.5.2.1 2021/12/31 20:39:00 raeburn Exp $
+# $Id: lonfeedback.pm,v 1.374 2017/11/03 21:36:27 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -44,7 +44,7 @@ use HTML::LCParser();
#use HTML::Tidy::libXML;
use Apache::lonspeller();
use Apache::longroup;
-use Archive::Zip qw( :ERROR_CODES );
+use Cwd;
use LONCAPA qw(:DEFAULT :match);
sub discussion_open {
@@ -118,16 +118,10 @@ sub list_discussion {
$outputtarget = 'export';
}
}
- my ($nofooter,$nodisclink,$nofdbklink);
if (not &discussion_visible($status)) {
if ($mode ne 'board') {
- ($nofooter,$nodisclink,$nofdbklink) = &check_menucoll();
- if ($nofooter || $nofdbklink) {
- return '
';
- } else {
- &Apache::lonenc::check_encrypt(\$ressymb);
- return '
'.&send_message_link($ressymb)."
";
- }
+ &Apache::lonenc::check_encrypt(\$ressymb);
+ return '
'.&send_message_link($ressymb)."
";
}
}
if ($group ne '' && $mode eq 'board') {
@@ -136,27 +130,17 @@ sub list_discussion {
}
}
- unless ($outputtarget eq 'export') {
- ($nofooter,$nodisclink,$nofdbklink) = &check_menucoll();
- }
-
- unless ($nofooter) {
- my ($blocked,$blocktext) =
- &Apache::loncommon::blocking_status('boards');
- if ($blocked) {
- my $footer = '
';
- unless ($nodisclink) {
- $footer .= ''.$blocktext.'';
- }
- &Apache::lonenc::check_encrypt(\$ressymb);
- if ($mode ne 'board') {
- unless ($nofdbklink) {
- $footer.=&send_message_link($ressymb);
- }
- }
- $footer.='
';
- return $footer;
+ my ($blocked,$blocktext) =
+ &Apache::loncommon::blocking_status('boards');
+ if ($blocked) {
+ $blocktext = '
'.$blocktext."";
+ &Apache::lonenc::check_encrypt(\$ressymb);
+ if ($mode ne 'board') {
+ $blocktext.=&send_message_link($ressymb).'
';
+ }else{
+ $blocktext.="";
}
+ return $blocktext;
}
my @bgcols = ("LC_disc_old_item","LC_disc_new_item");
@@ -690,7 +674,7 @@ END
$newpostsflag,$group,
$prevread,$markondisp,$seehidden);
$discussion .= "\n";
- }
+ }
if ($outputtarget eq 'export') {
if ($manifestok) {
while ($currdepth > 0) {
@@ -714,19 +698,18 @@ END
if (($env{'user.name'} =~ /^$match_username$/)
&& ($env{'user.domain'} =~ /^$match_domain$/)) {
- my $now = time();
+ 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 $cwd = &getcwd();
my $imszip = '/home/httpd/'.$imszipfile;
- if ($zip->writeToFileNamed($imszip) == AZ_OK) {
- $discussion .= &mt('Download the zip file from [_1]Discussion Posting Archive[_2]',
+ 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:').
@@ -790,60 +773,33 @@ END
&mt('This discussion is closed.').'';
}
} elsif ($outputtarget ne 'tex') {
- unless ($nofooter) {
- $discussion.='';
- unless ($nodisclink) {
- if (&discussion_open($status) &&
- &Apache::lonnet::allowed('pch',
- $env{'request.course.id'}.
- ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
- $discussion.= &send_feedback_link($ressymb);
- if ($env{'request.role.adv'}) {
- my $close = &Apache::lonnet::EXT('resource.0.discussend',$ressymb);
- my $canvote = &Apache::lonnet::EXT('resource.0.discussvote',$ressymb);
- if (defined($close) && $close ne '' && $close < time) {
- if ($canvote eq 'notended') {
- $discussion .= ' '.&mt('(Posting and voting closed for [_1] roles)',
- &Apache::lonnet::plaintext('st',$crstype));
- } else {
- $discussion .= ' '.&mt('(Closed for [_1] roles)',
- &Apache::lonnet::plaintext('st',$crstype));
- }
- }
+ $discussion.='
';
+ if (&discussion_open($status) &&
+ &Apache::lonnet::allowed('pch',
+ $env{'request.course.id'}.
+ ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
+ $discussion.= &send_feedback_link($ressymb);
+ if ($env{'request.role.adv'}) {
+ my $close = &Apache::lonnet::EXT('resource.0.discussend',$ressymb);
+ my $canvote = &Apache::lonnet::EXT('resource.0.discussvote',$ressymb);
+ if (defined($close) && $close ne '' && $close < time) {
+ if ($canvote eq 'notended') {
+ $discussion .= ' '.&mt('(Posting and voting closed for [_1] roles)',
+ &Apache::lonnet::plaintext('st',$crstype));
+ } else {
+ $discussion .= ' '.&mt('(Closed for [_1] roles)',
+ &Apache::lonnet::plaintext('st',$crstype));
}
- } else {
- $discussion.= ''.&mt('This discussion is closed.').'';
}
}
- unless ($nofdbklink) {
- $discussion.= &send_message_link($ressymb);
- }
- $discussion.='
';
+ } else {
+ $discussion.= '
'.&mt('This discussion is closed.').'';
}
+ $discussion.= &send_message_link($ressymb).'
';
}
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;
@@ -898,7 +854,7 @@ sub send_feedback_link {
&discussion_link($ressymb,
'
',
+ '" border="0" />',
'replydisc').
'';
}
@@ -909,7 +865,7 @@ sub send_message_link {
&discussion_link($ressymb,
'
',
+ '" border="0" />',
'sendmessageonly').
'';
return $output;
@@ -1003,9 +959,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
@@ -1819,11 +1780,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='';
@@ -2098,8 +2062,8 @@ END
} else {
$r->print(<
-$lt{'atta'} $attachmaxtext:
-
+$lt{'atta'} $attachmaxtext:
+
END
}
@@ -2110,7 +2074,7 @@ END
$r->print('');
}
$r->print(<
+
END
@@ -2985,12 +2949,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);
@@ -3213,7 +3181,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'} = '';
@@ -3547,7 +3515,7 @@ sub modify_attachments {
document.modattachments.action = document.modattachments.origpage.value;
document.modattachments.submit();
}
-
+
END
@@ -3590,8 +3558,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)){
@@ -4583,8 +4551,6 @@ 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;
@@ -4686,7 +4652,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++;