--- loncom/interface/lonmsg.pm 2002/07/22 14:23:29 1.35
+++ 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.35 2002/07/22 14:23:29 bowersj2 Exp $
+# $Id: lonmsg.pm,v 1.44 2002/12/27 14:59:42 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -50,6 +50,7 @@ use vars qw($msgcount);
use HTML::TokeParser;
use Apache::Constants qw(:common);
use Apache::loncommon;
+use Apache::lontexconvert;
# ===================================================================== Package
@@ -118,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 {
@@ -140,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='';
@@ -167,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 {
@@ -177,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}});
@@ -194,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='';
@@ -207,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';
}
@@ -216,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 {
@@ -313,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'}). + ''. ''. ''; @@ -355,7 +419,7 @@ sub comprep { +ENDBFORM + } +} + # ===================================================================== Handler sub handler { @@ -529,22 +638,27 @@ sub handler { # --------------------------- Get query string for limited number of parameters &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['display','replyto','forward','markread','markdel','markunread', - 'sendreply','compose','sendmail','critical']); + 'sendreply','compose','sendmail','critical','recname','recdom', + 'recordftf']); +# ------------------------------------------------------ They checked for email + &Apache::lonnet::put('email_status',{'recnewemail'=>0}); # --------------------------------------------------------------- Render Output - $r->print('
'. '
Functions: | '. 'Forward | '. 'Mark Unread | '. + 'Delete | '. 'Display all Messages | '. '
'. - $content{'message'}.'