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

www lon-capa-cvs@mail.lon-capa.org
Wed, 01 Nov 2006 22:22:33 -0000


www		Wed Nov  1 17:22:33 2006 EDT

  Modified files:              
    /loncom/interface	loncommon.pm lonmsg.pm lonnotify.pm 
  Log:
  Bug #4072: Add a reply-to field to notification messages.
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.466 loncom/interface/loncommon.pm:1.467
--- loncom/interface/loncommon.pm:1.466	Tue Oct 31 17:05:53 2006
+++ loncom/interface/loncommon.pm	Wed Nov  1 17:22:31 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.466 2006/10/31 22:05:53 albertel Exp $
+# $Id: loncommon.pm,v 1.467 2006/11/01 22:22:31 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2072,6 +2072,8 @@
     if ($udom eq 'public' && $uname eq 'public') {
 	return;
     }
+    if (!$udom) { $udom=$env{'user.domain'}; }
+    if (!$uname) { $uname=$env{'user.name'}; }
     my $id=$uname.':'.$udom;
     my ($names,$cached)=&Apache::lonnet::is_cached_new('emailscache',$id);
     if ($cached) {
Index: loncom/interface/lonmsg.pm
diff -u loncom/interface/lonmsg.pm:1.185 loncom/interface/lonmsg.pm:1.186
--- loncom/interface/lonmsg.pm:1.185	Mon Jun 12 18:55:23 2006
+++ loncom/interface/lonmsg.pm	Wed Nov  1 17:22:31 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging
 #
-# $Id: lonmsg.pm,v 1.185 2006/06/12 22:55:23 albertel Exp $
+# $Id: lonmsg.pm,v 1.186 2006/11/01 22:22:31 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -210,12 +210,21 @@
 
 sub sendemail {
     my ($to,$subject,$body)=@_;
+    my %senderemails=&Apache::loncommon::getemails();
+    my $senderaddress='';
+    foreach my $type ('notification','permanentemail','critnotification') {
+	if ($senderemails{$type}) {
+	    $senderaddress=$senderemails{$type};
+	}
+    }
     $body=
     "*** ".&mt('This is an automatic message generated by the LON-CAPA system.')."\n".
-    "*** ".&mt('Please do not reply to this address.')."\n\n".$body;
+    "*** ".($senderaddress?&mt('You can reply to this message'):&mt('Please do not reply to this address.')."\n*** ".
+	    &mt('A reply will not be received by the recipient!'))."\n\n".$body;
     my $msg = new Mail::Send;
     $msg->to($to);
     $msg->subject('[LON-CAPA] '.$subject);
+    if ($senderaddress) { $msg->add('Reply-to',$senderaddress); }
     if (my $fh = $msg->open()) {
 	print $fh $body;
 	$fh->close;
@@ -390,9 +399,7 @@
        $status='no_host';
     }
 # Notifications
-    my %userenv = &Apache::lonnet::get('environment',['critnotification',
-                                                      'permanentemail'],
-                                       $domain,$user);
+    my %userenv = &Apache::loncommon::getemails($user,$domain);
     if ($userenv{'critnotification'}) {
       &sendnotification($userenv{'critnotification'},$user,$domain,$subject,1,
 			$text);
Index: loncom/interface/lonnotify.pm
diff -u loncom/interface/lonnotify.pm:1.24 loncom/interface/lonnotify.pm:1.25
--- loncom/interface/lonnotify.pm:1.24	Thu Oct 12 18:47:31 2006
+++ loncom/interface/lonnotify.pm	Wed Nov  1 17:22:31 2006
@@ -1,3 +1,7 @@
+# The LearningOnline Network with CAPA
+# Sending messages
+#
+# $Id: lonnotify.pm,v 1.25 2006/11/01 22:22:31 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -205,7 +209,7 @@
             my ($trole,$uname,$udom,$runame,$rudom,$rsec) = split(/:/,$user);
             unless (grep/^$uname:$udom$/,@domcc) {
                 my %userinfo = &Apache::lonnet::get('environment',['lastname','firstname'],$udom,$uname);
-                $output .= '<input type="checkbox" name="sender" value="'.$uname.':'.$udom.'" />&nbsp;'.$userinfo{firstname}.' '.$userinfo{lastname}.'&nbsp;&nbsp;('.$uname.':'.$udom.')';
+                $output .= '<input type="checkbox" name="sender" value="'.$uname.':'.$udom.'" />&nbsp;'.$userinfo{'firstname'}.' '.$userinfo{'lastname'}.'&nbsp;&nbsp;('.$uname.':'.$udom.')';
                 push (@domcc,$uname.':'.$udom);
             }
         }
@@ -735,7 +739,7 @@
     my ($user,%email_defaults) = @_;
     my ($uname,$udom) = split(/:/,$user);
     my @emailtypes = ('permanentemail','critnotification','notification');
-    my %userinfo = &Apache::lonnet::get('environment',\@emailtypes,$udom,$uname);
+    my %userinfo = &Apache::loncommon::getemails($uname,$udom);
     my $email = '';
     foreach my $type (@emailtypes) {
         $email = $userinfo{$type};