--- loncom/interface/lonmsg.pm 2007/03/02 23:17:59 1.198 +++ loncom/interface/lonmsg.pm 2007/04/22 02:25:36 1.199 @@ -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 $uname and +$udom in stored internal messages, compared +with $email 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 @@ sub user_normal_msg_raw { $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 @@ sub secapply { =pod -=over 4 - -=item * - -decide_receiver($feedurl,$author,$question,$course,$policy,$defaultflag); +=item * B: Arguments $feedurl - /res/ url of resource (only need if $author is true) @@ -759,6 +797,12 @@ sub decide_receiver { return ($typestyle,%to); } +=pod + +=back + +=cut + 1; __END__