--- loncom/interface/lonfeedback.pm 2008/06/05 00:15:24 1.254 +++ loncom/interface/lonfeedback.pm 2008/06/06 05:24:28 1.255 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.254 2008/06/05 00:15:24 bisitz Exp $ +# $Id: lonfeedback.pm,v 1.255 2008/06/06 05:24:28 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1472,7 +1472,7 @@ sub replicate_attachments { } sub mail_screen { - my ($r,$feedurl,$options,$caller_symb) = @_; + my ($r,$feedurl,$options,$caller_symb,$attachmaxtext) = @_; if (exists($env{'form.origpage'})) { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','currnewattach','addnewattach','deloldattach','delnewattach','timestamp','idx','anondiscuss','discuss','blog','group','ref']); } @@ -1482,7 +1482,7 @@ sub mail_screen { 'myqu' => 'My question/comment/feedback:', 'title' => 'Title', 'reta' => 'Retained attachments', - 'atta' => 'Attachment (128 KB max size)', + 'atta' => 'Attachment', ); my $restitle = &get_resource_title($caller_symb,$feedurl); my $quote=''; @@ -1721,7 +1721,7 @@ END } } else { $r->print(< +$lt{'atta'} $attachmaxtext:

END } @@ -2391,7 +2391,7 @@ ENDFAILREDIR } sub redirect_back { - my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$blog,$status,$previous,$sort,$rolefilter,$statusfilter,$sectionpick,$grouppick,$numpicks,$group) = @_; + my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$blog,$status,$previous,$sort,$rolefilter,$statusfilter,$sectionpick,$grouppick,$numpicks,$group,$toolarge) = @_; my $sorttag = ''; my $roletag = ''; my $statustag = ''; @@ -2505,6 +2505,7 @@ $start_page $typestyle Sent $sendsomething message(s), and $sendposts post(s). $blog +$toolarge $status
$prevtag @@ -2932,7 +2933,8 @@ ENDPREVIEW } sub modify_attachments { - my ($r,$currnewattach,$currdelold,$symb,$idx,$attachmenturls)=@_; + my ($r,$currnewattach,$currdelold,$symb,$idx,$attachmenturls, + $attachmaxtext,$toolarge)=@_; my %lt = &Apache::lonlocal::texthash( 'subj' => 'Subject', @@ -2974,10 +2976,12 @@ END $r->print(< - +
+
- + + + + +
+ Subject: $subject

END if ($idx) { @@ -3003,9 +3007,15 @@ END $r->print("
"); } $r->print(< +
+ $lt{'adda'}
$attachmaxtext
@@ -3288,6 +3298,10 @@ sub handler { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['hide','unhide','deldisc','postdata','preview','replydisc','editdisc','cmd','symb','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navtime','navmaps','navurl','sortposts','applysort','rolefilter','statusfilter','sectionpick','groupick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export','sendmessageonly','group','ref']); my $group = $env{'form.group'}; + my %attachmax = ( + text => '(128 KB max size)', + num => 131072, + ); if ($env{'form.editdisc'}) { if (!(&editing_allowed($env{'form.editdisc'},$env{'form.group'}))) { my $symb=(split(/\:\:\:/,$env{'form.editdisc'}))[0]; @@ -3596,13 +3610,15 @@ ENDREDIR &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','addnewattach','delnewattach','timestamp','numoldver','idx','discuss','blog']); - my (@currnewattach,@currdelold,@keepold); + my (@currnewattach,@currdelold,@keepold,$toolarge); &process_attachments(\@currnewattach,\@currdelold,\@keepold); if (exists($env{'form.addnewattach.filename'})) { - unless (length($env{'form.addnewattach'})>131072) { + if (length($env{'form.addnewattach'})<=$attachmax{'num'}) { my $subdir = 'feedback/'.$env{'form.timestamp'}; my $newattachment=&Apache::lonnet::userfileupload('addnewattach',undef,$subdir); push(@currnewattach, $newattachment); + } else { + $toolarge = '

'.&mt('Attachment not included - exceeded permitted length').'

'; } } my $attachmenturls; @@ -3615,7 +3631,7 @@ ENDREDIR $attachmenturls = $contrib{$idx.':attachmenturl'}; } &modify_attachments($r,\@currnewattach,\@currdelold,$symb,$idx, - $attachmenturls); + $attachmenturls,$attachmax{'text'},$toolarge); return OK; } elsif ($env{'form.export'}) { &Apache::loncommon::content_type($r,'text/html'); @@ -3704,7 +3720,7 @@ ENDREDIR } my $options=&screen_header($feedurl,$symb); if ($options) { - &mail_screen($r,$feedurl,$options,$symb); + &mail_screen($r,$feedurl,$options,$symb,$attachmax{'text'}); } else { &fail_redirect($r,$feedurl); } @@ -3730,6 +3746,7 @@ ENDREDIR &Apache::lonnet::delenv('allowed.vgr'); # Get attachments, if any, and not too large my $attachmenturl=''; + my $toolarge=''; if (($env{'form.origpage'}) || ($env{'form.editdisc'}) || ($env{'form.replydisc'})) { my ($symb,$idx); @@ -3748,9 +3765,13 @@ ENDREDIR $symb=~s|(bulletin___\d+___)adm/wrapper/|$1|; $attachmenturl=&construct_attachmenturl(\@currnewattach,\@keepold,$symb,$idx); } elsif ($env{'form.attachment.filename'}) { - unless (length($env{'form.attachment'})>131072) { - $attachmenturl=&Apache::lonnet::userfileupload('attachment',undef,'feedback'); - } + if (length($env{'form.attachment'})<=$attachmax{'num'}) { + my $now = time; + my $subdir = 'feedback/'.$now; + $attachmenturl=&Apache::lonnet::userfileupload('attachment',undef,$subdir); + } else { + $toolarge = '

'.&mt('Attachment not included - exceeded permitted length').'

'; + } } # Filter HTML out of message (could be nasty) my $message=&clear_out_html($env{'form.comment'}); @@ -3793,7 +3814,7 @@ ENDREDIR } # Receipt screen and redirect back to where came from - &redirect_back($r,$feedurl,$typestyle,$numsent,$numpost,$blog,$status,$env{'form.previous'},undef,undef,undef,undef,undef,undef,$group); + &redirect_back($r,$feedurl,$typestyle,$numsent,$numpost,$blog,$status,$env{'form.previous'},undef,undef,undef,undef,undef,undef,$group,$toolarge); } return OK; }