[LON-CAPA-cvs] cvs: loncom /interface lonmsg.pm lonmsgdisplay.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Sun, 22 Apr 2007 02:25:39 -0000
raeburn Sat Apr 21 22:25:39 2007 EDT
Modified files:
/loncom/interface lonmsg.pm lonmsgdisplay.pm
Log:
- Making perldoc work in lonmsg.pm
- Moving some documentation from lonmsgdisplay.pm to lonmsg.pm
- Fix for critical messages sent to users with multiple forwards (lonmsgdisplay.pm rev 1.12) also needed to be applied for broadcast messages.
- Check for $specialmsg_status{$recipient} modified so sent mail will be stored in case of multiple forwards for critical or broadcast mail.
- Include sanity checking for ARRAY refs.
Index: loncom/interface/lonmsg.pm
diff -u loncom/interface/lonmsg.pm:1.198 loncom/interface/lonmsg.pm:1.199
--- loncom/interface/lonmsg.pm:1.198 Fri Mar 2 18:17:59 2007
+++ loncom/interface/lonmsg.pm Sat Apr 21 22:25:36 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging
#
-# $Id: lonmsg.pm,v 1.198 2007/03/02 23:17:59 albertel Exp $
+# $Id: lonmsg.pm,v 1.199 2007/04/22 02:25:36 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -28,6 +28,37 @@
package Apache::lonmsg;
+=pod
+
+=head1 NAME
+
+Apache::lonmsg: supports internal messaging
+
+=head1 SYNOPSIS
+
+lonmsg provides routines for sending messages.
+
+Right now, this document will cover just how to send a message, since
+it is likely you will not need to programmatically read messages,
+since lonmsg already implements that functionality.
+
+The routines used to package messages and unpackage messages are not
+only used by lonmsg when creating/extracting messages for LON-CAPA's
+internal messaging system, but also by lonnotify.pm which is available
+for use by Domain Coordinators to broadcast standard e-mail to specified
+users in their domain. The XML packaging used in the two cases is very
+similar. The differences are the use of <recuser>$uname</recuser> and
+<recdomain>$udom</recdomain> in stored internal messages, compared
+with <recipient username="$uname:$udom">$email</recipient> in stored
+Domain Coordinator e-mail for the storage of information about
+recipients of the message/e-mail.
+
+=head1 FUNCTIONS
+
+=over 4
+
+=cut
+
use strict;
use Apache::lonnet;
use HTML::TokeParser();
@@ -598,29 +629,40 @@
$baseurl, $attachmenturl, $toperm, $sentmessage, $symb, $restitle, $error)>:
Sends a message to the $user at $domain, with subject $subject and message $message.
+ Additionally it will check if the user has a Forwarding address
+ set, and send the message to that address instead
+
+ returns
+ - in array context a list of results for each message that was sent
+ - in scalar context a space seperated list of results for each
+ message sent
+
=cut
sub user_normal_msg {
my ($user,$domain,$subject,$message,$citation,$baseurl,$attachmenturl,
$toperm,$sentmessage,$symb,$restitle,$error)=@_;
- my $status='';
+ 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.=
+ push(@status,
&user_normal_msg_raw($forwuser,$forwdomain,$subject,$message,
$citation,$baseurl,$attachmenturl,$toperm,
- undef,undef,$sentmessage,undef,$symb,$restitle,$error).' ';
+ undef,undef,$sentmessage,undef,$symb,$restitle,$error));
}
} else {
- $status=&user_normal_msg_raw($user,$domain,$subject,$message,
+ push(@status,&user_normal_msg_raw($user,$domain,$subject,$message,
$citation,$baseurl,$attachmenturl,$toperm,
- undef,undef,$sentmessage,undef,$symb,$restitle,$error);
+ undef,undef,$sentmessage,undef,$symb,$restitle,$error));
}
- return $status;
+ if (wantarray) {
+ return @status;
+ }
+ return join(' ',@status);
}
sub store_sent_mail {
@@ -691,11 +733,7 @@
=pod
-=over 4
-
-=item *
-
-decide_receiver($feedurl,$author,$question,$course,$policy,$defaultflag);
+=item * B<decide_receiver($feedurl,$author,$question,$course,$policy,$defaultflag)>:
Arguments
$feedurl - /res/ url of resource (only need if $author is true)
@@ -759,6 +797,12 @@
return ($typestyle,%to);
}
+=pod
+
+=back
+
+=cut
+
1;
__END__
Index: loncom/interface/lonmsgdisplay.pm
diff -u loncom/interface/lonmsgdisplay.pm:1.68 loncom/interface/lonmsgdisplay.pm:1.69
--- loncom/interface/lonmsgdisplay.pm:1.68 Thu Mar 1 04:30:58 2007
+++ loncom/interface/lonmsgdisplay.pm Sat Apr 21 22:25:36 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging display
#
-# $Id: lonmsgdisplay.pm,v 1.68 2007/03/01 09:30:58 www Exp $
+# $Id: lonmsgdisplay.pm,v 1.69 2007/04/22 02:25:36 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,12 +33,13 @@
=head1 NAME
-Apache::lonmsg: supports internal messaging
+Apache::lonmsgdisplay: supports internal messaging
=head1 SYNOPSIS
-lonmsg provides routines for sending messages, receiving messages, and
-a handler to allow users to read, send, and delete messages.
+lonmsgdisplay provides a handler to allow users to read, send,
+and delete messages, and to create and delete message folders,
+and to move messages between folders.
=head1 OVERVIEW
@@ -93,25 +94,6 @@
are much more useful than traditional email can be made to be, even
with HTML support.
-Right now, this document will cover just how to send a message, since
-it is likely you will not need to programmatically read messages,
-since lonmsg already implements that functionality.
-
-The routines used to package messages and unpackage messages are not
-only used by lonmsg when creating/extracting messages for LON-CAPA's
-internal messaging system, but also by lonnotify.pm which is available
-for use by Domain Coordinators to broadcast standard e-mail to specified
-users in their domain. The XML packaging used in the two cases is very
-similar. The differences are the use of <recuser>$uname</recuser> and
-<recdomain>$udom</recdomain> in stored internal messages, compared
-with <recipient username="$uname:$udom">$email</recipient> in stored
-Domain Coordinator e-mail for the storage of information about
-recipients of the message/e-mail.
-
-=head1 FUNCTIONS
-
-=over 4
-
=cut
use strict;
@@ -1055,16 +1037,23 @@
}
my ($dis_name,$dis_domain) = ($fromname,$fromdomain);
if ($folder eq 'sent') {
- if (defined($recv_name) && !defined($recv_domain)) {
- $dis_name = join('<br />',@{$recv_name});
- $dis_domain = join('<br />',@{$recv_domain});
+ if (defined($recv_name) && defined($recv_domain)) {
+ if (ref($recv_name) eq 'ARRAY' &&
+ ref($recv_domain) eq 'ARRAY') {
+ $dis_name = join('<br />',@{$recv_name});
+ $dis_domain = join('<br />',@{$recv_domain});
+ }
} else {
my $msg_id = &unescape($origID);
my %message = &Apache::lonnet::get('nohist_email'.$suffix,
[$msg_id]);
my %content = &Apache::lonmsg::unpackagemsg($message{$msg_id});
- $dis_name = join('<br />',@{$content{'recuser'}});
- $dis_domain = join('<br />',@{$content{'recdomain'}});
+ if (ref($content{'recuser'}) eq 'ARRAY') {
+ $dis_name = join('<br />',@{$content{'recuser'}});
+ }
+ if (ref($content{'recdomain'}) eq 'ARRAY') {
+ $dis_domain = join('<br />',@{$content{'recdomain'}});
+ }
}
}
my $localsenttime = &Apache::lonlocal::locallocaltime($sendtime);
@@ -2367,7 +2356,7 @@
split(/\:/,&unescape($specialmsgid));
foreach my $recipient (sort(keys(%toaddr))) {
- if ($specialmsg_status{$recipient} eq 'ok') {
+ if ($specialmsg_status{$recipient} =~ /\s*(ok|con_delayed)\s*/) {
my $usersubj = $subj_prefix.'['.$recipient.']';
my $usermsgid =
&Apache::lonmsg::buildmsgid($stamp,$usersubj,
@@ -2760,8 +2749,6 @@
=pod
-=back
-
=cut
1;