--- loncom/interface/lonmsg.pm 2003/08/13 15:57:51 1.61
+++ loncom/interface/lonmsg.pm 2004/09/28 14:12:40 1.109
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging
#
-# $Id: lonmsg.pm,v 1.61 2003/08/13 15:57:51 www Exp $
+# $Id: lonmsg.pm,v 1.109 2004/09/28 14:12:40 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
@@ -89,6 +74,18 @@ email program, so they have full access
interface, or other features they may wish to use in response to the
student's query.
+=item * B: LON-CAPA can block display of e-mails that are
+sent to a student during an online exam. A course coordinator or
+instructor can set an open and close date/time for scheduled online
+exams in a course. If a user uses the LON-CAPA internal messaging
+system to display e-mails during the scheduled blocking event,
+display of all e-mail sent during the blocking period will be
+suppressed, and a message of explanation, including details of the
+currently active blocking periods will be displayed instead. A user
+who has a course coordinator or instructor role in a course will be
+unaffected by any blocking periods for the course, unless the user
+also has a student role in the course, AND has selected the student role.
+
=back
Users can ask LON-CAPA to forward messages to conventional e-mail
@@ -115,20 +112,28 @@ use Apache::loncommon();
use Apache::lontexconvert();
use HTML::Entities();
use Mail::Send;
+use Apache::lonlocal;
+use Apache::loncommunicate;
+
+# Querystring component with sorting type
+my $sqs;
+my $startdis;
+my $interdis;
# ===================================================================== Package
sub packagemsg {
- my ($subject,$message,$citation,$baseurl,$attachmenturl)=@_;
- $message =&HTML::Entities::encode($message);
- $citation=&HTML::Entities::encode($citation);
- $subject =&HTML::Entities::encode($subject);
+ my ($subject,$message,$citation,$baseurl,$attachmenturl,
+ $recuser,$recdomain)=@_;
+ $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++;
@@ -140,7 +145,7 @@ sub packagemsg {
my $result=''.$ENV{'user.name'}.''.
''.$ENV{'user.domain'}.''.
''.$subject.''.
- ''.
+ ''.
''.$ENV{'SERVER_NAME'}.''.
''.$ENV{'HTTP_HOST'}.''.
''.$ENV{'REMOTE_ADDR'}.''.
@@ -150,9 +155,12 @@ sub packagemsg {
''.$ENV{'browser.mathml'}.''.
''.$ENV{'HTTP_USER_AGENT'}.''.
''.$ENV{'request.course.id'}.''.
+ ''.$ENV{'request.course.sec'}.''.
''.$ENV{'request.role'}.''.
''.$ENV{'request.filename'}.''.
''.$msgid.''.
+ ''.$recuser.''.
+ ''.$recdomain.''.
''.$message.'';
if (defined($citation)) {
$result.=''.$citation.'';
@@ -181,13 +189,15 @@ sub unpackagemsg {
}
}
if ($content{'attachmenturl'}) {
- my ($fname,$ft)=($content{'attachmenturl'}=~/\/(\w+)\.(\w+)$/);
+ my ($fname)=($content{'attachmenturl'}=~m|/([^/]+)$|);
if ($notoken) {
- $content{'message'}.='
'.&mt('Attachment').
+ ': '.
+ $fname.'';
}
}
return %content;
@@ -196,10 +206,12 @@ sub unpackagemsg {
# ======================================================= Get info out of msgid
sub unpackmsgid {
- my $msgid=&Apache::lonnet::unescape(shift);
+ my ($msgid,$folder)=@_;
+ $msgid=&Apache::lonnet::unescape($msgid);
+ my $suffix=&foldersuffix($folder);
my ($sendtime,$shortsubj,$fromname,$fromdomain)=split(/\:/,
&Apache::lonnet::unescape($msgid));
- my %status=&Apache::lonnet::get('email_status',[$msgid]);
+ my %status=&Apache::lonnet::get('email_status'.$suffix,[$msgid]);
if ($status{$msgid}=~/^error\:/) { $status{$msgid}=''; }
unless ($status{$msgid}) { $status{$msgid}='new'; }
return ($sendtime,$shortsubj,$fromname,$fromdomain,$status{$msgid});
@@ -209,14 +221,19 @@ sub unpackmsgid {
sub sendemail {
my ($to,$subject,$body)=@_;
$body=
- "*** This is an automatic message generated by the LON-CAPA system.\n".
- "*** Please do not reply to this address.\n\n".$body;
+ "*** ".&mt('This is an automatic message generated by the LON-CAPA system.')."\n".
+ "*** ".&mt('Please do not reply to this address.')."\n\n".$body;
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;
+ my %oldENV=%ENV;
+ undef(%ENV);
+ if (my $fh = $msg->open()) {
+ print $fh $body;
+ $fh->close;
+ }
+ %ENV=%oldENV;
+ undef(%oldENV);
}
# ==================================================== Send notification emails
@@ -279,6 +296,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.='