--- loncom/interface/lonmsg.pm 2001/08/09 14:57:33 1.17 +++ loncom/interface/lonmsg.pm 2001/11/05 19:44:23 1.24 @@ -13,7 +13,8 @@ # 10/19,10/20,10/30, # 02/06/01 Gerd Kortemeyer # 07/27 Guy Albertelli -# 07/27,07/28,07/30,08/03,08/06,08/08,08/09 Gerd Kortemeyer +# 07/27,07/28,07/30,08/03,08/06,08/08,08/09,08/10,8/13,8/15, +# 10/1,11/5 Gerd Kortemeyer package Apache::lonmsg; @@ -114,15 +115,15 @@ sub author_res_msg { # ================================================== Critical message to a user sub user_crit_msg { - my ($user,$domain,$subject,$message)=@_; + my ($user,$domain,$subject,$message,$sendback)=@_; # Check if allowed missing my $status=''; my $msgid='undefined'; unless (($message)&&($user)&&($domain)) { $status='empty'; }; my $homeserver=&Apache::lonnet::homeserver($user,$domain); if ($homeserver ne 'no_host') { - my $msgid; ($msgid,$message)=&packagemsg($subject,$message); + if ($sendback) { $message.='true'; } $status=&Apache::lonnet::critical( 'put:'.$domain.':'.$user.':critical:'. &Apache::lonnet::escape($msgid).'='. @@ -146,13 +147,13 @@ sub user_crit_received { my $msgid=shift; my %message=&Apache::lonnet::get('critical',[$msgid]); my %contents=&unpackagemsg($message{$msgid}); - my $status='rec: '. + my $status='rec: '.($contents{'sendback'}? &user_normal_msg($contents{'sendername'},$contents{'senderdomain'}, 'Receipt: '.$ENV{'user.name'}.' at '.$ENV{'user.domain'}, 'User '.$ENV{'user.name'}.' at '.$ENV{'user.domain'}. ' acknowledged receipt of message "'. $contents{'subject'}.'" dated '.$contents{'time'}.".\n\n" - .'Message ID: '.$contents{'msgid'}); + .'Message ID: '.$contents{'msgid'}):'no msg req'); $status.=' trans: '. &Apache::lonnet::put( 'nohist_email',{$contents{'msgid'} => $message{$msgid}}); @@ -175,7 +176,6 @@ sub user_normal_msg { unless (($message)&&($user)&&($domain)) { $status='empty'; }; my $homeserver=&Apache::lonnet::homeserver($user,$domain); if ($homeserver ne 'no_host') { - my $msgid; ($msgid,$message)=&packagemsg($subject,$message,$citation); $status=&Apache::lonnet::critical( 'put:'.$domain.':'.$user.':nohist_email:'. @@ -227,6 +227,16 @@ sub discourse { } } + function checksec() { + for (i=0; i - +  + + 

ENDDISHEADER @@ -249,12 +261,15 @@ ENDDISHEADER my %reply=&Apache::lonnet::get('environment', ['firstname','middlename','lastname','generation'], $sdom,$sname); - $r->print('
'. + my $section=&Apache::lonnet::usection + ($sdom,$sname,$ENV{'request.course.id'}); + $r->print( + '
'. $reply{'firstname'}.' '. $reply{'middlename'}.' '. $reply{'lastname'}.' '. $reply{'generation'}. - ' ('.$_.')'); + ' ('.$_.') '.$section); } } sort keys %courselist; } @@ -294,13 +309,15 @@ sub comprep { my $dispcrit=''; if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) { $dispcrit= - ' Send as critical message

'; + ' Send as critical message
'. + ' Send as critical message'. + ' and return receipt

'; } $r->print(<<"ENDREPLY");

Subject:

-

$dispcrit @@ -353,7 +370,9 @@ sub compout { my $func='Send New'; if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) { $dispcrit= - ' Send as critical message

'; + ' Send as critical message
'. + ' Send as critical message'. + ' and return receipt

'; } if ($forwarding) { $dispcrit.=''. + $r->print( + ''. ''); - unless ($broadcast eq 'group') { + unless (($broadcast eq 'group') || ($broadcast eq 'upload')) { $r->print(<<"ENDREC");
@@ -377,14 +398,39 @@ sub compout { ENDREC } - $r->print(<<"ENDCOMP"); + unless ($broadcast eq 'upload') { + $r->print(<<"ENDCOMP"); +
Username:
Additional Recipients
username\@domain,username\@domain, ... +
+
Subject:
-

$dispcrit ENDCOMP + } + if ($broadcast eq 'upload') { + $r->print(< +

Generate messages from a file

+Subject: +
+username1\@domain1: text
+username2\@domain2: text
+username1\@domain1: text
+
+The messages will be assembled from all lines with the respective +username\@domain, and appended to the general message text.

+

+General message text:

+

+$dispcrit + +ENDUPLOAD + } if ($broadcast eq 'group') { &discourse; } @@ -452,13 +498,14 @@ sub handler { my %message=&Apache::lonnet::get('nohist_email',[$msgid]); my %content=&unpackagemsg($message{$msgid}); &statuschange($msgid,'replied'); - if (($ENV{'form.critmsg'}) && + if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) && (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) { $r->print('Sending critical: '. &user_crit_msg($content{'sendername'}, $content{'senderdomain'}, $ENV{'form.subject'}, - $ENV{'form.message'})); + $ENV{'form.message'}, + $ENV{'form.sendbck'})); } else { $r->print('Sending: '.&user_normal_msg($content{'sendername'}, $content{'senderdomain'}, @@ -508,21 +555,50 @@ sub handler { $ENV{'form.message'}.="\n\n-- Forwarded message --\n\n". $content{'message'}; } - if (($ENV{'form.critmsg'}) && + my %toaddr=(); + undef %toaddr; + if ($ENV{'form.sendmode'} eq 'group') { + map { + if ($_=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) { + $toaddr{$1}=''; + } + } keys %ENV; + } elsif ($ENV{'form.sendmode'} eq 'upload') { + map { + my ($rec,$txt)=split(/\s*\:\s*/,$_); + if ($txt) { + $rec=~s/\@/\:/; + $toaddr{$rec}.=$txt."\n"; + } + } split(/[\n\r\f]+/,$ENV{'form.upfile'}); + } else { + $toaddr{$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}}=''; + } + if ($ENV{'form.additionalrec'}) { + map { + my ($auname,$audom)=split(/\@/,$_); + $toaddr{$auname.':'.$audom}=''; + } split(/\,/,$ENV{'form.additionalrec'}); + } + map { + my ($recuname,$recdomain)=split(/\:/,$_); + my $msgtxt=$ENV{'form.message'}; + if ($toaddr{$_}) { $msgtxt.='


'.$toaddr{$_}; } + if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) && (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) { $r->print('Sending critical: '. - &user_crit_msg($ENV{'form.recuname'}, - $ENV{'form.recdomain'}, + &user_crit_msg($recuname,$recdomain, $ENV{'form.subject'}, - $ENV{'form.message'}, - $content{'citation'})); + $msgtxt, + $ENV{'form.sendbck'})); } else { - $r->print('Sending: '.&user_normal_msg($ENV{'form.recuname'}, - $ENV{'form.recdomain'}, + $r->print('Sending: '.&user_normal_msg($recuname,$recdomain, $ENV{'form.subject'}, - $ENV{'form.message'}, + $msgtxt, $content{'citation'})); } + $r->print('
'); + } keys %toaddr; if ($ENV{'form.displayedcrit'}) { &discrit($r); } else {