--- loncom/interface/lonmsg.pm 2006/04/23 04:04:38 1.182 +++ loncom/interface/lonmsg.pm 2006/04/25 19:45:50 1.183 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging # -# $Id: lonmsg.pm,v 1.182 2006/04/23 04:04:38 albertel Exp $ +# $Id: lonmsg.pm,v 1.183 2006/04/25 19:45:50 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -406,25 +406,38 @@ sub user_crit_msg_raw { a critical message $message to the $user at $domain. If $sendback is true, a reciept will be sent to the current user when $user recieves the 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_crit_msg { my ($user,$domain,$subject,$message,$sendback,$toperm,$sentmessage)=@_; - 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.= - &user_crit_msg_raw($forwuser,$forwdomain,$subject,$message, - $sendback,$toperm,$sentmessage).' '; + foreach my $addr (split(/\,/,$msgforward)) { + my ($forwuser,$forwdomain)=split(/\:/,$addr); + push(@status, + &user_crit_msg_raw($forwuser,$forwdomain,$subject,$message, + $sendback,$toperm,$sentmessage)); } } else { - $status=&user_crit_msg_raw($user,$domain,$subject,$message,$sendback,$toperm,$sentmessage); + push(@status, + &user_crit_msg_raw($user,$domain,$subject,$message,$sendback, + $toperm,$sentmessage)); } - return $status; + if (wantarray) { + return @status; + } + return join(' ',@status); } # =================================================== Critical message received