Diff for /loncom/interface/lonmsg.pm between versions 1.207 and 1.208

version 1.207, 2007/05/09 21:04:51 version 1.208, 2007/05/09 23:53:15
Line 299  sub sendnotification { Line 299  sub sendnotification {
     my ($to,$touname,$toudom,$subj,$crit,$text,$msgid)=@_;      my ($to,$touname,$toudom,$subj,$crit,$text,$msgid)=@_;
     my $sender=$env{'environment.firstname'}.' '.$env{'environment.lastname'};      my $sender=$env{'environment.firstname'}.' '.$env{'environment.lastname'};
     unless ($sender=~/\w/) {       unless ($sender=~/\w/) { 
  $sender=$env{'user.name'}.'@'.$env{'user.domain'};   $sender=$env{'user.name'}.':'.$env{'user.domain'};
     }      }
     my $critical=($crit?' critical':'');      my $critical=($crit?' critical':'');
   
     $text=~s/\&lt\;/\</gs;      $text=~s/\&lt\;/\</gs;
     $text=~s/\&gt\;/\>/gs;      $text=~s/\&gt\;/\>/gs;
     my $url='http://'.      my $url='http://'.
Line 309  sub sendnotification { Line 310  sub sendnotification {
       '/adm/email?username='.$touname.'&domain='.$toudom;        '/adm/email?username='.$touname.'&domain='.$toudom;
     my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid,      my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid,
         $symb,$error) = &Apache::lonmsg::unpackmsgid($msgid);          $symb,$error) = &Apache::lonmsg::unpackmsgid($msgid);
     my ($coursetext,$body,$bodystart,$bodyend);      my ($coursetext,$body,$bodybegin,$bodysubj,$bodyend);
     if ($fromcid ne '') {      if ($fromcid ne '') {
         $coursetext = "\n".&mt('Course').': ';          $coursetext = "\n".&mt('Course').': ';
         if ($env{'course.'.$fromcid.'.description'} ne '') {          if ($env{'course.'.$fromcid.'.description'} ne '') {
Line 323  sub sendnotification { Line 324  sub sendnotification {
         $coursetext .= "\n\n";          $coursetext .= "\n\n";
     }      }
     my @recipients = split(/,/,$to);      my @recipients = split(/,/,$to);
     $bodystart = $coursetext.       $bodybegin = $coursetext. 
                &mt('You received a'.$critical.' message from [_1] in LON-CAPA.',$sender).' '.&mt('The subject is                  &mt('You received a'.$critical.' message from [_1] in LON-CAPA.',$sender).' ';
       $bodysubj = &mt('The subject is 
   
  [_1]   [_1]
   
Line 341  sub sendnotification { Line 343  sub sendnotification {
 to access the full message.',$url);  to access the full message.',$url);
     my %userenv = &Apache::lonnet::get('environment',['notifywithhtml'],$toudom,$touname);      my %userenv = &Apache::lonnet::get('environment',['notifywithhtml'],$toudom,$touname);
     my $subject = &mt("'New' $critical message from ").$sender;      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 '') {      if ($userenv{'notifywithhtml'} ne '') {
         my @htmlexcerpt = split(/,/,$userenv{'notifywithhtml'});          my @htmlexcerpt = split(/,/,$userenv{'notifywithhtml'});
         foreach my $addr (@recipients) {          foreach my $addr (@recipients) {
             my $sendtext = $text;              if ($blocked) {
             if (!grep/^\Q$addr\E/,@htmlexcerpt) {                  $body = $bodybegin."\n".$blocktext."\n".$bodyend;
                 $sendtext =~ s/\<\/*[^\>]+\>//gs;              } 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);              &sendemail($addr,$subject,$body);
         }          }
     } else {      } else {
         $text =~ s/\<\/*[^\>]+\>//gs;          if ($blocked) {
         $body = $bodystart.$text.$bodyend;              $body = $bodybegin."\n".$blocktext."\n".$bodyend;
           } else {
               $text =~ s/\<\/*[^\>]+\>//gs;
               $body = $bodybegin.$bodysubj.$text.$bodyend;
           }
         &sendemail($to,$subject,$body);          &sendemail($to,$subject,$body);
     }      }
 }  }

Removed from v.1.207  
changed lines
  Added in v.1.208


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>