--- loncom/interface/lonfeedback.pm 2004/07/23 16:56:29 1.103 +++ 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.103 2004/07/23 16:56:29 albertel Exp $ +# $Id: lonfeedback.pm,v 1.108 2004/07/28 18:50:26 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,6 +36,7 @@ use Apache::loncommon(); use Apache::lontexconvert(); use Apache::lonlocal; # must not have () use Apache::lonhtmlcommon(); +use Apache::lonspeller(); sub discussion_open { my ($status)=@_; @@ -124,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) { @@ -257,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) { @@ -431,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; @@ -740,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.=(< -
-Note: in anonymous discussion, your name is visible only to -course faculty
-Title: 

- -

-Attachment (128 KB max size): -

- + +
+Note: in anonymous discussion, your name is visible only +to course faculty
+Title: 

+ ENDDISCUSS + if ($ENV{'form.origpage'}) { + $discussion.=''."\n"; + foreach (@currnewattach) { + $discussion.=''."\n"; + } + } + $discussion.="\n"; if ($outputtarget ne 'tex') { + $discussion.=&generate_attachments_button('',$attachnum,$ressymb,$now,\@currnewattach,\@currdelold,'',$mode); + if (@currnewattach > 0) { + $newattachmsg .= 'New attachments
'; + if (@currnewattach > 1) { + $newattachmsg .= '
    '; + foreach my $item (@currnewattach) { + $item =~ m#.*/([^/]+)$#; + $newattachmsg .= '
  1. '.$1.'
  2. '."\n"; + } + $newattachmsg .= '
'."\n"; + } else { + $currnewattach[0] =~ m#.*/([^/]+)$#; + $newattachmsg .= ''.$1.'
'."\n"; + } + } + $discussion.=$newattachmsg; $discussion.=&generate_preview_button(); } } else { @@ -777,22 +830,62 @@ ENDDISCUSS sub mail_screen { my ($r,$feedurl,$options) = @_; + if (exists($ENV{'form.origpage'})) { + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','currnewattach','addnewattach','deloldattach','delnewattach','timestamp','idx','anondiscuss','discuss']); + } my $bodytag=&Apache::loncommon::bodytag('Resource Feedback and Discussion', '','onLoad="window.focus();setposttype();"'); my $title=&Apache::lonnet::gettitle($feedurl); if (!$title) { $title = $feedurl; } my $quote=''; my $subject = ''; - my $oldmessage = ''; + my $comment = ''; my $prevtag = ''; my $parentmsg = ''; - my $anonscript = (< 0) { + if ($contrib{$idx.':message'} =~ /::::\Q$numoldver\E::::(.+?)$/si) { + $message = $1; + } else { + $message = $contrib{$idx.':message'}; + } + } else { + $message=$contrib{$idx.':message'}; + } $message=~s/\n/\
/g; - $quote='
'.&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 = (<'; } } + + if ($ENV{'form.origpage'}) { + $subject = $ENV{'form.subject'}; + $comment = $ENV{'form.comment'}; + &process_attachments(\@currnewattach,\@currdelold,\@keepold); + } my $latexHelp=&Apache::loncommon::helpLatexCheatsheet(); my $htmlheader=&Apache::lonhtmlcommon::htmlareaheaders(); - my $onsubmit=''; - if ((&Apache::lonhtmlcommon::htmlareabrowser()) && - (!&Apache::lonhtmlcommon::htmlareablocked())) { - $onsubmit='document.mailform.onsubmit();'; - } my $send=&mt('Send'); $r->print(< @@ -912,12 +1020,15 @@ $htmlheader } if (rec) { - $onsubmit + if (typeof(document.mailform.onsubmit)!='undefined') { + document.mailform.onsubmit(); + } document.mailform.submit(); } else { alert('Please check a feedback type.'); } } + $anonchk $anonscript //--> @@ -939,7 +1050,7 @@ END END } - $r->print(<print(< $quote @@ -948,20 +1059,78 @@ $quote $latexHelp Title:

-

+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(<

+END + } + $r->print(<

-ENDDOCUMENT -$r->print(&generate_preview_button(). -&Apache::lonhtmlcommon::htmlareaselectactive('comment'). -''); +END + if ($ENV{'form.editdisc'} || $ENV{'form.replydisc'}) { + my $now = time; + my $ressymb = $symb; + my $postidx = ''; + if ($ENV{'form.editdisc'}) { + $postidx = $idx; + } + if (@currnewattach > 0) { + $attachnum += @currnewattach; + } + $r->print(&generate_attachments_button($postidx,$attachnum,$ressymb,$now,\@currnewattach,\@currdelold,$numoldver)); + if ($attachnum > 0) { + if (@currnewattach > 0) { + $newattachmsg .= 'New attachments
'; + if (@currnewattach > 1) { + $newattachmsg .= '
    '; + foreach my $item (@currnewattach) { + $item =~ m#.*/([^/]+)$#; + $newattachmsg .= '
  1. '.$1.'
  2. '."\n"; + } + $newattachmsg .= '
'."\n"; + } else { + $currnewattach[0] =~ m#.*/([^/]+)$#; + $newattachmsg .= ''.$1.'
'."\n"; + } + } + if ($attachmsg) { + $r->print("Retained attachments:$attachmsg
\n"); + } + if ($newattachmsg) { + $r->print("$newattachmsg
"); + } + } + } + $r->print(&generate_preview_button(). + &Apache::lonhtmlcommon::htmlareaselectactive('comment'). + ''); } sub print_display_options { @@ -1430,6 +1599,7 @@ ENDREDIR sub no_redirect_back { my ($r,$feedurl) = @_; + my $nofeed=&mt('Sorry, no feedback possible on this resource ...'); $r->print (< Feedback not sent @@ -1444,7 +1614,7 @@ ENDNOREDIR -Sorry, no feedback possible on this resource ... +$nofeed ENDNOREDIRTWO @@ -1511,25 +1681,25 @@ sub resource_output { sub clear_out_html { my ($message,$override)=@_; unless (&Apache::lonhtmlcommon::htmlareablocked()) { return $message; } +# Always allow the -tag + my %html=(M=>1); +# Check if more is allowed my $cid=$ENV{'request.course.id'}; if (($ENV{"course.$cid.allow_limited_html_in_feedback"} =~ m/yes/i) || ($override)) { # allows