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

version 1.204, 2007/05/05 03:14:21 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;
     $text=~s/\<\/*[^\>]+\>//gs;  
     my $url='http://'.      my $url='http://'.
  &Apache::lonnet::hostname(&Apache::lonnet::homeserver($touname,$toudom)).   &Apache::lonnet::hostname(&Apache::lonnet::homeserver($touname,$toudom)).
       '/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;      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 323  sub sendnotification {
         }          }
         $coursetext .= "\n\n";          $coursetext .= "\n\n";
     }      }
     my $body = $coursetext.       my @recipients = split(/,/,$to);
                &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]   [_1]
   
 ',$subj)."\n".  ',$subj)."\n".
 '=== '.&mt('Excerpt')." ============================================================  '=== '.&mt('Excerpt')." ============================================================
 $text  ";
       $bodyend = "
 ========================================================================  ========================================================================
   
 ".&mt('Use   ".&mt('Use 
Line 338  $text Line 341  $text
  [_1]   [_1]
   
 to access the full message.',$url);  to access the full message.',$url);
     &sendemail($to,'New'.$critical.' message from '.$sender,$body);      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) {
               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;
               }
               &sendemail($addr,$subject,$body);
           }
       } else {
           if ($blocked) {
               $body = $bodybegin."\n".$blocktext."\n".$bodyend;
           } else {
               $text =~ s/\<\/*[^\>]+\>//gs;
               $body = $bodybegin.$bodysubj.$text.$bodyend;
           }
           &sendemail($to,$subject,$body);
       }
 }  }
 # ============================================================= Check for email  # ============================================================= Check for email
   
Line 634  sub user_normal_msg_raw { Line 674  sub user_normal_msg_raw {
    $$sentmessage = $packed_message;     $$sentmessage = $packed_message;
        }         }
 # Notifications  # Notifications
        my %userenv = &Apache::lonnet::get('environment',['notification',         my %userenv = &Apache::loncommon::getemails($user,$domain);
  'permanentemail'],  
   $domain,$user);  
        if ($userenv{'notification'}) {         if ($userenv{'notification'}) {
    &sendnotification($userenv{'notification'},$user,$domain,$subject,0,     &sendnotification($userenv{'notification'},$user,$domain,$subject,0,
      $text,$msgid);       $text,$msgid);
Line 706  sub process_sent_mail { Line 744  sub process_sent_mail {
     my $sentsubj;      my $sentsubj;
     if ($numsent > 1) {      if ($numsent > 1) {
         $sentsubj = $subj_prefix.' ('.$numsent.' sent) '.$msgsubj;          $sentsubj = $subj_prefix.' ('.$numsent.' sent) '.$msgsubj;
       } else {
           if ($subj_prefix) {
               $sentsubj = $subj_prefix.' ';
           }
           $sentsubj .= $msgsubj;
     }      }
     $sentsubj = &HTML::Entities::encode($sentsubj,'<>&"');      $sentsubj = &HTML::Entities::encode($sentsubj,'<>&"');
     my $sentmsgid =       my $sentmsgid = 

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


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