--- loncom/interface/lonmsg.pm 2004/01/15 18:25:36 1.80 +++ loncom/interface/lonmsg.pm 2004/04/06 15:56:37 1.97 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging # -# $Id: lonmsg.pm,v 1.80 2004/01/15 18:25:36 www Exp $ +# $Id: lonmsg.pm,v 1.97 2004/04/06 15:56:37 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -101,6 +101,7 @@ use Apache::lontexconvert(); use HTML::Entities(); use Mail::Send; use Apache::lonlocal; +use Apache::loncommunicate; # Querystring component with sorting type my $sqs; @@ -109,15 +110,15 @@ my $sqs; sub packagemsg { my ($subject,$message,$citation,$baseurl,$attachmenturl)=@_; - $message =&HTML::Entities::encode($message); - $citation=&HTML::Entities::encode($citation); - $subject =&HTML::Entities::encode($subject); + $message =&HTML::Entities::encode($message,'<>&"'); + $citation=&HTML::Entities::encode($citation,'<>&"'); + $subject =&HTML::Entities::encode($subject,'<>&"'); #remove machine specification $baseurl =~ s|^http://[^/]+/|/|; - $baseurl =&HTML::Entities::encode($baseurl); + $baseurl =&HTML::Entities::encode($baseurl,'<>&"'); #remove machine specification $attachmenturl =~ s|^http://[^/]+/|/|; - $attachmenturl =&HTML::Entities::encode($attachmenturl); + $attachmenturl =&HTML::Entities::encode($attachmenturl,'<>&"'); my $now=time; $msgcount++; @@ -139,6 +140,7 @@ sub packagemsg { ''.$ENV{'browser.mathml'}.''. ''.$ENV{'HTTP_USER_AGENT'}.''. ''.$ENV{'request.course.id'}.''. + ''.$ENV{'request.course.sec'}.''. ''.$ENV{'request.role'}.''. ''.$ENV{'request.filename'}.''. ''.$msgid.''. @@ -203,7 +205,7 @@ sub sendemail { my $msg = new Mail::Send; $msg->to($to); $msg->subject('[LON-CAPA] '.$subject); - if (my $fh = $msg->open('smtp',Server => 'localhost')) { + if (my $fh = $msg->open()) { print $fh $body; $fh->close; } @@ -396,7 +398,7 @@ sub user_crit_received { my %contents=&unpackagemsg($message{$msgid},1); my $status='rec: '.($contents{'sendback'}? &user_normal_msg($contents{'sendername'},$contents{'senderdomain'}, - &mt('Receipt').': '.$ENV{'user.name'}.' at '.$ENV{'user.domain'}, + &mt('Receipt').': '.$ENV{'user.name'}.' '.&mt('at').' '.$ENV{'user.domain'}.', '.$contents{'subject'}, &mt('User').' '.$ENV{'user.name'}.' '.&mt('at').' '.$ENV{'user.domain'}. ' acknowledged receipt of message'."\n".' "'. $contents{'subject'}.'"'."\n".&mt('dated').' '. @@ -507,7 +509,7 @@ sub discourse { 'cfs' => 'Check for Section/Group', 'cfn' => 'Check for None'); $r->print(< + -  - -  - +  + +  +

ENDDISHEADER my %coursepersonnel= @@ -599,7 +601,9 @@ $content{'sendername'}.'@'. '
'.&mt('Subject').': '.$content{'subject'}. '

'. &Apache::lontexconvert::msgtexconverted($content{'message'}). - '
'. + ''. +&mt('You have to confirm that you received this message. After confirmation, this message will be moved to your regular inbox'). + '
'. ''. ''; @@ -615,51 +619,6 @@ $content{'sendername'}.'@'. $r->print(''); } -# =============================================================== Compose reply - -sub comprep { - my ($r,$msgid)=@_; - my %message=&Apache::lonnet::get('nohist_email',[$msgid]); - my %content=&unpackagemsg($message{$msgid},1); - my $quotemsg='> '.$content{'message'}; - $quotemsg=~s/\r/\n/g; - $quotemsg=~s/\f/\n/g; - $quotemsg=~s/\n+/\n\> /g; - my $torepl=&Apache::loncommon::aboutmewrapper( - &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).' ('. -$content{'sendername'}.'@'. - $content{'senderdomain'}.')'; - my $subject=&mt('Re').': '.$content{'subject'}; - my $dispcrit=''; - if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) { - my $crithelp = Apache::loncommon::help_open_topic("Course_Critical_Message"); - $dispcrit= - ' '.&mt('Send as critical message').' ' . $crithelp . - '
'. - ' '.&mt('Send as critical message').' ' . - &mt('and return receipt') . $crithelp . '

