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

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Wed, 09 May 2007 23:53:16 -0000


raeburn		Wed May  9 19:53:16 2007 EDT

  Modified files:              
    /loncom/interface	loncommon.pm lonmsg.pm 
  Log:
  Bug 5056.  E-mail notification excludes excerpt of if a non-critical message is received during a COM blocking period.
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.532 loncom/interface/loncommon.pm:1.533
--- loncom/interface/loncommon.pm:1.532	Tue May  1 21:33:48 2007
+++ loncom/interface/loncommon.pm	Wed May  9 19:53:15 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.532 2007/05/02 01:33:48 albertel Exp $
+# $Id: loncommon.pm,v 1.533 2007/05/09 23:53:15 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2912,7 +2912,7 @@
         }
         my $no_ownblock = 0;
         my $no_userblock = 0;
-        if ($otheruser) {
+        if ($otheruser && $activity ne 'com') {
             # Check if current user has 'evb' priv for this
             if (defined($own_courses{$course})) {
                 foreach my $sec (keys(%{$own_courses{$course}})) {
Index: loncom/interface/lonmsg.pm
diff -u loncom/interface/lonmsg.pm:1.207 loncom/interface/lonmsg.pm:1.208
--- loncom/interface/lonmsg.pm:1.207	Wed May  9 17:04:51 2007
+++ loncom/interface/lonmsg.pm	Wed May  9 19:53:15 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging
 #
-# $Id: lonmsg.pm,v 1.207 2007/05/09 21:04:51 raeburn Exp $
+# $Id: lonmsg.pm,v 1.208 2007/05/09 23:53:15 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -299,9 +299,10 @@
     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'};
+	$sender=$env{'user.name'}.':'.$env{'user.domain'};
     }
     my $critical=($crit?' critical':'');
+
     $text=~s/\&lt\;/\</gs;
     $text=~s/\&gt\;/\>/gs;
     my $url='http://'.
@@ -309,7 +310,7 @@
       '/adm/email?username='.$touname.'&domain='.$toudom;
     my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid,
         $symb,$error) = &Apache::lonmsg::unpackmsgid($msgid);
-    my ($coursetext,$body,$bodystart,$bodyend);
+    my ($coursetext,$body,$bodybegin,$bodysubj,$bodyend);
     if ($fromcid ne '') {
         $coursetext = "\n".&mt('Course').': ';
         if ($env{'course.'.$fromcid.'.description'} ne '') {
@@ -323,8 +324,9 @@
         $coursetext .= "\n\n";
     }
     my @recipients = split(/,/,$to);
-    $bodystart = $coursetext. 
-               &mt('You received a'.$critical.' message from [_1] in LON-CAPA.',$sender).' '.&mt('The subject is 
+    $bodybegin = $coursetext. 
+               &mt('You received a'.$critical.' message from [_1] in LON-CAPA.',$sender).' ';
+    $bodysubj = &mt('The subject is 
 
  [_1]
 
@@ -341,19 +343,40 @@
 to access the full message.',$url);
     my %userenv = &Apache::lonnet::get('environment',['notifywithhtml'],$toudom,$touname);
     my $subject = &mt("'New' $critical message from ").$sender;
+ 
+    my ($blocked,$blocktext);
+    if (!$crit) {
+        my %setters;
+        my ($startblock,$endblock) = 
+            &Apache::loncommon::blockcheck(\%setters,'com',$touname,$toudom);
+        if ($startblock && $endblock) {
+            $blocked = 1;
+            my $showstart = localtime($startblock);
+            my $showend = localtime($endblock);
+            $blocktext = &mt('LON-CAPA messages sent to you between [_1] and [_2] will be inaccessible until the end of this time period, because you are a student in a course with an active communications block.',$showstart,$showend);
+        }
+    }
     if ($userenv{'notifywithhtml'} ne '') {
         my @htmlexcerpt = split(/,/,$userenv{'notifywithhtml'});
         foreach my $addr (@recipients) {
-            my $sendtext = $text;
-            if (!grep/^\Q$addr\E/,@htmlexcerpt) {
-                $sendtext =~ s/\<\/*[^\>]+\>//gs;
+            if ($blocked) {
+                $body = $bodybegin."\n".$blocktext."\n".$bodyend;
+            } else {
+                my $sendtext = $text;
+                if (!grep/^\Q$addr\E/,@htmlexcerpt) {
+                    $sendtext =~ s/\<\/*[^\>]+\>//gs;
+                }
+                $body = $bodybegin.$bodysubj.$sendtext.$bodyend;
             }
-            $body = $bodystart.$sendtext.$bodyend;
             &sendemail($addr,$subject,$body);
         }
     } else {
-        $text =~ s/\<\/*[^\>]+\>//gs;
-        $body = $bodystart.$text.$bodyend;
+        if ($blocked) {
+            $body = $bodybegin."\n".$blocktext."\n".$bodyend;
+        } else {
+            $text =~ s/\<\/*[^\>]+\>//gs;
+            $body = $bodybegin.$bodysubj.$text.$bodyend;
+        }
         &sendemail($to,$subject,$body);
     }
 }