version 1.20, 2001/08/13 19:36:39
|
version 1.26, 2001/12/19 17:17:46
|
Line 1
|
Line 1
|
# The LearningOnline Network with CAPA |
# The LearningOnline Network with CAPA |
# |
|
# Routines for messaging |
# Routines for messaging |
# |
# |
|
# $Id$ |
|
# |
|
# Copyright Michigan State University Board of Trustees |
|
# |
|
# This file is part of the LearningOnline Network with CAPA (LON-CAPA). |
|
# |
|
# LON-CAPA is free software; you can redistribute it and/or modify |
|
# it under the terms of the GNU General Public License as published by |
|
# the Free Software Foundation; either version 2 of the License, or |
|
# (at your option) any later version. |
|
# |
|
# LON-CAPA is distributed in the hope that it will be useful, |
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
# GNU General Public License for more details. |
|
# |
|
# You should have received a copy of the GNU General Public License |
|
# along with LON-CAPA; if not, write to the Free Software |
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
# |
|
# /home/httpd/html/adm/gpl.txt |
|
# |
|
# http://www.lon-capa.org/ |
|
# |
|
# |
# (Routines to control the menu |
# (Routines to control the menu |
# |
# |
# (TeX Conversion Module |
# (TeX Conversion Module |
Line 13
|
Line 37
|
# 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 Guy Albertelli |
# 07/27,07/28,07/30,08/03,08/06,08/08,08/09,08/10,8/13 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; |
package Apache::lonmsg; |
|
|
Line 114 sub author_res_msg {
|
Line 139 sub author_res_msg {
|
# ================================================== Critical message to a user |
# ================================================== Critical message to a user |
|
|
sub user_crit_msg { |
sub user_crit_msg { |
my ($user,$domain,$subject,$message)=@_; |
my ($user,$domain,$subject,$message,$sendback)=@_; |
# Check if allowed missing |
# Check if allowed missing |
my $status=''; |
my $status=''; |
my $msgid='undefined'; |
my $msgid='undefined'; |
unless (($message)&&($user)&&($domain)) { $status='empty'; }; |
unless (($message)&&($user)&&($domain)) { $status='empty'; }; |
my $homeserver=&Apache::lonnet::homeserver($user,$domain); |
my $homeserver=&Apache::lonnet::homeserver($user,$domain); |
if ($homeserver ne 'no_host') { |
if ($homeserver ne 'no_host') { |
my $msgid; |
|
($msgid,$message)=&packagemsg($subject,$message); |
($msgid,$message)=&packagemsg($subject,$message); |
|
if ($sendback) { $message.='<sendback>true</sendback>'; } |
$status=&Apache::lonnet::critical( |
$status=&Apache::lonnet::critical( |
'put:'.$domain.':'.$user.':critical:'. |
'put:'.$domain.':'.$user.':critical:'. |
&Apache::lonnet::escape($msgid).'='. |
&Apache::lonnet::escape($msgid).'='. |
Line 146 sub user_crit_received {
|
Line 171 sub user_crit_received {
|
my $msgid=shift; |
my $msgid=shift; |
my %message=&Apache::lonnet::get('critical',[$msgid]); |
my %message=&Apache::lonnet::get('critical',[$msgid]); |
my %contents=&unpackagemsg($message{$msgid}); |
my %contents=&unpackagemsg($message{$msgid}); |
my $status='rec: '. |
my $status='rec: '.($contents{'sendback'}? |
&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'}, |
'User '.$ENV{'user.name'}.' at '.$ENV{'user.domain'}. |
'User '.$ENV{'user.name'}.' at '.$ENV{'user.domain'}. |
' acknowledged receipt of message "'. |
' acknowledged receipt of message "'. |
$contents{'subject'}.'" dated '.$contents{'time'}.".\n\n" |
$contents{'subject'}.'" dated '.$contents{'time'}.".\n\n" |
.'Message ID: '.$contents{'msgid'}); |
.'Message ID: '.$contents{'msgid'}):'no msg req'); |
$status.=' trans: '. |
$status.=' trans: '. |
&Apache::lonnet::put( |
&Apache::lonnet::put( |
'nohist_email',{$contents{'msgid'} => $message{$msgid}}); |
'nohist_email',{$contents{'msgid'} => $message{$msgid}}); |
Line 175 sub user_normal_msg {
|
Line 200 sub user_normal_msg {
|
unless (($message)&&($user)&&($domain)) { $status='empty'; }; |
unless (($message)&&($user)&&($domain)) { $status='empty'; }; |
my $homeserver=&Apache::lonnet::homeserver($user,$domain); |
my $homeserver=&Apache::lonnet::homeserver($user,$domain); |
if ($homeserver ne 'no_host') { |
if ($homeserver ne 'no_host') { |
my $msgid; |
|
($msgid,$message)=&packagemsg($subject,$message,$citation); |
($msgid,$message)=&packagemsg($subject,$message,$citation); |
$status=&Apache::lonnet::critical( |
$status=&Apache::lonnet::critical( |
'put:'.$domain.':'.$user.':nohist_email:'. |
'put:'.$domain.':'.$user.':nohist_email:'. |
Line 309 sub comprep {
|
Line 333 sub comprep {
|
my $dispcrit=''; |
my $dispcrit=''; |
if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) { |
if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) { |
$dispcrit= |
$dispcrit= |
'<input type=checkbox name=critmsg> Send as critical message<p>'; |
'<input type=checkbox name=critmsg> Send as critical message<br>'. |
|
'<input type=checkbox name=sendbck> Send as critical message'. |
|
' and return receipt<p>'; |
} |
} |
$r->print(<<"ENDREPLY"); |
$r->print(<<"ENDREPLY"); |
<form action="/adm/email" method=post> |
<form action="/adm/email" method=post> |
<input type=hidden name=sendreply value="$msgid"> |
<input type=hidden name=sendreply value="$msgid"> |
Subject: <input type=text size=50 name=subject value="$subject"><p> |
Subject: <input type=text size=50 name=subject value="$subject"><p> |
<textarea name=message cols=60 rows=10> |
<textarea name=message cols=64 rows=10 wrap=hard> |
$quotemsg |
$quotemsg |
</textarea><p> |
</textarea><p> |
$dispcrit |
$dispcrit |
Line 328 ENDREPLY
|
Line 354 ENDREPLY
|
|
|
sub disall { |
sub disall { |
my $r=shift; |
my $r=shift; |
$r->print('<h1>Display All Messages</h1>'. |
$r->print( |
|
'<h1>Display All Messages</h1><form method=post action="/adm/email">'. |
'<table border=2><tr><th colspan=2> </th><th>Date</th>'. |
'<table border=2><tr><th colspan=2> </th><th>Date</th>'. |
'<th>Username</th><th>Domain</th><th>Subject</th><th>Status</th></tr>'); |
'<th>Username</th><th>Domain</th><th>Subject</th><th>Status</th></tr>'); |
map { |
map { |
Line 346 sub disall {
|
Line 373 sub disall {
|
} |
} |
$r->print('<td><a href="/adm/email?display='.$_. |
$r->print('<td><a href="/adm/email?display='.$_. |
'">Open</a></td><td><a href="/adm/email?markdel='.$_. |
'">Open</a></td><td><a href="/adm/email?markdel='.$_. |
'">Delete</a></td><td>'.localtime($sendtime).'</td><td>'. |
'">Delete</a><input type=checkbox name="delmark_'.$_.'"></td>'. |
|
'<td>'.localtime($sendtime).'</td><td>'. |
$fromname.'</td><td>'.$fromdomain.'</td><td>'. |
$fromname.'</td><td>'.$fromdomain.'</td><td>'. |
&Apache::lonnet::unescape($shortsubj).'</td><td>'. |
&Apache::lonnet::unescape($shortsubj).'</td><td>'. |
$status.'</td></tr>'); |
$status.'</td></tr>'); |
Line 355 sub disall {
|
Line 383 sub disall {
|
$ENV{'user.domain'}.':'. |
$ENV{'user.domain'}.':'. |
$ENV{'user.name'}.':nohist_email', |
$ENV{'user.name'}.':nohist_email', |
$ENV{'user.home'})); |
$ENV{'user.home'})); |
$r->print('</table></body></html>'); |
$r->print('</table><p>'. |
|
'<input type=submit name="markeddel" value="Delete Checked">'. |
|
'</form></body></html>'); |
} |
} |
|
|
# ============================================================== Compose output |
# ============================================================== Compose output |
Line 368 sub compout {
|
Line 398 sub compout {
|
my $func='Send New'; |
my $func='Send New'; |
if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) { |
if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) { |
$dispcrit= |
$dispcrit= |
'<input type=checkbox name=critmsg> Send as critical message<p>'; |
'<input type=checkbox name=critmsg> Send as critical message<br>'. |
|
'<input type=checkbox name=sendbck> Send as critical message'. |
|
' and return receipt<p>'; |
} |
} |
if ($forwarding) { |
if ($forwarding) { |
$dispcrit.='<input type=hidden name=forwid value="'. |
$dispcrit.='<input type=hidden name=forwid value="'. |
Line 382 sub compout {
|
Line 414 sub compout {
|
$content{'sendername'}.' at '.$content{'senderdomain'}; |
$content{'sendername'}.' at '.$content{'senderdomain'}; |
} |
} |
my $defdom=$ENV{'user.domain'}; |
my $defdom=$ENV{'user.domain'}; |
$r->print('<form action="/adm/email" name="compemail" method=post>'. |
$r->print( |
|
'<form action="/adm/email" name="compemail" method=post'. |
|
' enctype="multipart/form-data">'. |
'<input type=hidden name=sendmail value=on><table>'); |
'<input type=hidden name=sendmail value=on><table>'); |
unless ($broadcast eq 'group') { |
unless (($broadcast eq 'group') || ($broadcast eq 'upload')) { |
$r->print(<<"ENDREC"); |
$r->print(<<"ENDREC"); |
<table> |
<table> |
<tr><td>Username:</td><td><input type=text size=12 name=recuname></td></tr> |
<tr><td>Username:</td><td><input type=text size=12 name=recuname></td></tr> |
Line 392 sub compout {
|
Line 426 sub compout {
|
<td><input type=text size=12 name=recdomain value="$defdom"></td></tr> |
<td><input type=text size=12 name=recdomain value="$defdom"></td></tr> |
ENDREC |
ENDREC |
} |
} |
$r->print(<<"ENDCOMP"); |
unless ($broadcast eq 'upload') { |
|
$r->print(<<"ENDCOMP"); |
<tr><td>Additional Recipients<br><tt>username\@domain,username\@domain, ... |
<tr><td>Additional Recipients<br><tt>username\@domain,username\@domain, ... |
</tt></td><td> |
</tt></td><td> |
<input type=text size=50 name=additionalrec></td></tr> |
<input type=text size=50 name=additionalrec></td></tr> |
<tr><td>Subject:</td><td><input type=text size=50 name=subject value="$dissub"> |
<tr><td>Subject:</td><td><input type=text size=50 name=subject value="$dissub"> |
</td></tr></table> |
</td></tr></table> |
<textarea name=message cols=60 rows=10>$dismsg |
<textarea name=message cols=60 rows=10 wrap=hard>$dismsg |
</textarea><p> |
</textarea><p> |
$dispcrit |
$dispcrit |
<input type=submit value="$func Mail"> |
<input type=submit value="$func Mail"> |
ENDCOMP |
ENDCOMP |
|
} |
|
if ($broadcast eq 'upload') { |
|
$r->print(<<ENDUPLOAD); |
|
<input type=hidden name=sendmode value=upload> |
|
<h3>Generate messages from a file</h3> |
|
Subject: <input type=text size=50 name=subject> |
|
<pre> |
|
username1\@domain1: text |
|
username2\@domain2: text |
|
username1\@domain1: text |
|
</pre> |
|
The messages will be assembled from all lines with the respective |
|
<tt>username\@domain</tt>, and appended to the general message text.<p> |
|
<input type=file name=upfile size=20><p> |
|
General message text:<p> |
|
<textarea name=message cols=60 rows=10 wrap=hard>$dismsg |
|
</textarea><p> |
|
$dispcrit |
|
<input type=submit value="Upload and send"> |
|
ENDUPLOAD |
|
} |
if ($broadcast eq 'group') { |
if ($broadcast eq 'group') { |
&discourse; |
&discourse; |
} |
} |
Line 470 sub handler {
|
Line 526 sub handler {
|
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'); |
if (($ENV{'form.critmsg'}) && |
if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) && |
(&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) { |
(&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) { |
$r->print('Sending critical: '. |
$r->print('Sending critical: '. |
&user_crit_msg($content{'sendername'}, |
&user_crit_msg($content{'sendername'}, |
$content{'senderdomain'}, |
$content{'senderdomain'}, |
$ENV{'form.subject'}, |
$ENV{'form.subject'}, |
$ENV{'form.message'})); |
$ENV{'form.message'}, |
|
$ENV{'form.sendbck'})); |
} else { |
} else { |
$r->print('Sending: '.&user_normal_msg($content{'sendername'}, |
$r->print('Sending: '.&user_normal_msg($content{'sendername'}, |
$content{'senderdomain'}, |
$content{'senderdomain'}, |
Line 510 sub handler {
|
Line 567 sub handler {
|
} elsif ($ENV{'form.markdel'}) { |
} elsif ($ENV{'form.markdel'}) { |
&statuschange($ENV{'form.markdel'},'deleted'); |
&statuschange($ENV{'form.markdel'},'deleted'); |
&disall($r); |
&disall($r); |
|
} elsif ($ENV{'form.markeddel'}) { |
|
my $total=0; |
|
map { |
|
if ($_=~/^form\.delmark_(.*)$/) { |
|
&statuschange(&Apache::lonnet::unescape($1),'deleted'); |
|
$total++; |
|
} |
|
} keys %ENV; |
|
$r->print('Deleted '.$total.' message(s)<p>'); |
|
&disall($r); |
} elsif ($ENV{'form.markunread'}) { |
} elsif ($ENV{'form.markunread'}) { |
&statuschange($ENV{'form.markunread'},'new'); |
&statuschange($ENV{'form.markunread'},'new'); |
&disall($r); |
&disall($r); |
Line 531 sub handler {
|
Line 598 sub handler {
|
if ($ENV{'form.sendmode'} eq 'group') { |
if ($ENV{'form.sendmode'} eq 'group') { |
map { |
map { |
if ($_=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) { |
if ($_=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) { |
$toaddr{$1}=1; |
$toaddr{$1}=''; |
} |
} |
} keys %ENV; |
} 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 { |
} else { |
$toaddr{$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}}=1; |
$toaddr{$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}}=''; |
} |
} |
if ($ENV{'form.additionalrec'}) { |
if ($ENV{'form.additionalrec'}) { |
map { |
map { |
my ($auname,$audom)=split(/\@/,$_); |
my ($auname,$audom)=split(/\@/,$_); |
$toaddr{$auname.':'.$audom}=1; |
$toaddr{$auname.':'.$audom}=''; |
} split(/\,/,$ENV{'form.additionalrec'}); |
} split(/\,/,$ENV{'form.additionalrec'}); |
} |
} |
map { |
map { |
my ($recuname,$recdomain)=split(/\:/,$_); |
my ($recuname,$recdomain)=split(/\:/,$_); |
if (($ENV{'form.critmsg'}) && |
my $msgtxt=$ENV{'form.message'}; |
|
if ($toaddr{$_}) { $msgtxt.='<hr>'.$toaddr{$_}; } |
|
if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) && |
(&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) { |
(&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) { |
$r->print('Sending critical: '. |
$r->print('Sending critical: '. |
&user_crit_msg($recuname,$recdomain, |
&user_crit_msg($recuname,$recdomain, |
$ENV{'form.subject'}, |
$ENV{'form.subject'}, |
$ENV{'form.message'}, |
$msgtxt, |
$content{'citation'})); |
$ENV{'form.sendbck'})); |
} else { |
} else { |
$r->print('Sending: '.&user_normal_msg($recuname,$recdomain, |
$r->print('Sending: '.&user_normal_msg($recuname,$recdomain, |
$ENV{'form.subject'}, |
$ENV{'form.subject'}, |
$ENV{'form.message'}, |
$msgtxt, |
$content{'citation'})); |
$content{'citation'})); |
} |
} |
$r->print('<br>'); |
$r->print('<br>'); |