--- loncom/interface/lonmsgdisplay.pm 2007/12/08 00:25:14 1.83 +++ loncom/interface/lonmsgdisplay.pm 2008/06/06 17:46:15 1.87 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging display # -# $Id: lonmsgdisplay.pm,v 1.83 2007/12/08 00:25:14 raeburn Exp $ +# $Id: lonmsgdisplay.pm,v 1.87 2008/06/06 17:46:15 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -513,22 +513,34 @@ sub discourse { $result .= ''."\n"; - $result .= &Apache::lonselstudent::render_student_list($current_members, - "compemail", - "current", - \%defaultUsers, - 1,"selectedusers",1); - - $result .= &Apache::lonselstudent::render_student_list($expired_members, - "compemail", - "expired", - \%defaultUsers, - 1, "selectedusers",0); - $result .= &Apache::lonselstudent::render_student_list($future_members, - "compemail", - "future", - \%defaultUsers, - 1, "selectedusers", 0); + my $tmptext; + if ($tmptext = &Apache::lonselstudent::render_student_list($current_members, + "compemail", + "current", + \%defaultUsers, + 1,"selectedusers",1) + ) { + $result .= '

'.&mt('Course members with current access').'

'; + $result .= $tmptext; + } + if ($tmptext = &Apache::lonselstudent::render_student_list($expired_members, + "compemail", + "expired", + \%defaultUsers, + 1, "selectedusers",0) + ) { + $result .= '

'.&mt('Course members with expired access').'

'; + $result .= $tmptext; + } + if ($tmptext = &Apache::lonselstudent::render_student_list($future_members, + "compemail", + "future", + \%defaultUsers, + 1, "selectedusers", 0) + ) { + $result .= '

'.&mt('Course members with future access').'

'; + $result .= $tmptext; + } return $result; } @@ -555,7 +567,7 @@ sub disgroup { 'recipients to select.'); return $result; } else { - $result = &mt('Select message recipients from the group members listed below.
'); + $result = &mt('Select message recipients from the group members listed below.').'
'; my %Sortby = ( active => {}, previous => {}, @@ -737,7 +749,7 @@ $content{'sendername'}.':'. '
'.&mt('Subject').': '.$content{'subject'}. '
'.
               &Apache::lontexconvert::msgtexconverted($content{'message'}).
-            '
'; + '
'; my ($rec_button,$reprec_button); $rec_button = &mt('Move to Inbox'); if (!$content{'noreplies'}) { @@ -752,7 +764,7 @@ $content{'sendername'}.':'. } else { $result .= &mt('Access to other pages will be prevented until you have moved the message to your inbox.'); } - $result .= '
'. + $result .= '

