--- loncom/interface/lonfeedback.pm 2013/01/18 13:22:26 1.364
+++ loncom/interface/lonfeedback.pm 2019/08/11 15:15:39 1.382
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.364 2013/01/18 13:22:26 bisitz Exp $
+# $Id: lonfeedback.pm,v 1.382 2019/08/11 15:15:39 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)=@_;
@@ -336,12 +336,15 @@ sub list_discussion {
'aner' => 'An error occurred opening the manifest file.',
'difo' => 'Discussion for',
'aerr' => 'An error occurred opening the export file for posting',
+ 'discussions' => 'DISCUSSIONS'
+ );
+ my %js_lt = &Apache::lonlocal::texthash(
'aysu' => 'Are you sure you want to delete this post?',
'dpwn' => 'Deleted posts will no longer be visible to you and other students',
'bwco' => 'but will continue to be visible to your instructor',
'depo' => 'Deleted posts will no longer be visible to you or anyone else.',
- 'discussions' => 'DISCUSSIONS'
);
+ &js_escape(\%js_lt);
my $currdisp = $lt{'allposts'};
my $currmark = $lt{'onmark'};
@@ -447,12 +450,12 @@ imscp_v1p1.xsd http://www.imsglobal.org/
prevparm = "&previous="+previous
}
if (caller == 'studentdelete') {
- if (confirm("$lt{'aysu'}\\n$lt{'dpwn'},\\n$lt{'bwco'}")) {
+ if (confirm("$js_lt{'aysu'}\\n$js_lt{'dpwn'},\\n$js_lt{'bwco'}")) {
document.location.href = "/adm/feedback?hide="+symbparm+prevparm+groupparm
}
} else {
if (caller == 'seeiddelete') {
- if (confirm("$lt{'aysu'}\\n$lt{'depo'}")) {
+ if (confirm("$js_lt{'aysu'}\\n$js_lt{'depo'}")) {
document.location.href = "/adm/feedback?deldisc="+symbparm+prevparm+groupparm
}
}
@@ -468,18 +471,18 @@ imscp_v1p1.xsd http://www.imsglobal.org/
my $numhidden = keys(%notshown);
if ($numhidden > 0) {
my $colspan = $maxdepth+1;
- $discussion.="\n".'
'.
- ' ';
+ my $href = '/adm/feedback?allposts=1&symb='.$escsymb;
if ($newpostsflag) {
- $discussion .= '&previous='.$prevread;
+ $href .= '&previous='.$prevread;
}
- $discussion .= &group_args($group);
- $discussion .= '">'.&mt('Show all posts').' '.&mt('to display').' '.
- $numhidden.' ';
+ $href .= &group_args($group);
if ($showunmark) {
- $discussion .= &mt('posts previously marked read');
+ $discussion .= &mt('[_1]Show all posts[_2] to display [quant,_3,post] previously marked read',
+ '',' ',$numhidden);
} else {
- $discussion .= &mt('previously viewed posts');
+ $discussion .= &mt('[_1]Show all posts[_2] to display [quant,_3,post] previously viewed',
+ '',' ',$numhidden);
}
$discussion .= ' ';
}
@@ -562,7 +565,7 @@ imscp_v1p1.xsd http://www.imsglobal.org/
my $postingfile;
my $postingfilename = $tempexport.'/'.$postfilename;
if ($postingfile = Apache::File->new('>'.$postingfilename)) {
- print $postingfile 'Discussion Post '.
+ print $postingfile ''.&mt('Discussion Post').' '.
$imsitems{$alldiscussion{$post}}{'title'}.' '.
$imsitems{$alldiscussion{$post}}{'sender'}.
$imsitems{$alldiscussion{$post}}{'timestamp'}.' '.
@@ -671,7 +674,7 @@ END
$newpostsflag,$group,
$prevread,$markondisp,$seehidden);
$discussion .= "\n";
- }
+ }
if ($outputtarget eq 'export') {
if ($manifestok) {
while ($currdepth > 0) {
@@ -693,22 +696,34 @@ 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','').' ';
- if ($copyresult) {
- $discussion .= &mt('The following errors occurred during export').' - '.$copyresult;
+ 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]',
+ '',' ').' ';
+ } 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 {
- $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 a manifest file.').' ';
+ $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 a manifest file.').'
';
}
return $discussion;
}
@@ -840,7 +855,7 @@ sub send_feedback_link {
&discussion_link($ressymb,
' ',
+ '" />',
'replydisc').
'';
}
@@ -851,7 +866,7 @@ sub send_message_link {
&discussion_link($ressymb,
' ',
+ '" />',
'sendmessageonly').
'';
return $output;
@@ -926,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',
@@ -945,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
@@ -1278,7 +1298,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.=" '.
' '.
@@ -1505,12 +1526,12 @@ sub build_posting_display {
if ($userlikes{$idx}) {
$$discussionitems[$idx].=' ';
} else {
- $$discussionitems[$idx].=' '.&discussion_link($symb,' ','like',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Like this posting"));
+ $$discussionitems[$idx].=' '.&discussion_link($ressymb,' ','like',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Like this posting"));
}
if ($userunlikes{$idx}) {
$$discussionitems[$idx].=' ';
} else {
- $$discussionitems[$idx].=' '.&discussion_link($symb,' ','unlike',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Unlike this posting"));
+ $$discussionitems[$idx].=' '.&discussion_link($ressymb,' ','unlike',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Unlike this posting"));
}
}
}
@@ -1528,7 +1549,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/:/) {
@@ -1760,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='';
@@ -1896,6 +1914,7 @@ END
my $latexHelp=&Apache::loncommon::helpLatexCheatsheet(undef,undef,1,($env{'form.modal'}?'popup':0));
my $send=&mt('Send');
my $alert = &mt('Please select a feedback type.');
+ &js_escape(\$alert);
my $js= <
//
+
END
my ($textareaheader,$textareaclass);
@@ -2040,7 +2060,8 @@ END
} else {
$r->print(<
-$lt{'atta'} $attachmaxtext:
+$lt{'atta'} $attachmaxtext:
+
END
}
@@ -2051,7 +2072,7 @@ END
$r->print(' ');
}
$r->print(<
+
END
@@ -2129,6 +2150,11 @@ sub print_display_options {
'yhni' => 'You have not indicated that you wish to change any of the discussion settings',
'ywbr' => 'You will be returned to the previous page if you click OK.'
);
+ my %js_lt = &Apache::lonlocal::texthash(
+ 'yhni' => 'You have not indicated that you wish to change any of the discussion settings',
+ 'ywbr' => 'You will be returned to the previous page if you click OK.'
+ );
+ &js_escape(\%js_lt);
my $dispchangeA = $lt{'unread'};
my $dispchangeB = $lt{'unmark'};
@@ -2222,7 +2248,7 @@ function setDisp() {
if (chktotal > 0) {
document.modifydisp.submit()
} else {
- if(confirm("$lt{'yhni'}. \\n$lt{'ywbr'}")) {
+ if(confirm("$js_lt{'yhni'}. \\n$js_lt{'ywbr'}")) {
if (prev > 0) {
location.href = "$feedurl?previous=$previous"
} else {
@@ -2582,7 +2608,7 @@ sub print_showposters {
my $table_start =&Apache::loncommon::start_data_table();
$r->print(<
+