--- loncom/interface/lonmsg.pm 2002/12/27 16:33:36 1.45
+++ loncom/interface/lonmsg.pm 2003/04/02 00:50:46 1.53
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging
#
-# $Id: lonmsg.pm,v 1.45 2002/12/27 16:33:36 www Exp $
+# $Id: lonmsg.pm,v 1.53 2003/04/02 00:50:46 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -47,21 +47,27 @@ package Apache::lonmsg;
use strict;
use Apache::lonnet();
use vars qw($msgcount);
-use HTML::TokeParser;
+use HTML::TokeParser();
use Apache::Constants qw(:common);
-use Apache::loncommon;
-use Apache::lontexconvert;
+use Apache::loncommon();
+use Apache::lontexconvert();
+use HTML::Entities();
+use Mail::Send;
# ===================================================================== Package
sub packagemsg {
- my ($subject,$message,$citation)=@_;
- $message=~s/\\<\;/g;
- $message=~s/\>/\>\;/g;
- $citation=~s/\\<\;/g;
- $citation=~s/\>/\>\;/g;
- $subject=~s/\\<\;/g;
- $subject=~s/\>/\>\;/g;
+ my ($subject,$message,$citation,$baseurl,$attachmenturl)=@_;
+ $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);
+ #remove machine specification
+ $attachmenturl =~ s|^http://[^/]+/|/|;
+ $attachmenturl =&HTML::Entities::encode($attachmenturl);
+
my $now=time;
$msgcount++;
my $partsubj=$subject;
@@ -69,8 +75,7 @@ sub packagemsg {
my $msgid=&Apache::lonnet::escape(
$now.':'.$partsubj.':'.$ENV{'user.name'}.':'.
$ENV{'user.domain'}.':'.$msgcount.':'.$$);
- return $msgid,
- '
Attachment: '.$fname.'.'.$ft.''; + } else { + $content{'message'}.='
Attachment: '.$fname.'.'.$ft.'';
+ }
+ }
return %content;
}
@@ -119,6 +143,42 @@ sub unpackmsgid {
return ($sendtime,$shortsubj,$fromname,$fromdomain,$status{$msgid});
}
+
+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;
+ 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;
+}
+
+# ==================================================== Send notification emails
+
+sub sendnotification {
+ my ($to,$touname,$toudom,$subj,$crit)=@_;
+ my $sender=$ENV{'environment.firstname'}.' '.$ENV{'environment.lastname'};
+ my $critical=($crit?' critical':'');
+ my $url='http://'.
+ $Apache::lonnet::hostname{&Apache::lonnet::homeserver($touname,$toudom)}.
+ '/adm/login&username='.$touname.'&domain='.$toudom;
+ my $body=(< No face-to-face records or critical messages in this course. No notes, face-to-face discussion records, or critical messages in this course.');
unless (($broadcast eq 'group') || ($broadcast eq 'upload')) {
my $domform = &Apache::loncommon::select_dom_form($defdom,'recdomain');
-
+ my $selectlink=&Apache::loncommon::selectstudent_link
+ ('compemail','recuname','recdomain');
$r->print(<<"ENDREC");
-
+Username: Username: $selectlink
ENDREC
@@ -623,7 +698,7 @@ $content{'sendername'}.'@'.
}
# Check to see if there were any messages.
if ($result eq '') {
- $r->print("Domain:
$domform User Records of Face-To-Face Discussions and Critical Messages in Course
-