--- loncom/interface/lonmsg.pm 2003/10/15 18:01:10 1.67
+++ loncom/interface/lonmsg.pm 2004/04/06 15:56:37 1.97
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging
#
-# $Id: lonmsg.pm,v 1.67 2003/10/15 18:01:10 www Exp $
+# $Id: lonmsg.pm,v 1.97 2004/04/06 15:56:37 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,23 +25,8 @@
#
# http://www.lon-capa.org/
#
-#
-# (Routines to control the menu
-#
-# (TeX Conversion Module
-#
-# 05/29/00,05/30 Gerd Kortemeyer)
-#
-# 10/05 Gerd Kortemeyer)
-#
-# 10/19,10/20,10/30,
-# 02/06/01 Gerd Kortemeyer
-# 07/27 Guy Albertelli
-# 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
-# YEAR=2002
-# 1/1,3/18 Gerd Kortemeyer
-#
+
+
package Apache::lonmsg;
=pod
@@ -116,6 +101,7 @@ use Apache::lontexconvert();
use HTML::Entities();
use Mail::Send;
use Apache::lonlocal;
+use Apache::loncommunicate;
# Querystring component with sorting type
my $sqs;
@@ -124,15 +110,15 @@ my $sqs;
sub packagemsg {
my ($subject,$message,$citation,$baseurl,$attachmenturl)=@_;
- $message =&HTML::Entities::encode($message);
- $citation=&HTML::Entities::encode($citation);
- $subject =&HTML::Entities::encode($subject);
+ $message =&HTML::Entities::encode($message,'<>&"');
+ $citation=&HTML::Entities::encode($citation,'<>&"');
+ $subject =&HTML::Entities::encode($subject,'<>&"');
#remove machine specification
$baseurl =~ s|^http://[^/]+/|/|;
- $baseurl =&HTML::Entities::encode($baseurl);
+ $baseurl =&HTML::Entities::encode($baseurl,'<>&"');
#remove machine specification
$attachmenturl =~ s|^http://[^/]+/|/|;
- $attachmenturl =&HTML::Entities::encode($attachmenturl);
+ $attachmenturl =&HTML::Entities::encode($attachmenturl,'<>&"');
my $now=time;
$msgcount++;
@@ -154,6 +140,7 @@ sub packagemsg {
''.$ENV{'browser.mathml'}.' '.
''.$ENV{'HTTP_USER_AGENT'}.' '.
''.$ENV{'request.course.id'}.' '.
+ ''.$ENV{'request.course.sec'}.' '.
''.$ENV{'request.role'}.' '.
''.$ENV{'request.filename'}.' '.
''.$msgid.' '.
@@ -218,9 +205,10 @@ sub sendemail {
my $msg = new Mail::Send;
$msg->to($to);
$msg->subject('[LON-CAPA] '.$subject);
- my $fh = $msg->open('smtp',Server => 'localhost');
- print $fh $body;
- $fh->close;
+ if (my $fh = $msg->open()) {
+ print $fh $body;
+ $fh->close;
+ }
}
# ==================================================== Send notification emails
@@ -283,6 +271,53 @@ sub author_res_msg {
return 'no_host';
}
+# =========================================== Retrieve author resource messages
+
+sub retrieve_author_res_msg {
+ my $url=shift;
+ $url=&Apache::lonnet::declutter($url);
+ my ($domain,$author)=($url=~/^(\w+)\/(\w+)\//);
+ my %errormsgs=&Apache::lonnet::dump('nohist_res_msgs',$domain,$author);
+ my $msgs='';
+ foreach (keys %errormsgs) {
+ if ($_=~/^\Q$url\E\_\d+$/) {
+ my %content=&unpackagemsg($errormsgs{$_});
+ $msgs.='
'.
+ $content{'time'}.' : '.$content{'message'}.
+ '
';
+ }
+ }
+ return $msgs;
+}
+
+
+# =============================== Delete all author messages related to one URL
+
+sub del_url_author_res_msg {
+ my $url=shift;
+ $url=&Apache::lonnet::declutter($url);
+ my ($domain,$author)=($url=~/^(\w+)\/(\w+)\//);
+ my @delmsgs=();
+ foreach (&Apache::lonnet::getkeys('nohist_res_msgs',$domain,$author)) {
+ if ($_=~/^\Q$url\E\_\d+$/) {
+ push (@delmsgs,$_);
+ }
+ }
+ return &Apache::lonnet::del('nohist_res_msgs',\@delmsgs,$domain,$author);
+}
+
+# ================= Return hash with URLs for which there is a resource message
+
+sub all_url_author_res_msg {
+ my ($author,$domain)=@_;
+ my %returnhash=();
+ foreach (&Apache::lonnet::getkeys('nohist_res_msgs',$domain,$author)) {
+ $_=~/^(.+)\_\d+/;
+ $returnhash{$1}=1;
+ }
+ return %returnhash;
+}
+
# ================================================== Critical message to a user
sub user_crit_msg_raw {
@@ -363,7 +398,7 @@ sub user_crit_received {
my %contents=&unpackagemsg($message{$msgid},1);
my $status='rec: '.($contents{'sendback'}?
&user_normal_msg($contents{'sendername'},$contents{'senderdomain'},
- &mt('Receipt').': '.$ENV{'user.name'}.' at '.$ENV{'user.domain'},
+ &mt('Receipt').': '.$ENV{'user.name'}.' '.&mt('at').' '.$ENV{'user.domain'}.', '.$contents{'subject'},
&mt('User').' '.$ENV{'user.name'}.' '.&mt('at').' '.$ENV{'user.domain'}.
' acknowledged receipt of message'."\n".' "'.
$contents{'subject'}.'"'."\n".&mt('dated').' '.
@@ -474,7 +509,7 @@ sub discourse {
'cfs' => 'Check for Section/Group',
'cfn' => 'Check for None');
$r->print(<
+
-
-
-
-
+
+
+
+
ENDDISHEADER
my %coursepersonnel=
@@ -566,7 +601,9 @@ $content{'sendername'}.'@'.
' '.&mt('Subject').': '.$content{'subject'}.
'
'.
&Apache::lontexconvert::msgtexconverted($content{'message'}).
- ' '.
+ ''.
+&mt('You have to confirm that you received this message. After confirmation, this message will be moved to your regular inbox').
+ ' '.
' '.
' ';
@@ -582,44 +619,6 @@ $content{'sendername'}.'@'.
$r->print(' ');
}
-# =============================================================== Compose reply
-
-sub comprep {
- my ($r,$msgid)=@_;
- my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
- my %content=&unpackagemsg($message{$msgid},1);
- my $quotemsg='> '.$content{'message'};
- $quotemsg=~s/\r/\n/g;
- $quotemsg=~s/\f/\n/g;
- $quotemsg=~s/\n+/\n\> /g;
- my $torepl=&Apache::loncommon::aboutmewrapper(
- &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).' ('.
-$content{'sendername'}.'@'.
- $content{'senderdomain'}.')';
- my $subject=&mt('Re').': '.$content{'subject'};
- my $dispcrit='';
- if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
- my $crithelp = Apache::loncommon::help_open_topic("Course_Critical_Message");
- $dispcrit=
- ' '.&mt('Send as critical message').' ' . $crithelp .
- ' '.
- ' '.&mt('Send as critical message').' ' .
- &mt('and return receipt') . $crithelp . '';
- }
- $r->print(<<"ENDREPLY");
-
-ENDREPLY
-}
-
sub sortedmessages {
my @messages = &Apache::lonnet::getkeys('nohist_email');
#unpack the varibles and repack into temp for sorting
@@ -740,7 +739,7 @@ ENDDISHEADER
}
$r->print(''.&mt('Open').' '.&mt('Delete').' '.
+ '">'.&mt('Delete').' '.
''.&Apache::lonlocal::locallocaltime($sendtime).' '.
$fromname.' '.$fromdomain.' '.
&Apache::lonnet::unescape($shortsubj).' '.
@@ -751,78 +750,139 @@ ENDDISHEADER
''.&mt('Check All').' '.
''.&mt('Uncheck All').' '.
' '.
- ' '.
+ ' '.
'