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

raeburn lon-capa-cvs@mail.lon-capa.org
Thu, 28 Dec 2006 18:47:15 -0000


raeburn		Thu Dec 28 13:47:15 2006 EDT

  Modified files:              
    /loncom/interface	lonmsg.pm 
  Log:
  Bug 5098
  And some internationalization.
  
  
Index: loncom/interface/lonmsg.pm
diff -u loncom/interface/lonmsg.pm:1.193 loncom/interface/lonmsg.pm:1.194
--- loncom/interface/lonmsg.pm:1.193	Wed Dec 27 15:42:12 2006
+++ loncom/interface/lonmsg.pm	Thu Dec 28 13:47:15 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging
 #
-# $Id: lonmsg.pm,v 1.193 2006/12/27 20:42:12 raeburn Exp $
+# $Id: lonmsg.pm,v 1.194 2006/12/28 18:47:15 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -246,7 +246,7 @@
 # ==================================================== Send notification emails
 
 sub sendnotification {
-    my ($to,$touname,$toudom,$subj,$crit,$text)=@_;
+    my ($to,$touname,$toudom,$subj,$crit,$text,$msgid)=@_;
     my $sender=$env{'environment.firstname'}.' '.$env{'environment.lastname'};
     unless ($sender=~/\w/) { 
 	$sender=$env{'user.name'}.'@'.$env{'user.domain'};
@@ -258,21 +258,36 @@
     my $url='http://'.
       $Apache::lonnet::hostname{&Apache::lonnet::homeserver($touname,$toudom)}.
       '/adm/email?username='.$touname.'&domain='.$toudom;
-    my $body=(<<ENDMSG);
-You received a$critical message from $sender in LON-CAPA. The subject is
+    my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid,
+        $symb,$error) = &Apache::lonmsg::unpackmsgid($msgid);
+    my $coursetext;
+    if ($fromcid ne '') {
+        $coursetext = "\n".&mt('Course').': ';
+        if ($env{'course.'.$fromcid.'.description'} ne '') {
+            $coursetext .= $env{'course.'.$fromcid.'.description'};
+        } else {
+            my %coursehash = &Apache::lonnet::coursedescription($fromcid,);
+            if ($coursehash{'description'} ne '') {
+                $coursetext .= $coursehash{'description'};
+            }
+        }
+        $coursetext .= "\n\n";
+    }
+    my $body = $coursetext. 
+               &mt('You received a[_1] message from '.$sender.' in LON-CAPA.',$critical).' '.&mt("The subject is 
 
  $subj
 
-=== Excerpt ============================================================
+")."\n".
+'=== '.&mt('Excerpt')." ============================================================
 $text
 ========================================================================
 
-Use
+".&mt("Use 
 
  $url
 
-to access the full message.
-ENDMSG
+to access the full message.");
     &sendemail($to,'New'.$critical.' message from '.$sender,$body);
 }
 # ============================================================= Check for email
@@ -423,11 +438,11 @@
     my %userenv = &Apache::loncommon::getemails($user,$domain);
     if ($userenv{'critnotification'}) {
       &sendnotification($userenv{'critnotification'},$user,$domain,$subject,1,
-			$text);
+			$text,$msgid);
     }
     if ($toperm && $userenv{'permanentemail'}) {
       &sendnotification($userenv{'permanentemail'},$user,$domain,$subject,1,
-			$text);
+			$text,$msgid);
     }
 # Log this
     &Apache::lonnet::logthis(
@@ -564,11 +579,11 @@
                                        $domain,$user);
     if ($userenv{'notification'}) {
 	&sendnotification($userenv{'notification'},$user,$domain,$subject,0,
-			  $text);
+			  $text,$msgid);
     }
     if ($toperm && $userenv{'permanentemail'}) {
 	&sendnotification($userenv{'permanentemail'},$user,$domain,$subject,0,
-			  $text);
+			  $text,$msgid);
     }
     &Apache::lonnet::log($env{'user.domain'},$env{'user.name'},
                          $env{'user.home'},