--- loncom/interface/lonmsg.pm 2002/06/26 20:41:55 1.34
+++ loncom/interface/lonmsg.pm 2002/12/27 14:59:42 1.44
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging
#
-# $Id: lonmsg.pm,v 1.34 2002/06/26 20:41:55 www Exp $
+# $Id: lonmsg.pm,v 1.44 2002/12/27 14:59:42 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -49,6 +49,8 @@ use Apache::lonnet();
use vars qw($msgcount);
use HTML::TokeParser;
use Apache::Constants qw(:common);
+use Apache::loncommon;
+use Apache::lontexconvert;
# ===================================================================== Package
@@ -117,6 +119,17 @@ sub unpackmsgid {
return ($sendtime,$shortsubj,$fromname,$fromdomain,$status{$msgid});
}
+# ============================================================= Check for email
+
+sub newmail {
+ if ((time-$ENV{'user.mailcheck.time'})>300) {
+ my %what=&Apache::lonnet::get('email_status',['recnewemail']);
+ &Apache::lonnet::appenv('user.mailcheck.time'=>time);
+ if ($what{'recnewemail'}>0) { return 1; }
+ }
+ return 0;
+}
+
# =============================== Automated message to the author of a resource
sub author_res_msg {
@@ -139,7 +152,7 @@ sub author_res_msg {
# ================================================== Critical message to a user
-sub user_crit_msg {
+sub user_crit_msg_raw {
my ($user,$domain,$subject,$message,$sendback)=@_;
# Check if allowed missing
my $status='';
@@ -166,6 +179,27 @@ sub user_crit_msg {
return $status;
}
+# New routine that respects "forward" and calls old routine
+
+sub user_crit_msg {
+ my ($user,$domain,$subject,$message,$sendback)=@_;
+ my $status='';
+ my %userenv = &Apache::lonnet::get('environment',['msgforward'],
+ $domain,$user);
+ my $msgforward=$userenv{'msgforward'};
+ if ($msgforward) {
+ foreach (split(/\,/,$msgforward)) {
+ my ($forwuser,$forwdomain)=split(/\:/,$_);
+ $status.=
+ &user_crit_msg_raw($forwuser,$forwdomain,$subject,$message,
+ $sendback).' ';
+ }
+ } else {
+ $status=&user_crit_msg_raw($user,$domain,$subject,$message,$sendback);
+ }
+ return $status;
+}
+
# =================================================== Critical message received
sub user_crit_received {
@@ -176,9 +210,10 @@ sub user_crit_received {
&user_normal_msg($contents{'sendername'},$contents{'senderdomain'},
'Receipt: '.$ENV{'user.name'}.' at '.$ENV{'user.domain'},
'User '.$ENV{'user.name'}.' at '.$ENV{'user.domain'}.
- ' acknowledged receipt of message "'.
- $contents{'subject'}.'" dated '.$contents{'time'}.".\n\n"
- .'Message ID: '.$contents{'msgid'}):'no msg req');
+ ' acknowledged receipt of message'."\n".' "'.
+ $contents{'subject'}.'"'."\n".'dated '.
+ $contents{'time'}.".\n"
+ ):'no msg req');
$status.=' trans: '.
&Apache::lonnet::put(
'nohist_email',{$contents{'msgid'} => $message{$msgid}});
@@ -193,7 +228,7 @@ sub user_crit_received {
# ======================================================== Normal communication
-sub user_normal_msg {
+sub user_normal_msg_raw {
my ($user,$domain,$subject,$message,$citation)=@_;
# Check if allowed missing
my $status='';
@@ -206,6 +241,8 @@ sub user_normal_msg {
'put:'.$domain.':'.$user.':nohist_email:'.
&Apache::lonnet::escape($msgid).'='.
&Apache::lonnet::escape($message),$homeserver);
+ &Apache::lonnet::put
+ ('email_status',{'recnewemail'=>time},$domain,$user);
} else {
$status='no_host';
}
@@ -215,6 +252,29 @@ sub user_normal_msg {
return $status;
}
+# New routine that respects "forward" and calls old routine
+
+sub user_normal_msg {
+ my ($user,$domain,$subject,$message,$citation)=@_;
+ my $status='';
+ my %userenv = &Apache::lonnet::get('environment',['msgforward'],
+ $domain,$user);
+ my $msgforward=$userenv{'msgforward'};
+ if ($msgforward) {
+ foreach (split(/\,/,$msgforward)) {
+ my ($forwuser,$forwdomain)=split(/\:/,$_);
+ $status.=
+ &user_normal_msg_raw($forwuser,$forwdomain,$subject,$message,
+ $citation).' ';
+ }
+ } else {
+ $status=
+ &user_normal_msg_raw($user,$domain,$subject,$message,$citation);
+ }
+ return $status;
+}
+
+
# =============================================================== Status Change
sub statuschange {
@@ -312,10 +372,15 @@ sub discrit {
my %content=&unpackagemsg($what{$_});
next if ($content{'senderdomain'} eq '');
$content{'message'}=~s/\n/\
/g;
- $result.='
'.$content{'message'}.''. + $result.='
'. + &Apache::lontexconvert::msgtexconverted($content{'message'}). + ''. ''. ''; @@ -343,16 +408,18 @@ sub comprep { my $subject='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= - ' Send as critical message
';
+ ' Send as critical message ' . $crithelp .
+ '
'.
+ ' Send as critical message ' .
+ ' and return receipt' . $crithelp . '
'; } $r->print(<<"ENDREPLY");
'); } +# ---------------------------------------------------------------- Face to face + +sub facetoface { + my ($r,$stage)=@_; + unless (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) { + return; + } + my $defdom=$ENV{'user.domain'}; + if ($ENV{'form.recdomain'}) { $defdom=$ENV{'form.recdomain'}; } + my $domform = &Apache::loncommon::select_dom_form($defdom,'recdomain'); + $r->print(<<"ENDTREC"); +'. '
Functions: | '. 'Forward | '. 'Mark Unread | '. + 'Delete | '. 'Display all Messages | '. '
'. - $content{'message'}.'