version 1.7, 2001/02/06 18:17:34
|
version 1.14, 2001/08/03 17:16:48
|
Line 12
|
Line 12
|
# |
# |
# 10/19,10/20,10/30, |
# 10/19,10/20,10/30, |
# 02/06/01 Gerd Kortemeyer |
# 02/06/01 Gerd Kortemeyer |
|
# 07/27 Guy Albertelli |
|
# 07/27,07/28,07/30,08/03 Gerd Kortemeyer |
|
|
package Apache::lonmsg; |
package Apache::lonmsg; |
|
|
Line 83 sub unpackmsgid {
|
Line 85 sub unpackmsgid {
|
my $msgid=&Apache::lonnet::unescape(shift); |
my $msgid=&Apache::lonnet::unescape(shift); |
my ($sendtime,$shortsubj,$fromname,$fromdomain)=split(/\:/, |
my ($sendtime,$shortsubj,$fromname,$fromdomain)=split(/\:/, |
&Apache::lonnet::unescape($msgid)); |
&Apache::lonnet::unescape($msgid)); |
my %status=&Apache::lonnet::get('email_status',$msgid); |
my %status=&Apache::lonnet::get('email_status',[$msgid]); |
if ($status{$msgid}=~/^error\:/) { $status{$msgid}=''; } |
if ($status{$msgid}=~/^error\:/) { $status{$msgid}=''; } |
unless ($status{$msgid}) { $status{$msgid}='new'; } |
unless ($status{$msgid}) { $status{$msgid}='new'; } |
return ($sendtime,$shortsubj,$fromname,$fromdomain,$status{$msgid}); |
return ($sendtime,$shortsubj,$fromname,$fromdomain,$status{$msgid}); |
Line 141 sub user_crit_msg {
|
Line 143 sub user_crit_msg {
|
# =================================================== Critical message received |
# =================================================== Critical message received |
|
|
sub user_crit_received { |
sub user_crit_received { |
my $message=shift; |
my $msgid=shift; |
my %contents=&unpackagemsg($message); |
my %message=&Apache::lonnet::get('critical',[$msgid]); |
|
my %contents=&unpackagemsg($message{$msgid}); |
my $status='rec: '. |
my $status='rec: '. |
&user_normal_msg($contents{'sendername'},$contents{'senderdomain'}, |
&user_normal_msg($contents{'sendername'},$contents{'senderdomain'}, |
'Receipt: '.$ENV{'user.name'}.' at '.$ENV{'user.domain'}, |
'Receipt: '.$ENV{'user.name'}.' at '.$ENV{'user.domain'}, |
Line 151 sub user_crit_received {
|
Line 154 sub user_crit_received {
|
$contents{'subject'}.'" dated '.$contents{'time'}.".\n\n" |
$contents{'subject'}.'" dated '.$contents{'time'}.".\n\n" |
.'Message ID: '.$contents{'msgid'}); |
.'Message ID: '.$contents{'msgid'}); |
$status.=' trans: '. |
$status.=' trans: '. |
&Apache::lonnet::put('nohist_email',$contents{'msgid'} => $message); |
&Apache::lonnet::put( |
|
'nohist_email',{$contents{'msgid'} => $message{$msgid}}); |
$status.=' del: '. |
$status.=' del: '. |
&Apache::lonnet::del('critical',$contents{'msgid'}); |
&Apache::lonnet::del('critical',[$contents{'msgid'}]); |
&Apache::lonnet::log($ENV{'user.domain'},$ENV{'user.name'}, |
&Apache::lonnet::log($ENV{'user.domain'},$ENV{'user.name'}, |
$ENV{'user.home'},'Received critical message '. |
$ENV{'user.home'},'Received critical message '. |
$contents{'msgid'}. |
$contents{'msgid'}. |
', '.$status); |
', '.$status); |
|
return $status; |
} |
} |
|
|
# ======================================================== Normal communication |
# ======================================================== Normal communication |
Line 189 sub user_normal_msg {
|
Line 194 sub user_normal_msg {
|
|
|
sub statuschange { |
sub statuschange { |
my ($msgid,$newstatus)=@_; |
my ($msgid,$newstatus)=@_; |
my %status=&Apache::lonnet::get('email_status',$msgid); |
my %status=&Apache::lonnet::get('email_status',[$msgid]); |
if ($status{$msgid}=~/^error\:/) { $status{$msgid}=''; } |
if ($status{$msgid}=~/^error\:/) { $status{$msgid}=''; } |
unless ($status{$msgid}) { $status{$msgid}='new'; } |
unless ($status{$msgid}) { $status{$msgid}='new'; } |
unless (($status{$msgid} eq 'replied') || |
unless (($status{$msgid} eq 'replied') || |
($status{$msgid} eq 'forwarded')) { |
($status{$msgid} eq 'forwarded')) { |
&Apache::lonnet::put('email_status',($msgid => $newstatus)); |
&Apache::lonnet::put('email_status',{$msgid => $newstatus}); |
} |
} |
|
if (($newstatus eq 'deleted') || ($newstatus eq 'new')) { |
|
&Apache::lonnet::put('email_status',{$msgid => $newstatus}); |
|
} |
|
} |
|
|
|
# ==================================================== Display Critical Message |
|
|
|
sub discrit { |
|
my $r=shift; |
|
$r->print('<h1><font color=red>Critical Messages</font></h1>'. |
|
'<form action=/adm/email method=post>'. |
|
'<input type=hidden name=confirm value=true>'); |
|
my %what=&Apache::lonnet::dump('critical'); |
|
map { |
|
my %content=&unpackagemsg($what{$_}); |
|
$content{'message'}=~s/\n/\<br\>/g; |
|
$r->print('<hr>From: <b>'.$content{'sendername'}.'@'. |
|
$content{'senderdomain'}.'</b> ('.$content{'time'}. |
|
')<br><blockquote>'.$content{'message'}.'</blockquote>'. |
|
'<input type=submit name="rec_'.$_.'" value="Confirm Receipt">'. |
|
'<input type=submit name="reprec_'.$_.'" value="Confirm Receipt and Reply">'); |
|
} sort keys %what; |
|
$r->print('</form>'); |
|
} |
|
|
|
# =============================================================== Compose reply |
|
|
|
sub comprep { |
|
my ($r,$msgid)=@_; |
|
my %message=&Apache::lonnet::get('nohist_email',[$msgid]); |
|
my %content=&unpackagemsg($message{$msgid}); |
|
my $quotemsg='> '.$content{'message'}; |
|
$quotemsg=~s/\r/\n/g; |
|
$quotemsg=~s/\f/\n/g; |
|
$quotemsg=~s/\n+/\n\> /g; |
|
my $subject='Re: '.$content{'subject'}; |
|
my $dispcrit=''; |
|
if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) { |
|
$dispcrit= |
|
'<input type=checkbox name=critmsg> Send as critical message<p>'; |
|
} |
|
$r->print(<<"ENDREPLY"); |
|
<form action="/adm/email" method=post> |
|
<input type=hidden name=sendreply value="$msgid"> |
|
Subject: <input type=text size=50 name=subject value="$subject"><p> |
|
<textarea name=message cols=60 rows=10> |
|
$quotemsg |
|
</textarea><p> |
|
$dispcrit |
|
<input type=submit value="Send Reply"> |
|
</form> |
|
ENDREPLY |
} |
} |
|
|
|
sub disall { |
|
my $r=shift; |
|
$r->print('<h1>Display All Messages</h1>'. |
|
'<table border=2><tr><th colspan=2> </th><th>Date</th>'. |
|
'<th>Username</th><th>Domain</th><th>Subject</th><th>Status</th></tr>'); |
|
map { |
|
my ($sendtime,$shortsubj,$fromname,$fromdomain,$status)= |
|
&Apache::lonmsg::unpackmsgid($_); |
|
unless ($status eq 'deleted') { |
|
if ($status eq 'new') { |
|
$r->print('<tr bgcolor="#FFBB77">'); |
|
} elsif ($status eq 'read') { |
|
$r->print('<tr bgcolor="#BBBB77">'); |
|
} elsif ($status eq 'replied') { |
|
$r->print('<tr bgcolor="#AAAA88">'); |
|
} else { |
|
$r->print('<tr bgcolor="#99BBBB">'); |
|
} |
|
$r->print('<td><a href="/adm/email?display='.$_. |
|
'">Open</a></td><td><a href="/adm/email?markdel='.$_. |
|
'">Delete</a></td><td>'.localtime($sendtime).'</td><td>'. |
|
$fromname.'</td><td>'.$fromdomain.'</td><td>'. |
|
&Apache::lonnet::unescape($shortsubj).'</td><td>'. |
|
$status.'</td></tr>'); |
|
} |
|
} sort split(/\&/,&Apache::lonnet::reply('keys:'. |
|
$ENV{'user.domain'}.':'. |
|
$ENV{'user.name'}.':nohist_email', |
|
$ENV{'user.home'})); |
|
$r->print('</table></body></html>'); |
|
} |
|
|
# ===================================================================== Handler |
# ===================================================================== Handler |
|
|
sub handler { |
sub handler { |
Line 216 sub handler {
|
Line 306 sub handler {
|
$value =~ tr/+/ /; |
$value =~ tr/+/ /; |
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; |
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; |
if (($name eq 'display') || ($name eq 'replyto') || |
if (($name eq 'display') || ($name eq 'replyto') || |
($name eq 'forward') || ($name eq 'mark') || |
($name eq 'forward') || ($name eq 'markread') || |
($name eq 'sendreply')) { |
($name eq 'markdel') || ($name eq 'markunread') || |
|
($name eq 'sendreply') || ($name eq 'compose') || |
|
($name eq 'sendmail') || ($name eq 'critical')) { |
unless ($ENV{'form.'.$name}) { |
unless ($ENV{'form.'.$name}) { |
$ENV{'form.'.$name}=$value; |
$ENV{'form.'.$name}=$value; |
} |
} |
Line 233 sub handler {
|
Line 325 sub handler {
|
if ($ENV{'form.display'}) { |
if ($ENV{'form.display'}) { |
my $msgid=$ENV{'form.display'}; |
my $msgid=$ENV{'form.display'}; |
&statuschange($msgid,'read'); |
&statuschange($msgid,'read'); |
my %message=&Apache::lonnet::get('nohist_email',$msgid); |
my %message=&Apache::lonnet::get('nohist_email',[$msgid]); |
my %content=&unpackagemsg($message{$msgid}); |
my %content=&unpackagemsg($message{$msgid}); |
$r->print('<b>Subject:</b> '.$content{'subject'}. |
$r->print('<b>Subject:</b> '.$content{'subject'}. |
'<br><b>From:</b> '.$content{'sendername'}.' at '. |
'<br><b>From:</b> '.$content{'sendername'}.' at '. |
$content{'senderdomain'}. |
$content{'senderdomain'}. |
'<br><b>Time:</b> '.$content{'time'}.'<hr>Functions: '. |
'<br><b>Time:</b> '.$content{'time'}.'<p>'. |
'<a href="/adm/email?replyto='.&Apache::lonnet::escape($msgid). |
'<table border=2><tr bgcolor="#FFFFAA"><td>Functions:</td>'. |
'"><b>Reply</b></a><hr><pre>'. |
'<td><a href="/adm/email?replyto='.&Apache::lonnet::escape($msgid). |
|
'"><b>Reply</b></a></td>'. |
|
'<td><a href="/adm/email?replyto='.&Apache::lonnet::escape($msgid). |
|
'"><b>Forward</b></a></td>'. |
|
'</tr></table><p><pre>'. |
$content{'message'}.'</pre><hr>'.$content{'citation'}); |
$content{'message'}.'</pre><hr>'.$content{'citation'}); |
} elsif ($ENV{'form.replyto'}) { |
} elsif ($ENV{'form.replyto'}) { |
my $msgid=$ENV{'form.replyto'}; |
&comprep($r,$ENV{'form.replyto'}); |
my %message=&Apache::lonnet::get('nohist_email',$msgid); |
|
my %content=&unpackagemsg($message{$msgid}); |
|
my $quotemsg='> '.$content{'message'}; |
|
$quotemsg=~s/\r/\n/g; |
|
$quotemsg=~s/\f/\n/g; |
|
$quotemsg=~s/\n+/\n\> /g; |
|
my $subject='Re: '.$content{'subject'}; |
|
$r->print(<<"ENDREPLY"); |
|
<form action="/adm/email" method=post> |
|
<input type=hidden name=sendreply value="$msgid"> |
|
Subject: <input type=text size=50 name=subject value="$subject"><p> |
|
<textarea name=message cols=60 rows=10> |
|
$quotemsg |
|
</textarea><p> |
|
<input type=submit value="Send Reply"> |
|
</form> |
|
ENDREPLY |
|
} elsif ($ENV{'form.sendreply'}) { |
} elsif ($ENV{'form.sendreply'}) { |
my $msgid=$ENV{'form.sendreply'}; |
my $msgid=$ENV{'form.sendreply'}; |
my %message=&Apache::lonnet::get('nohist_email',$msgid); |
my %message=&Apache::lonnet::get('nohist_email',[$msgid]); |
my %content=&unpackagemsg($message{$msgid}); |
my %content=&unpackagemsg($message{$msgid}); |
&statuschange($msgid,'replied'); |
&statuschange($msgid,'replied'); |
$r->print('Sending: '.&user_normal_msg($content{'sendername'}, |
if (($ENV{'form.critmsg'}) && |
|
(&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) { |
|
$r->print('Sending critical: '. |
|
&user_crit_msg($content{'sendername'}, |
$content{'senderdomain'}, |
$content{'senderdomain'}, |
$ENV{'form.subject'}, |
$ENV{'form.subject'}, |
$ENV{'form.message'})); |
$ENV{'form.message'})); |
|
} else { |
|
$r->print('Sending: '.&user_normal_msg($content{'sendername'}, |
|
$content{'senderdomain'}, |
|
$ENV{'form.subject'}, |
|
$ENV{'form.message'})); |
|
} |
|
if ($ENV{'form.displayedcrit'}) { |
|
&discrit($r); |
|
} else { |
|
&disall($r); |
|
} |
|
} elsif ($ENV{'form.confirm'}) { |
|
map { |
|
if ($_=~/^form\.rec\_(.*)$/) { |
|
$r->print('<b>Confirming Receipt:</b> '. |
|
&user_crit_received($1).'<br>'); |
|
} |
|
if ($_=~/^form\.reprec\_(.*)$/) { |
|
my $msgid=$1; |
|
$r->print('<b>Confirming Receipt:</b> '. |
|
&user_crit_received($msgid).'<br>'); |
|
&comprep($r,$msgid); |
|
} |
|
} keys %ENV; |
|
&discrit($r); |
|
} elsif ($ENV{'form.critical'}) { |
|
&discrit($r); |
} elsif ($ENV{'form.forward'}) { |
} elsif ($ENV{'form.forward'}) { |
} elsif ($ENV{'form.mark'}) { |
} elsif ($ENV{'form.markread'}) { |
|
} elsif ($ENV{'form.markdel'}) { |
|
&statuschange($ENV{'form.markdel'},'deleted'); |
|
&disall($r); |
|
} elsif ($ENV{'form.markunread'}) { |
|
} elsif ($ENV{'form.compose'}) { |
|
my $dispcrit=''; |
|
if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) { |
|
$dispcrit= |
|
'<input type=checkbox name=critmsg> Send as critical message<p>'; |
|
} |
|
$r->print(<<"ENDCOMP"); |
|
<form action="/adm/email" method=post> |
|
<input type=hidden name=sendmail value=on> |
|
Subject: <input type=text size=50 name=subject value=""><p> |
|
<textarea name=message cols=60 rows=10> |
|
</textarea><p> |
|
$dispcrit |
|
<input type=submit value="Send Mail"> |
|
</form> |
|
ENDCOMP |
|
} elsif ($ENV{'form.sendmail'}) { |
} else { |
} else { |
$r->print('<table border=2><tr><th> </th><th>Date</th>'. |
&disall($r); |
'<th>Username</th><th>Domain</th><th>Subject</th><th>Status</th></tr>'); |
|
map { |
|
my ($sendtime,$shortsubj,$fromname,$fromdomain,$status)= |
|
&Apache::lonmsg::unpackmsgid($_); |
|
if ($status eq 'new') { |
|
$r->print('<tr bgcolor="#FFBB77">'); |
|
} elsif ($status eq 'read') { |
|
$r->print('<tr bgcolor="#BBBB77">'); |
|
} elsif ($status eq 'replied') { |
|
$r->print('<tr bgcolor="#AAAA88">'); |
|
} else { |
|
$r->print('<tr bgcolor="#99BBBB">'); |
|
} |
|
$r->print('<td><a href="/adm/email?display='.$_. |
|
'">Open</a></td><td>'.localtime($sendtime).'</td><td>'. |
|
$fromname.'</td><td>'.$fromdomain.'</td><td>'. |
|
&Apache::lonnet::unescape($shortsubj).'</td><td>'. |
|
$status.'</td></tr>'); |
|
} sort split(/\&/,&Apache::lonnet::reply('keys:'. |
|
$ENV{'user.domain'}.':'. |
|
$ENV{'user.name'}.':nohist_email', |
|
$ENV{'user.home'})); |
|
$r->print('</table></body></html>'); |
|
|
|
} |
} |
$r->print('</body></html>'); |
$r->print('</body></html>'); |
return OK; |
return OK; |