--- loncom/interface/lonmsg.pm 2001/08/03 17:16:48 1.14 +++ loncom/interface/lonmsg.pm 2001/08/09 14:57:33 1.17 @@ -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,08/08,08/09 Gerd Kortemeyer package Apache::lonmsg; @@ -206,6 +206,59 @@ sub statuschange { } } +# ======================================================= Display a course list + +sub discourse { + my $r=shift; + my %courselist=&Apache::lonnet::dump( + 'classlist', + $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, + $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + my $now=time; + $r->print(< + + + +

+ENDDISHEADER + map { + my ($end,$start)=split(/\:/,$courselist{$_}); + my $active=1; + if (($end) && ($now>$end)) { $active=0; } + if ($active) { + my ($sname,$sdom)=split(/\:/,$_); + my %reply=&Apache::lonnet::get('environment', + ['firstname','middlename','lastname','generation'], + $sdom,$sname); + $r->print('
'. + $reply{'firstname'}.' '. + $reply{'middlename'}.' '. + $reply{'lastname'}.' '. + $reply{'generation'}. + ' ('.$_.')'); + } + } sort keys %courselist; +} + # ==================================================== Display Critical Message sub discrit { @@ -223,7 +276,8 @@ sub discrit { ''. ''); } sort keys %what; - $r->print(''); + $r->print( + ''); } # =============================================================== Compose reply @@ -255,6 +309,8 @@ $dispcrit ENDREPLY } +# ======================================================== Display all messages + sub disall { my $r=shift; $r->print('

Display All Messages

'. @@ -287,6 +343,54 @@ sub disall { $r->print(''); } +# ============================================================== Compose output + +sub compout { + my ($r,$forwarding,$broadcast)=@_; + 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('

'. + ''); + unless ($broadcast eq 'group') { + $r->print(<<"ENDREC"); +
+ + + +ENDREC + } + $r->print(<<"ENDCOMP"); +
Username:
Domain:
Subject: +
+

+$dispcrit + +ENDCOMP + if ($broadcast eq 'group') { + &discourse; + } + $r->print('

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

'.
              $content{'message'}.'

'.$content{'citation'}); } elsif ($ENV{'form.replyto'}) { @@ -380,28 +487,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,'',$ENV{'form.compose'}); } 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); }