'. ''; if (!$content{'noreplies'}) { $result .= ' 1) { - $r->print(&mt('Each of the [quant,_1,message] you checked -will be forwarded to the recipient(s) you select below.',$multiforward).'
'); + $r->print(&mt('Each of the [quant,_1,message] you checked' + .' will be forwarded to the recipient(s) you select below.',$multiforward) + .'
'); } else { $r->print(&mt('The message you checked will be forwarded to the recipient(s) you select below.').'
'); } @@ -1209,6 +1222,7 @@ will be forwarded to the recipient(s) yo my $dissub=''; my $dismsg=''; my $disbase=''; + my $attachrow; my $func=&mt('Send New'); my %lt=&Apache::lonlocal::texthash('us' => 'Username', 'do' => 'Domain', @@ -1223,7 +1237,15 @@ will be forwarded to the recipient(s) yo 'gmt' => 'General message text', 'tff' => 'The file format for the uploaded portion of the message is', 'uas' => 'Upload and Send', + 'atta' => 'Attachment', ); + my %attachmax = ( + text => '(128 KB max size)', + num => 131072, + ); + if (!$forwarding && !$multiforward) { + $attachrow = '
'.$lt{'atta'}.' '.$attachmax{'text'}.': '; + } if (&Apache::lonnet::allowed('srm',$env{'request.course.id'}) || &Apache::lonnet::allowed('srm',$env{'request.course.id'}. '/'.$env{'request.course.sec'})) { @@ -1417,7 +1439,10 @@ $latexHelp. $latexHelp


+ +$attachrow +

+
$dispcrit $disbase ENDCOMP @@ -1504,9 +1529,10 @@ ENDREP sub additional_rec_row { my ($lt) = @_; my $cc = &mt('Cc:'); - my $bcc = &mt('Bcc:'); + my $bcc = &mt('Bcc:'); + my $exmpl = &mt('username:domain,username:domain,...'); my $output = <<"ENDADD"; -$lt->{'ad'} :
username:domain,username:domain, ... +$lt->{'ad'} :
($exmpl)  $cc
$bcc @@ -2390,6 +2416,8 @@ sub sendoffmail { my %msg_status; my $numsent = 0; my $nosentstore = 1; + my $attachmenturl; + my $now = time; my ($cdom,$cnum,$group); if (exists($env{'form.group'})) { $group = $env{'form.group'}; @@ -2412,10 +2440,13 @@ sub sendoffmail { if ($env{'form.forwid'}) { my $msgid=$env{'form.forwid'}; my %message=&Apache::lonnet::get('nohist_email'.$suffix,[$msgid]); - %content=&Apache::lonmsg::unpackagemsg($message{$msgid},1); + %content=&Apache::lonmsg::unpackagemsg($message{$msgid},1,1); &statuschange($msgid,'forwarded',$folder); - $env{'form.message'}.="\n\n-- Forwarded message --\n\n". - $content{'message'}; + if ($content{'attachmenturl'} ne '') { + $attachmenturl = $content{'attachmenturl'}; + } + $env{'form.message'} .= "\n\n-- Forwarded message --\n\n". + $content{'message'}; } if ($env{'form.replyid'}) { my $msgid=$env{'form.replyid'}; @@ -2514,7 +2545,18 @@ sub sendoffmail { $env{'user.domain'},\%reciphash); if ($recipstatus ne 'ok') { &Apache::lonnet::logthis('Failed to store Bcc and Cc recipients for '.$env{'user.name'}.':'.$env{'user.domain'}); - } + } + if ($env{'form.attachment'}) { + if (length($env{'form.attachment'})<131072) { + $attachmenturl=&Apache::lonnet::userfileupload('attachment',undef,'feedback/'.$now); + } else { + $r->print('

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

'); + } + } elsif ($env{'form.multiforward'}) { + if ($env{'form.attachmenturl'} ne '') { + $attachmenturl = $env{'form.attachmenturl'}; + } + } my @recusers; my @recudoms; foreach my $address (sort(keys(%toaddr))) { @@ -2540,7 +2582,7 @@ sub sendoffmail { &Apache::lonmsg::user_normal_msg($recuname,$recdomain, $msgsubj,$msgtxt, $content{'citation'}, - undef,undef, + undef,$attachmenturl, $env{'form.permanent'}, \$sentmessage{$address}, undef,undef,undef, @@ -2573,7 +2615,7 @@ sub sendoffmail { $specialresult = &Apache::lonmsg::user_normal_msg_raw($cnum,$cdom, $subj_prefix.' '.$course_str,$savemsg,undef,undef, - undef,undef,undef,\$specialmsgid,undef,undef,undef, + $attachmenturl,undef,undef,\$specialmsgid,undef,undef,undef, undef,undef,1); $specialmsgid = &unescape($specialmsgid); if ($specialresult eq 'ok') { @@ -2590,7 +2632,7 @@ sub sendoffmail { $pid); &Apache::lonmsg::user_normal_msg_raw($cnum,$cdom, $subj_prefix.' ['.$recipient.']',$msgsubj, - undef,undef,undef,undef,$usermsgid,undef, + undef,undef,$attachmenturl,undef,$usermsgid,undef, undef,$specialmsgid,undef,undef,undef,1); } } @@ -2598,7 +2640,7 @@ sub sendoffmail { &Apache::lonmsg::process_sent_mail($msgsubj, $subj_prefix,$numsent,$stamp,$msgname,$msgdom, $msgcount,$context,$pid,$savemsg,\@recusers, - \@recudoms); + \@recudoms,undef,$attachmenturl); } } else { &Apache::lonnet::logthis('Failed to create record of critical, broadcast or archived message in '.$env{'course.'.$env{'request.course.id'}.'.num'}.' '&mt('at').' '.$env{'course.'.$env{'request.course.id'}.'.domain'}.' - no msgid generated'); @@ -2610,7 +2652,7 @@ sub sendoffmail { &Apache::lonmsg::process_sent_mail($msgsubj,$subj_prefix, $numsent,$stamp,$env{'user.name'}, $env{'user.domain'},$msgcount,$context, - $$,$savemsg,\@recusers,\@recudoms); + $$,$savemsg,\@recusers,\@recudoms,undef,$attachmenturl); } } if (!$env{'form.multiforward'}) { @@ -2627,7 +2669,7 @@ sub sendoffmail { } } else { $r->print('

'.&mt('Could not deliver message').' '. - &mt('Please use the browser "Back" button and correct the recipient addresses '."($sendstatus)").'

'); + &mt('Please use the browser "Back" button and correct the recipient addresses ([_1]).',$sendstatus).'

'); } } } @@ -2862,7 +2904,7 @@ sub handler { foreach my $item (@to_forward) { my $msgid=&unescape($item); my %message=&Apache::lonnet::get('nohist_email'.$suffix,[$msgid]); - my %content=&Apache::lonmsg::unpackagemsg($message{$msgid},1); + my %content=&Apache::lonmsg::unpackagemsg($message{$msgid},1,1); if ($env{'form.showorigsubj'}) { $env{'form.subject'} = $fixed_subj.$content{'subject'}; } else { @@ -2876,8 +2918,10 @@ sub handler { &Apache::loncommon::plainname($uname,$udom).' ('. $uname.':'.$udom.')'; } - $env{'form.message'} .= "\n\n-- Forwarded message --\n\n". - $content{'message'}; + $env{'form.message'}.="\n\n-- Forwarded message --\n\n". + $content{'message'}; + $env{'form.attachmenturl'} = $content{'attachmenturl'}; + $env{'form.multiforwid'} = $item; $fwdcount ++; $r->print($fwdcount.': '); $sendresult{$msgid} = &sendoffmail($r,$folder);