[LON-CAPA-cvs] cvs: loncom /interface lonmsg.pm lonmsgdisplay.pm

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 25 Apr 2006 19:45:53 -0000


albertel		Tue Apr 25 15:45:53 2006 EDT

  Modified files:              
    /loncom/interface	lonmsgdisplay.pm lonmsg.pm 
  Log:
  - sending a critical message with a msgforward address set would cause messages to not get added to the users sent message folder
  
  
Index: loncom/interface/lonmsgdisplay.pm
diff -u loncom/interface/lonmsgdisplay.pm:1.11 loncom/interface/lonmsgdisplay.pm:1.12
--- loncom/interface/lonmsgdisplay.pm:1.11	Sun Apr 23 03:13:21 2006
+++ loncom/interface/lonmsgdisplay.pm	Tue Apr 25 15:45:50 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging display
 #
-# $Id: lonmsgdisplay.pm,v 1.11 2006/04/23 07:13:21 albertel Exp $
+# $Id: lonmsgdisplay.pm,v 1.12 2006/04/25 19:45:50 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1765,29 +1765,32 @@
 	    my ($recuname,$recdomain)=split(/\:/,$_);
             my $msgtxt = $savemsg;
 	    if ($toaddr{$_}) { $msgtxt.='<hr />'.$toaddr{$_}; }
-	    my $thismsg;
+	    my @thismsg;
 	    if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) && 
 		(&Apache::lonnet::allowed('srm',$env{'request.course.id'})
 		 || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
 					     '/'.$env{'request.course.sec'}))) {
 		$r->print(&mt('Sending critical message').' '.$recuname.'@'.$recdomain.': ');
-		$thismsg=&Apache::lonmsg::user_crit_msg($recuname,$recdomain,$msgsubj,$msgtxt,
+		@thismsg=&Apache::lonmsg::user_crit_msg($recuname,$recdomain,$msgsubj,$msgtxt,
 				$env{'form.sendbck'},$env{'form.permanent'},
                                                              \$sentmessage{$_});
 	    } else {
 		$r->print(&mt('Sending').' '.$recuname.'@'.$recdomain.': ');
-		$thismsg=&Apache::lonmsg::user_normal_msg($recuname,$recdomain,$msgsubj,$msgtxt,
+		@thismsg=&Apache::lonmsg::user_normal_msg($recuname,$recdomain,$msgsubj,$msgtxt,
 					  $content{'citation'},undef,undef,$env{'form.permanent'},\$sentmessage{$_});
             }
 	    if (($env{'request.course.id'}) && (($msgtype eq 'critical') || 
                                          ($env{'form.sendmode'} eq 'group'))) {
-	        $specialmsg_status{$recuname.':'.$recdomain}  = $thismsg;
-                if ($thismsg eq 'ok') {
-                    $numspecial ++;
-                }
+	        $specialmsg_status{$recuname.':'.$recdomain} =
+		    join(' ',@thismsg);
+		foreach my $result (@thismsg) {
+		    if ($result eq 'ok') {
+			$numspecial++;
+		    }
+		}
 	    }
-	    $r->print($thismsg.'<br />');
-	    $sendstatus.=' '.$thismsg;
+	    $r->print(join(' ',@thismsg).'<br />');
+	    $sendstatus.=' '.join(' ',@thismsg);
 	}
         if (($env{'request.course.id'}) && (($env{'form.sendmode'} eq 'group')
                                               || ($msgtype eq 'critical'))) {
Index: loncom/interface/lonmsg.pm
diff -u loncom/interface/lonmsg.pm:1.182 loncom/interface/lonmsg.pm:1.183
--- loncom/interface/lonmsg.pm:1.182	Sun Apr 23 00:04:38 2006
+++ loncom/interface/lonmsg.pm	Tue Apr 25 15:45:50 2006
@@ -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 @@
     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