--- loncom/interface/lonmsg.pm 2004/03/01 01:19:51 1.87 +++ loncom/interface/lonmsg.pm 2004/03/26 17:13:59 1.94 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging # -# $Id: lonmsg.pm,v 1.87 2004/03/01 01:19:51 www Exp $ +# $Id: lonmsg.pm,v 1.94 2004/03/26 17:13:59 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -508,7 +508,7 @@ sub discourse { 'cfs' => 'Check for Section/Group', 'cfn' => 'Check for None'); $r->print(< + -  - -  - +  + +  +

ENDDISHEADER my %coursepersonnel= @@ -618,51 +618,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 @@ -783,7 +738,7 @@ ENDDISHEADER } $r->print(''.&mt('Open').''.&mt('Delete').''. + '">'.&mt('Delete').''. ''.&Apache::lonlocal::locallocaltime($sendtime).''. $fromname.''.$fromdomain.''. &Apache::lonnet::unescape($shortsubj).''. @@ -794,15 +749,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'); @@ -816,50 +798,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 @@ -867,14 +874,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: @@ -888,9 +895,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') { @@ -922,7 +929,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').': '. @@ -930,13 +937,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); } @@ -949,7 +956,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'}; } @@ -960,17 +971,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
@@ -982,7 +999,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'}, @@ -994,16 +1012,102 @@ 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 { @@ -1024,124 +1128,43 @@ sub handler { $sqs='&sortedby='.$ENV{'form.sortedby'}; # ------------------------------------------------------ They checked for email &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')); - my %courseinfo=&Apache::lonnet::coursedescription($content{'courseid'}); - - $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'}.'

'. - ''. - ''. - ''. - ''. - ''. - ''); - 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'},1).
-		  '

'.$content{'citation'}); + &displaymessage($r,$ENV{'form.display'}); } 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); - } + &compout($r,'',$ENV{'form.replyto'}); } elsif ($ENV{'form.confirm'}) { + &printheader($r,'','Confirmed Receipt'); foreach (keys %ENV) { if ($_=~/^form\.rec\_(.*)$/) { - $r->print('Confirming Receipt: '. + $r->print(''.&mt('Confirming Receipt').': '. &user_crit_received($1).'
'); } if ($_=~/^form\.reprec\_(.*)$/) { my $msgid=$1; - $r->print('Confirming Receipt: '. + $r->print(''.&mt('Confirming Receipt').': '. &user_crit_received($msgid).'
'); - &comprep($r,$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.markread'}) { } elsif ($ENV{'form.markdel'}) { + &printheader($r,'','Deleted Message'); &statuschange($ENV{'form.markdel'},'deleted'); &disall($r); } elsif ($ENV{'form.markeddel'}) { @@ -1152,18 +1175,22 @@ sub handler { $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'}); + &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'}) { @@ -1199,25 +1226,28 @@ sub handler { $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 ($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').' ...'); - $sendstatus.=' '.&user_crit_msg($recuname,$recdomain, + $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').' ...'); - $sendstatus.=' '.&user_normal_msg($recuname,$recdomain, + $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('
'); + $r->print($thismsg.'
'); + $sendstatus.=' '.$thismsg; } } if ($sendstatus=~/^(\s*(?:ok|con_delayed)\s*)*$/) { @@ -1234,6 +1264,7 @@ sub handler { ); } } else { + &printheader($r,'','Display All Messages'); &disall($r); } $r->print('');