--- loncom/interface/lonfeedback.pm 2004/07/27 23:35:34 1.107
+++ loncom/interface/lonfeedback.pm 2004/07/28 18:50:26 1.108
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.107 2004/07/27 23:35:34 www Exp $
+# $Id: lonfeedback.pm,v 1.108 2004/07/28 18:50:26 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -125,7 +125,7 @@ sub list_discussion {
}
}
-# Get information about students and non-stundents in course for filtering display of posts
+# Get information about students and non-students in course for filtering display of posts
my %roleshash = ();
my %roleinfo = ();
if ($rolefilter) {
@@ -258,22 +258,36 @@ sub list_discussion {
$numoldver = 1;
}
}
- my $message=$contrib{$idx.':message'};
+ my ($message,$subject);
+ if ($idx > 0) {
+ if ($contrib{$idx.':message'} =~ /.*::::\Q$numoldver\E::::(.+?)$/si) {
+ $message = $1;
+ } else {
+ $message = $contrib{$idx.':message'};
+ }
+ } else {
+ $message=$contrib{$idx.':message'};
+ }
+ my $attachmenturls = $contrib{$idx.':attachmenturl'};
$message=~s/\n/\
/g;
- $message=&Apache::lontexconvert::msgtexconverted($message,undef,$numoldver);
- my $subject=$contrib{$idx.':subject'};
+ $message=&Apache::lontexconvert::msgtexconverted($message);
+ if ($idx > 0) {
+ if ($contrib{$idx.':subject'} =~ /.*::::\Q$numoldver\E::::(.+?)$/si) {
+ $subject = $1;
+ } else {
+ $subject = $contrib{$idx.':subject'};
+ }
+ } else {
+ $subject=$contrib{$idx.':subject'};
+ }
if (defined($subject)) {
$subject=~s/\n/\
/g;
- $subject=&Apache::lontexconvert::msgtexconverted($subject,undef,$numoldver);
+ $subject=&Apache::lontexconvert::msgtexconverted($subject);
}
- if ($contrib{$idx.':attachmenturl'}) {
- my ($fname)
- =($contrib{$idx.':attachmenturl'}=~m|/([^/]+)$|);
- &Apache::lonnet::allowuploaded('/adm/feedback',
- $contrib{$idx.':attachmenturl'});
- $message.='
'.&mt('Attachment'). - ': '. - $fname.'
'; + if ($attachmenturls) { + my @attachments = (); + my %currattach = (); + &extract_attachments($attachmenturls,$idx,$numoldver,\$message,\@attachments,\%currattach); } if ($message) { if ($hidden) { @@ -432,6 +446,7 @@ sub list_discussion { if ($showonlyunread && $prevread > $posttime) { $notshown{$idx} = 1; } else { +# apply filters my $uname = $contrib{$idx.':sendername'}; my $udom = $contrib{$idx.':senderdomain'}; my $poster = $uname.':'.$udom; @@ -741,23 +756,60 @@ END } } if ($discussiononly) { + my $now = time; + my $attachnum = 0; + my $newattachmsg = ''; + my @currnewattach = (); + my @currdelold = (); + my $comment = ''; + my $subject = ''; + if ($ENV{'form.origpage'}) { + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['addnewattach','deloldattach','delnewattach','timestamp','idx','subject','comment']); + $subject = &HTML::Entities::encode($ENV{'form.subject'},'<>&"'); + $comment = &HTML::Entities::encode($ENV{'form.comment'},'<>&"'); + my @keepold = (); + &process_attachments(\@currnewattach,\@currdelold,\@keepold); + if (@currnewattach > 0) { + $attachnum += @currnewattach; + } + } $discussion.=(<-Attachment (128 KB max size): -
- + +'.&Apache::lontexconvert::msgtexconverted($message,undef,$numoldver).''; + $quote='
'.&Apache::lontexconvert::msgtexconverted($message).''; if ($idx > 0) { - if ($contrib{'subject'} =~ /::::\d+::::(.+)$/si) { + if ($contrib{$idx.':subject'} =~ /::::\Q$numoldver\E::::(.+?)$/si) { $subject = $1; } else { $subject = $contrib{$idx.':subject'}; } $subject = 'Re: '.$subject; } + $subject = &HTML::Entities::encode($subject,'<>&"'); } else { - if ($contrib{$idx.':message'} =~ /::::\d+::::(.+)$/si) { - $oldmessage = $1; + $attachmenturls = $contrib{$idx.':attachmenturl'}; + if ($contrib{$idx.':message'} =~ /.*::::(\d+)::::(.*?)$/si) { + $numoldver = $1; + $comment = $2; } else { - $oldmessage = $contrib{$idx.':message'}; + $comment = $contrib{$idx.':message'}; } - $oldmessage=&HTML::Entities::encode($oldmessage,'<>&"'); - if ($contrib{$idx.':subject'} =~ /::::\d+::::(.+)$/si) { + $comment = &HTML::Entities::encode($comment,'<>&"'); + if ($contrib{$idx.':subject'} =~ /.*::::\d+::::(.+?)$/si) { $subject = $1; } else { $subject = $contrib{$idx.':subject'}; } + $subject = &HTML::Entities::encode($subject,'<>&"'); if (defined($contrib{$idx.':replyto'})) { $parentmsg = $contrib{$idx.':replyto'}; } - my $anonflag = 0; - if ($contrib{$idx.':anonymous'}) { - $anonflag = 1; - } - $anonscript = (<
-
+END
+ if ( ($ENV{'form.editdisc'}) || ($ENV{'form.replydisc'}) ) {
+ if ($ENV{'form.origpage'}) {
+ foreach (@currnewattach) {
+ $r->print(''."\n");
+ }
+ foreach (@currdelold) {
+ $r->print(''."\n");
+ }
+ }
+ if ($ENV{'form.editdisc'}) {
+ if ($attachmenturls) {
+ &extract_attachments($attachmenturls,$idx,$numoldver,\$attachmsg,\@attachments,\%currattach,\@currdelold);
+ $attachnum = scalar(keys %currattach);
+ foreach (keys %currattach) {
+ $r->print(''."\n");
+ }
+ }
+ }
+ } else {
+ $r->print(<