--- loncom/interface/lonmsg.pm 2001/08/03 18:47:18 1.15 +++ loncom/interface/lonmsg.pm 2001/08/16 01:42:07 1.22 @@ -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,08/10,8/13,8/15 Gerd Kortemeyer package Apache::lonmsg; @@ -121,7 +121,6 @@ sub user_crit_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); $status=&Apache::lonnet::critical( 'put:'.$domain.':'.$user.':critical:'. @@ -175,7 +174,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:'. @@ -206,6 +204,74 @@ 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); + 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; +} + # ==================================================== Display Critical Message sub discrit { @@ -223,7 +289,8 @@ sub discrit { ''. ''); } sort keys %what; - $r->print(''); + $r->print( + ''); } # =============================================================== Compose reply @@ -292,7 +359,7 @@ sub disall { # ============================================================== Compose output sub compout { - my ($r,$forwarding)=@_; + my ($r,$forwarding,$broadcast)=@_; my $dispcrit=''; my $dissub=''; my $dismsg=''; @@ -313,21 +380,55 @@ sub compout { $content{'sendername'}.' at '.$content{'senderdomain'}; } my $defdom=$ENV{'user.domain'}; - $r->print(<<"ENDCOMP"); -

- + $r->print( + ''. + ''); + unless (($broadcast eq 'group') || ($broadcast eq 'upload')) { + $r->print(<<"ENDREC");
+ENDREC + } + unless ($broadcast eq 'upload') { + $r->print(<<"ENDCOMP"); +
Username:
Domain:
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; + } + $r->print(''); } # ===================================================================== Handler @@ -435,8 +536,67 @@ sub handler { &statuschange($ENV{'form.markunread'},'new'); &disall($r); } elsif ($ENV{'form.compose'}) { - &compout($r); + &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'}; + } + 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'}) && + (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) { + $r->print('Sending critical: '. + &user_crit_msg($recuname,$recdomain, + $ENV{'form.subject'}, + $msgtxt, + $content{'citation'})); + } else { + $r->print('Sending: '.&user_normal_msg($recuname,$recdomain, + $ENV{'form.subject'}, + $msgtxt, + $content{'citation'})); + } + $r->print('
'); + } keys %toaddr; + if ($ENV{'form.displayedcrit'}) { + &discrit($r); + } else { + &disall($r); + } } else { &disall($r); }