'; - } - my %lt=&Apache::lonlocal::texthash( - 'to' => 'To', - 'sb' => 'Subject', - 'sr' => 'Send Reply', - 'ca' => 'Cancel' - ); - $r->print(<<"ENDREPLY"); -

- -$lt{'to'}: $torepl
-$lt{'sb'}:

-


-$dispcrit - - -
-ENDREPLY -} - sub sortedmessages { my @messages = &Apache::lonnet::getkeys('nohist_email'); #unpack the varibles and repack into temp for sorting @@ -780,7 +739,7 @@ ENDDISHEADER } $r->print(''.&mt('Open').''.&mt('Delete').''. + '">'.&mt('Delete').''. ''.&Apache::lonlocal::locallocaltime($sendtime).''. $fromname.''.$fromdomain.''. &Apache::lonnet::unescape($shortsubj).''. @@ -791,15 +750,42 @@ ENDDISHEADER ''.&mt('Check All').' '. ''.&mt('Uncheck All').'

'. ''. - ''. + ''. ''); } # ============================================================== Compose output sub compout { - my ($r,$forwarding,$broadcast)=@_; - my $dispcrit=''; + my ($r,$forwarding,$replying,$broadcast,$replycrit)=@_; + + if ($broadcast eq 'individual') { + &printheader($r,'/adm/email?compose=individual', + 'Send a Message'); + } elsif ($broadcast) { + &printheader($r,'/adm/email?compose=group', + 'Broadcast Message'); + } elsif ($forwarding) { + &Apache::lonhtmlcommon::add_breadcrumb + ({href=>"/adm/email?display=".&Apache::lonnet::escape($forwarding), + text=>"Display Message"}); + &printheader($r,'/adm/email?forward='.&Apache::lonnet::escape($forwarding), + 'Forwarding a Message'); + } elsif ($replying) { + &Apache::lonhtmlcommon::add_breadcrumb + ({href=>"/adm/email?display=".&Apache::lonnet::escape($replying), + text=>"Display Message"}); + &printheader($r,'/adm/email?replyto='.&Apache::lonnet::escape($replying), + 'Replying to a Message'); + } elsif ($replycrit) { + $r->print('

'.&mt('Replying to a Critical Message').'

'); + $replying=$replycrit; + } else { + &printheader($r,'/adm/email?compose=upload', + 'Distribute from Uploaded File'); + } + + my $dispcrit=''; my $dissub=''; my $dismsg=''; my $func=&mt('Send New'); @@ -813,50 +799,75 @@ sub compout { if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) { my $crithelp = Apache::loncommon::help_open_topic("Course_Critical_Message"); $dispcrit= - ' '.&mt('Send as critical message').' ' . $crithelp . + ' '.&mt('Send as critical message').' ' . $crithelp . '
'. - ' '.&mt('Send as critical message').' ' . + ' '.&mt('Send as critical message').' ' . &mt('and return receipt') . $crithelp . '

'; - } + } + my %message; + my %content; + my $defdom=$ENV{'user.domain'}; if ($forwarding) { - $dispcrit.=''; - $func=&mt('Forward'); - my %message=&Apache::lonnet::get('nohist_email',[$forwarding]); - my %content=&unpackagemsg($message{$forwarding}); - - $dissub=&mt('Forwarding').': '.$content{'subject'}; - $dismsg=&mt('Forwarded message from').' '. - $content{'sendername'}.' '.&mt('at').' '.$content{'senderdomain'}; + %message=&Apache::lonnet::get('nohist_email',[$forwarding]); + %content=&unpackagemsg($message{$forwarding}); + $dispcrit.=''; + $func=&mt('Forward'); + + $dissub=&mt('Forwarding').': '.$content{'subject'}; + $dismsg=&mt('Forwarded message from').' '. + $content{'sendername'}.' '.&mt('at').' '.$content{'senderdomain'}; + } + if ($replying) { + %message=&Apache::lonnet::get('nohist_email',[$replying]); + %content=&unpackagemsg($message{$replying}); + $dispcrit.=''; + $func=&mt('Replying to'); + + $dissub=&mt('Reply').': '.$content{'subject'}; + $dismsg='> '.$content{'message'}; + $dismsg=~s/\r/\n/g; + $dismsg=~s/\f/\n/g; + $dismsg=~s/\n+/\n\> /g; } - my $defdom=$ENV{'user.domain'}; if ($ENV{'form.recdom'}) { $defdom=$ENV{'form.recdom'}; } $r->print( '

'."\n". - ''."\n". + ''."\n". ''); unless (($broadcast eq 'group') || ($broadcast eq 'upload')) { - my $domform = &Apache::loncommon::select_dom_form($defdom,'recdomain'); - my $selectlink=&Apache::loncommon::selectstudent_link + if ($replying) { + $r->print(''); + } else { + my $domform = &Apache::loncommon::select_dom_form($defdom,'recdomain'); + my $selectlink=&Apache::loncommon::selectstudent_link ('compemail','recuname','recdomain'); - $r->print(<<"ENDREC"); -
'.&mt('Replying to').' '. + &Apache::loncommon::aboutmewrapper( + &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).' ('. + $content{'sendername'}.'@'. + $content{'senderdomain'}.')'. + ''. + ''. + '
+ $r->print(<<"ENDREC"); ENDREC + } } my $latexHelp = Apache::loncommon::helpLatexCheatsheet(); if ($broadcast ne 'upload') { $r->print(<<"ENDCOMP"); - +
$lt{'us'}:$selectlink
$lt{'do'}: $domform
$lt{'ad'}
username\@domain,username\@domain, ...
-
$lt{'sb'}: +
$lt{'sb'}:
$latexHelp -


$dispcrit @@ -864,13 +875,14 @@ $dispcrit ENDCOMP } else { # $broadcast is 'upload' $r->print(< + +

Generate messages from a file

-Subject: +Subject:

General message text
-

The file format for the uploaded portion of the message is: @@ -884,9 +896,9 @@ username3\@domain1: text The messages will be assembled from all lines with the respective username\@domain, and appended to the general message text.

-

+

$dispcrit - +

ENDUPLOAD } if ($broadcast eq 'group') { @@ -918,7 +930,7 @@ sub disfacetoface { $result.='

'.&mt('Sent Message').'

'; %content=&unpackagemsg($content{'message'}); $content{'message'}= - 'Subject: '.$content{'subject'}.'
'. + ''.&mt('Subject').': '.$content{'subject'}.'
'. $content{'message'}; } $result.=&mt('By').': '. @@ -926,13 +938,13 @@ sub disfacetoface { &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).' ('. $content{'sendername'}.'@'. $content{'senderdomain'}.') '.$content{'time'}. - '
'. + '
'. &Apache::lontexconvert::msgtexconverted($content{'message'}). '
'; } # Check to see if there were any messages. if ($result eq '') { - $r->print("

No notes, face-to-face discussion records, or critical messages in this course.

"); + $r->print("

".&mt("No notes, face-to-face discussion records, or critical messages in this course.")."

"); } else { $r->print($result); } @@ -945,7 +957,11 @@ sub facetoface { unless (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) { return; } + &printheader($r, + '/adm/email?recordftf=query', + "User Notes, Face-to-Face, Critical Messages"); # from query string + if ($ENV{'form.recname'}) { $ENV{'form.recuname'}=$ENV{'form.recname'}; } if ($ENV{'form.recdom'}) { $ENV{'form.recdomain'}=$ENV{'form.recdom'}; } @@ -956,17 +972,23 @@ sub facetoface { my $domform = &Apache::loncommon::select_dom_form($defdom,'recdomain'); my $stdbrws = &Apache::loncommon::selectstudent_link ('stdselect','recuname','recdomain'); + my %lt=&Apache::lonlocal::texthash('user' => 'Username', + 'dom' => 'Domain', + 'head' => 'User Notes, Records of Face-To-Face Discussions, and Critical Messages in Course', + 'subm' => 'Retrieve discussion and message records', + 'newr' => 'New Record (record is visible to course faculty and staff)', + 'post' => 'Post this Record'); $r->print(<<"ENDTREC"); -

User Notes, Records of Face-To-Face Discussions, and Critical Messages in Course

+

$lt{'head'}

- + + - +
Username:
$lt{'user'}: $stdbrws -
Domain:
$lt{'dom'}: $domform
@@ -978,7 +1000,8 @@ ENDTREC &user_normal_msg_raw( $ENV{'course.'.$ENV{'request.course.id'}.'.num'}, $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, - 'Record ['.$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}.']', + &mt('Record'). + ' ['.$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}.']', $ENV{'form.newrecord'}); } $r->print('

'.&Apache::loncommon::plainname($ENV{'form.recuname'}, @@ -990,28 +1013,114 @@ ENDTREC ENDRHEAD $r->print(<New Record (record is visible to course faculty and staff)
+
$lt{'newr'}

- + ENDBFORM } } +# ----------------------------------------------------------- Display a message + +sub displaymessage { + my ($r,$msgid)=@_; + &statuschange($msgid,'read'); + my %message=&Apache::lonnet::get('nohist_email',[$msgid]); + my %content=&unpackagemsg($message{$msgid}); +# info to generate "next" and "previous" buttons + my @messages=&sortedmessages(); + my $counter=0; + $r->print('
');
+    my $escmsgid=&Apache::lonnet::escape($msgid);
+    foreach (@messages) {
+	if ($_->[5] eq $escmsgid){
+	    last;
+	}
+	$counter++;
+    }
+    $r->print('
'); + my $number_of_messages = scalar(@messages); #subtract 1 for last index +# start output + &printheader($r,'/adm/email?display='.&Apache::lonnet::escape($msgid),'Display a Message','',$content{'baseurl'}); + my %courseinfo=&Apache::lonnet::coursedescription($content{'courseid'}); +# Functions + $r->print(''. + ''. + ''. + ''. + ''. + ''); + if ($counter > 0){ + $r->print(''); + } + if ($counter < $number_of_messages - 1){ + $r->print(''); + } + $r->print('
'.&mt('Functions').':'.&mt('Reply').''.&mt('Forward').''.&mt('Mark Unread').'Delete'.&mt('Display all Messages').''.&mt('Previous').''.&mt('Next').'
'); + $r->print('
'.&mt('Subject').': '.$content{'subject'}. + '
'.&mt('From').': '. + &Apache::loncommon::aboutmewrapper( + &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}), + $content{'sendername'},$content{'senderdomain'}).' ('. + $content{'sendername'}.' at '. + $content{'senderdomain'}.') '. + ($content{'courseid'}?'
'.&mt('Course').': '.$courseinfo{'description'}. + ($content{'coursesec'}?' ('.&mt('Group/Section').': '.$content{'coursesec'}.')':''):''). + '
'.&mt('Time').': '.$content{'time'}. + '

'.
+	      &Apache::lontexconvert::msgtexconverted($content{'message'},1).
+	      '

'.$content{'citation'}.'

'); + return; +} + +# ================================================================== The Header + +sub header { + my ($r,$title,$baseurl)=@_; + $r->print('Communication and Messages'); + if ($baseurl) { + $r->print(""); + } + $r->print(&Apache::loncommon::studentbrowser_javascript().''. + &Apache::loncommon::bodytag('Communication and Messages')); + $r->print(&Apache::lonhtmlcommon::breadcrumbs + (undef,($title?$title:'Communication and Messages'))); + +} + +# ---------------------------------------------------------------- Print header + +sub printheader { + my ($r,$url,$desc,$title,$baseurl)=@_; + &Apache::lonhtmlcommon::add_breadcrumb + ({href=>$url, + text=>$desc}); + &header($r,$title,$baseurl); +} + + # ===================================================================== Handler sub handler { my $r=shift; # ----------------------------------------------------------- Set document type - - &Apache::loncommon::content_type($r,'text/html'); - $r->send_http_header; - - return OK if $r->header_only; - + + &Apache::loncommon::content_type($r,'text/html'); + $r->send_http_header; + + return OK if $r->header_only; + # --------------------------- Get query string for limited number of parameters &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['display','replyto','forward','markread','markdel','markunread', @@ -1019,217 +1128,150 @@ sub handler { 'recordftf','sortedby']); $sqs='&sortedby='.$ENV{'form.sortedby'}; # ------------------------------------------------------ They checked for email - &Apache::lonnet::put('email_status',{'recnewemail'=>0}); + &Apache::lonnet::put('email_status',{'recnewemail'=>0}); + +# ----------------------------------------------------------------- Breadcrumbs + + &Apache::lonhtmlcommon::clear_breadcrumbs(); + &Apache::lonhtmlcommon::add_breadcrumb + ({href=>"/adm/communicate", + text=>"Communication/Messages", + faq=>12,bug=>'Communication Tools',}); + # --------------------------------------------------------------- Render Output - if (!$ENV{'form.display'}) { - $r->print('EMail and Messaging'. - &Apache::loncommon::studentbrowser_javascript().''. - &Apache::loncommon::bodytag('EMail and Messages'). - &Apache::loncommon::help_open_faq(12). - &Apache::loncommon::help_open_bug('Communication Tools')); - } - if ($ENV{'form.display'}) { - my $msgid=$ENV{'form.display'}; - &statuschange($msgid,'read'); - my %message=&Apache::lonnet::get('nohist_email',[$msgid]); - my %content=&unpackagemsg($message{$msgid}); -# info to generate "next" and "previous" buttons - my @messages=&sortedmessages(); - my $counter=0; - $r->print('
');
-      my $escmsgid=&Apache::lonnet::escape($msgid);
-      foreach (@messages) {
- 	  if ($_->[5] eq $escmsgid){
- 	      last;
- 	  }
- 	  $counter++;
-      }
-      $r->print('
'); - my $number_of_messages = scalar(@messages); #subtract 1 for last index -# start output - $r->print('EMail and Messaging'); - if (defined($content{'baseurl'})) { - $r->print(""); - } - $r->print(&Apache::loncommon::studentbrowser_javascript(). - ''. - &Apache::loncommon::bodytag('EMail and Messages'). - &Apache::loncommon::help_open_faq(12). - &Apache::loncommon::help_open_bug('Communication Tools')); - $r->print(''.&mt('Subject').': '.$content{'subject'}. - '
'.&mt('From').': '. -&Apache::loncommon::aboutmewrapper( -&Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}), -$content{'sendername'},$content{'senderdomain'}).' ('. - $content{'sendername'}.' at '. - $content{'senderdomain'}.') '. - '
'.&mt('Time').': '.$content{'time'}.'

'. - ''. - ''. - ''. - ''. - ''. - ''); - if ($counter > 0){ - $r->print(''); - } - if ($counter < $number_of_messages - 1){ - $r->print(''); - } - $r->print('
'.&mt('Functions').':'.&mt('Reply').''.&mt('Forward').''.&mt('Mark Unread').'Delete'.&mt('Display all Messages').''.&mt('Previous').''.&mt('Next').'

'.
-             &Apache::lontexconvert::msgtexconverted($content{'message'}).
-             '

'.$content{'citation'}); - } elsif ($ENV{'form.replyto'}) { - &comprep($r,$ENV{'form.replyto'}); - } elsif ($ENV{'form.sendreply'}) { - if ($ENV{'form.send'}) { - my $msgid=$ENV{'form.sendreply'}; - my %message=&Apache::lonnet::get('nohist_email',[$msgid]); - my %content=&unpackagemsg($message{$msgid},1); - &statuschange($msgid,'replied'); - if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) && - (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) { - $r->print(&mt('Sending critical message').': '. - &user_crit_msg($content{'sendername'}, - $content{'senderdomain'}, - &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}), - &Apache::lonfeedback::clear_out_html($ENV{'form.message'}), - $ENV{'form.sendbck'})); - } else { - $r->print(&mt('Sending').': '.&user_normal_msg($content{'sendername'}, - $content{'senderdomain'}, - &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}), - &Apache::lonfeedback::clear_out_html($ENV{'form.message'}))); - } - } - if ($ENV{'form.displayedcrit'}) { - &discrit($r); - } else { - &disall($r); - } - } elsif ($ENV{'form.confirm'}) { - foreach (keys %ENV) { - if ($_=~/^form\.rec\_(.*)$/) { - $r->print('Confirming Receipt: '. - &user_crit_received($1).'
'); - } - if ($_=~/^form\.reprec\_(.*)$/) { - my $msgid=$1; - $r->print('Confirming Receipt: '. - &user_crit_received($msgid).'
'); - &comprep($r,$msgid); - } - } - &discrit($r); - } elsif ($ENV{'form.critical'}) { - &discrit($r); - } elsif ($ENV{'form.forward'}) { - &compout($r,$ENV{'form.forward'}); - } elsif ($ENV{'form.markread'}) { - } elsif ($ENV{'form.markdel'}) { - &statuschange($ENV{'form.markdel'},'deleted'); - &disall($r); - } elsif ($ENV{'form.markeddel'}) { - my $total=0; - foreach (keys %ENV) { - if ($_=~/^form\.delmark_(.*)$/) { - &statuschange(&Apache::lonnet::unescape($1),'deleted'); - $total++; - } - } - $r->print('Deleted '.$total.' message(s)

'); - &disall($r); - } elsif ($ENV{'form.markunread'}) { - &statuschange($ENV{'form.markunread'},'new'); - &disall($r); - } elsif ($ENV{'form.compose'}) { - &compout($r,'',$ENV{'form.compose'}); - } elsif ($ENV{'form.recordftf'}) { - &facetoface($r,$ENV{'form.recordftf'}); - } elsif ($ENV{'form.sendmail'}) { - my $sendstatus=''; - if ($ENV{'form.send'}) { - my %content=(); - undef %content; - if ($ENV{'form.forwid'}) { - my $msgid=$ENV{'form.forwid'}; - my %message=&Apache::lonnet::get('nohist_email',[$msgid]); - %content=&unpackagemsg($message{$msgid},1); - &statuschange($msgid,'forwarded'); - $ENV{'form.message'}.="\n\n-- Forwarded message --\n\n". - $content{'message'}; - } - my %toaddr=(); - undef %toaddr; - if ($ENV{'form.sendmode'} eq 'group') { - foreach (keys %ENV) { - if ($_=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) { - $toaddr{$1}=''; - } - } - } elsif ($ENV{'form.sendmode'} eq 'upload') { - foreach (split(/[\n\r\f]+/,$ENV{'form.upfile'})) { - my ($rec,$txt)=split(/\s*\:\s*/,$_); - if ($txt) { - $rec=~s/\@/\:/; - $toaddr{$rec}.=$txt."\n"; - } - } - } else { - $toaddr{$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}}=''; - } - if ($ENV{'form.additionalrec'}) { - foreach (split(/\,/,$ENV{'form.additionalrec'})) { - my ($auname,$audom)=split(/\@/,$_); - $toaddr{$auname.':'.$audom}=''; - } - } - foreach (keys %toaddr) { - my ($recuname,$recdomain)=split(/\:/,$_); - my $msgtxt=&Apache::lonfeedback::clear_out_html($ENV{'form.message'}); - if ($toaddr{$_}) { $msgtxt.='


'.$toaddr{$_}; } - if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) && - (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) { - $r->print(&mt('Sending critical message').' ...'); - $sendstatus.=' '.&user_crit_msg($recuname,$recdomain, - &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}), - $msgtxt, - $ENV{'form.sendbck'}); - } else { - $r->print(&mt('Sending').' ...'); - $sendstatus.=' '.&user_normal_msg($recuname,$recdomain, - &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}), - $msgtxt, - $content{'citation'}); - } - $r->print('
'); - } - } - if ($sendstatus=~/^(\s*(?:ok|con_delayed)\s*)*$/) { - if ($ENV{'form.displayedcrit'}) { - &discrit($r); - } else { - &disall($r); - } - } else { - $r->print( - '

'.&mt('Could not deliver message').'

'. - &mt('Please use the browser "Back" button and correct the recipient addresses') - ); - } - } else { - &disall($r); - } - $r->print(''); - return OK; + if ($ENV{'form.display'}) { + &displaymessage($r,$ENV{'form.display'}); + } elsif ($ENV{'form.replyto'}) { + &compout($r,'',$ENV{'form.replyto'}); + } elsif ($ENV{'form.confirm'}) { + &printheader($r,'','Confirmed Receipt'); + foreach (keys %ENV) { + if ($_=~/^form\.rec\_(.*)$/) { + $r->print(''.&mt('Confirming Receipt').': '. + &user_crit_received($1).'
'); + } + if ($_=~/^form\.reprec\_(.*)$/) { + my $msgid=$1; + $r->print(''.&mt('Confirming Receipt').': '. + &user_crit_received($msgid).'
'); + &compout($r,'','','',$msgid); + } + } + &discrit($r); + } elsif ($ENV{'form.critical'}) { + &printheader($r,'','Displaying Critical Messages'); + &discrit($r); + } elsif ($ENV{'form.forward'}) { + &compout($r,$ENV{'form.forward'}); + } elsif ($ENV{'form.markdel'}) { + &printheader($r,'','Deleted Message'); + &statuschange($ENV{'form.markdel'},'deleted'); + &disall($r); + } elsif ($ENV{'form.markeddel'}) { + my $total=0; + foreach (keys %ENV) { + if ($_=~/^form\.delmark_(.*)$/) { + &statuschange(&Apache::lonnet::unescape($1),'deleted'); + $total++; + } + } + &printheader($r,'','Deleted Messages'); + $r->print('Deleted '.$total.' message(s)

'); + &disall($r); + } elsif ($ENV{'form.markunread'}) { + &printheader($r,'','Marked Message as Unread'); + &statuschange($ENV{'form.markunread'},'new'); + &disall($r); + } elsif ($ENV{'form.compose'}) { + &compout($r,'','',$ENV{'form.compose'}); + } elsif ($ENV{'form.recordftf'}) { + &facetoface($r,$ENV{'form.recordftf'}); + } elsif ($ENV{'form.sendmail'}) { + my $sendstatus=''; + if ($ENV{'form.send'}) { + &printheader($r,'','Messages being sent.'); + $r->rflush(); + my %content=(); + undef %content; + if ($ENV{'form.forwid'}) { + my $msgid=$ENV{'form.forwid'}; + my %message=&Apache::lonnet::get('nohist_email',[$msgid]); + %content=&unpackagemsg($message{$msgid},1); + &statuschange($msgid,'forwarded'); + $ENV{'form.message'}.="\n\n-- Forwarded message --\n\n". + $content{'message'}; + } + my %toaddr=(); + undef %toaddr; + if ($ENV{'form.sendmode'} eq 'group') { + foreach (keys %ENV) { + if ($_=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) { + $toaddr{$1}=''; + } + } + } elsif ($ENV{'form.sendmode'} eq 'upload') { + foreach (split(/[\n\r\f]+/,$ENV{'form.upfile'})) { + my ($rec,$txt)=split(/\s*\:\s*/,$_); + if ($txt) { + $rec=~s/\@/\:/; + $toaddr{$rec}.=$txt."\n"; + } + } + } else { + $toaddr{$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}}=''; + } + if ($ENV{'form.additionalrec'}) { + foreach (split(/\,/,$ENV{'form.additionalrec'})) { + my ($auname,$audom)=split(/\@/,$_); + $toaddr{$auname.':'.$audom}=''; + } + } + + foreach (keys %toaddr) { + my ($recuname,$recdomain)=split(/\:/,$_); + my $msgtxt=&Apache::lonfeedback::clear_out_html($ENV{'form.message'}); + if ($toaddr{$_}) { $msgtxt.='


'.$toaddr{$_}; } + my $thismsg; + if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) && + (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) { + $r->print(&mt('Sending critical message').' '.$recuname.'@'.$recdomain.': '); + $thismsg=&user_crit_msg($recuname,$recdomain, + &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}), + $msgtxt, + $ENV{'form.sendbck'}); + } else { + $r->print(&mt('Sending').' '.$recuname.'@'.$recdomain.': '); + $thismsg=&user_normal_msg($recuname,$recdomain, + &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}), + $msgtxt, + $content{'citation'}); + } + $r->print($thismsg.'
'); + $sendstatus.=' '.$thismsg; + } + } else { + &printheader($r,'','No messages sent.'); + } + if ($sendstatus=~/^(\s*(?:ok|con_delayed)\s*)*$/) { + $r->print('
'.&mt('Completed.').''); + if ($ENV{'form.displayedcrit'}) { + &discrit($r); + } else { + &Apache::loncommunicate::menu($r); + } + } else { + $r->print( + '

'.&mt('Could not deliver message').'

'. + &mt('Please use the browser "Back" button and correct the recipient addresses') + ); + } + } else { + &printheader($r,'','Display All Messages'); + &disall($r); + } + $r->print(''); + return OK; } # ================================================= Main program, reset counter