--- loncom/interface/lonmsg.pm 2001/08/03 17:16:48 1.14 +++ loncom/interface/lonmsg.pm 2001/08/06 11:41:11 1.16 @@ -13,7 +13,7 @@ # 10/19,10/20,10/30, # 02/06/01 Gerd Kortemeyer # 07/27 Guy Albertelli -# 07/27,07/28,07/30,08/03 Gerd Kortemeyer +# 07/27,07/28,07/30,08/03,08/06 Gerd Kortemeyer package Apache::lonmsg; @@ -223,7 +223,8 @@ sub discrit { ''. ''); } sort keys %what; - $r->print(''); + $r->print( + ''); } # =============================================================== Compose reply @@ -255,6 +256,8 @@ $dispcrit ENDREPLY } +# ======================================================== Display all messages + sub disall { my $r=shift; $r->print('

Display All Messages

'. @@ -287,6 +290,47 @@ sub disall { $r->print(''); } +# ============================================================== Compose output + +sub compout { + my ($r,$forwarding)=@_; + my $dispcrit=''; + my $dissub=''; + my $dismsg=''; + my $func='Send New'; + if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) { + $dispcrit= + ' Send as critical message

'; + } + if ($forwarding) { + $dispcrit.=''; + $func='Forward'; + my %message=&Apache::lonnet::get('nohist_email',[$forwarding]); + my %content=&unpackagemsg($message{$forwarding}); + + $dissub='Forwarding: '.$content{'subject'}; + $dismsg='Forwarded message from '. + $content{'sendername'}.' at '.$content{'senderdomain'}; + } + my $defdom=$ENV{'user.domain'}; + $r->print(<<"ENDCOMP"); +

+ + + + + +
Username:
Domain:
Subject: +
+

+$dispcrit + +

+ENDCOMP +} + # ===================================================================== Handler sub handler { @@ -334,8 +378,11 @@ sub handler { ''. ''. - ''. + ''. + ''. '
Functions:ReplyForwardMark UnreadDisplay all Messages

'.
              $content{'message'}.'

'.$content{'citation'}); } elsif ($ENV{'form.replyto'}) { @@ -380,28 +427,47 @@ sub handler { } 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.markunread'}) { + &statuschange($ENV{'form.markunread'},'new'); + &disall($r); } elsif ($ENV{'form.compose'}) { - my $dispcrit=''; - if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) { - $dispcrit= - ' Send as critical message

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

- -Subject:

-

-$dispcrit - -

-ENDCOMP + &compout($r); } elsif ($ENV{'form.sendmail'}) { + 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}); + &statuschange($msgid,'forwarded'); + $ENV{'form.message'}.="\n\n-- Forwarded message --\n\n". + $content{'message'}; + } + if (($ENV{'form.critmsg'}) && + (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) { + $r->print('Sending critical: '. + &user_crit_msg($ENV{'form.recuname'}, + $ENV{'form.recdomain'}, + $ENV{'form.subject'}, + $ENV{'form.message'}, + $content{'citation'})); + } else { + $r->print('Sending: '.&user_normal_msg($ENV{'form.recuname'}, + $ENV{'form.recdomain'}, + $ENV{'form.subject'}, + $ENV{'form.message'}, + $content{'citation'})); + } + if ($ENV{'form.displayedcrit'}) { + &discrit($r); + } else { + &disall($r); + } } else { &disall($r); }