Diff for /loncom/interface/lonmsg.pm between versions 1.173 and 1.174

version 1.173, 2006/01/23 23:15:51 version 1.174, 2006/01/30 07:32:20
Line 137  my $interdis; Line 137  my $interdis;
   
 sub packagemsg {  sub packagemsg {
     my ($subject,$message,$citation,$baseurl,$attachmenturl,      my ($subject,$message,$citation,$baseurl,$attachmenturl,
  $recuser,$recdomain,$msgid,$type)=@_;   $recuser,$recdomain,$msgid,$type,$crsmsgid)=@_;
     $message =&HTML::Entities::encode($message,'<>&"');      $message =&HTML::Entities::encode($message,'<>&"');
     $citation=&HTML::Entities::encode($citation,'<>&"');      $citation=&HTML::Entities::encode($citation,'<>&"');
     $subject =&HTML::Entities::encode($subject,'<>&"');      $subject =&HTML::Entities::encode($subject,'<>&"');
Line 170  sub packagemsg { Line 170  sub packagemsg {
         $msgid = &buildmsgid($now,$subject,$env{'user.name'},$env{'user.domain'},          $msgid = &buildmsgid($now,$subject,$env{'user.name'},$env{'user.domain'},
                             $msgcount,$course_context,$$);                              $msgcount,$course_context,$$);
     }      }
     my $result='<sendername>'.$env{'user.name'}.'</sendername>'.      my $result = '<sendername>'.$env{'user.name'}.'</sendername>'.
            '<senderdomain>'.$env{'user.domain'}.'</senderdomain>'.             '<senderdomain>'.$env{'user.domain'}.'</senderdomain>'.
            '<subject>'.$subject.'</subject>'.             '<subject>'.$subject.'</subject>'.
    '<time>'.&Apache::lonlocal::locallocaltime($now).'</time>'.             '<time>'.&Apache::lonlocal::locallocaltime($now).'</time>';
    '<servername>'.$ENV{'SERVER_NAME'}.'</servername>'.      if (defined($crsmsgid)) {
           $result.= '<courseid>'.$course_context.'</courseid>'.
                     '<coursesec>'.$env{'request.course.sec'}.'</coursesec>'.
                     '<msgid>'.$msgid.'</msgid>'.
                     '<coursemsgid>'.$crsmsgid.'</coursemsgid>'.
                     '<message>'.$message.'</message>';
           return ($msgid,$result);
       }
       $result .= '<servername>'.$ENV{'SERVER_NAME'}.'</servername>'.
            '<host>'.$ENV{'HTTP_HOST'}.'</host>'.             '<host>'.$ENV{'HTTP_HOST'}.'</host>'.
    '<client>'.$ENV{'REMOTE_ADDR'}.'</client>'.     '<client>'.$ENV{'REMOTE_ADDR'}.'</client>'.
    '<browsertype>'.$env{'browser.type'}.'</browsertype>'.     '<browsertype>'.$env{'browser.type'}.'</browsertype>'.
Line 536  sub user_crit_received { Line 544  sub user_crit_received {
   
 sub user_normal_msg_raw {  sub user_normal_msg_raw {
     my ($user,$domain,$subject,$message,$citation,$baseurl,$attachmenturl,      my ($user,$domain,$subject,$message,$citation,$baseurl,$attachmenturl,
  $toperm,$currid,$newid,$sentmessage)=@_;   $toperm,$currid,$newid,$sentmessage,$crsmsgid)=@_;
 # Check if allowed missing  # Check if allowed missing
     my ($status,$packed_message);      my ($status,$packed_message);
     my $msgid='undefined';      my $msgid='undefined';
Line 546  sub user_normal_msg_raw { Line 554  sub user_normal_msg_raw {
     if ($homeserver ne 'no_host') {      if ($homeserver ne 'no_host') {
        ($msgid,$packed_message)=         ($msgid,$packed_message)=
                  &packagemsg($subject,$message,$citation,$baseurl,                   &packagemsg($subject,$message,$citation,$baseurl,
                                      $attachmenturl,$user,$domain,$currid);                                       $attachmenturl,$user,$domain,$currid,
        (undef, my $packed_message_no_citation)=                                                           undef,$crsmsgid);
                          &packagemsg($subject,$message,undef     ,$baseurl,  
                                      $attachmenturl,$user,$domain,$currid);  
 # Store in user folder  # Store in user folder
        $status=&Apache::lonnet::critical(         $status=&Apache::lonnet::critical(
            'put:'.$domain.':'.$user.':nohist_email:'.             'put:'.$domain.':'.$user.':nohist_email:'.
Line 565  sub user_normal_msg_raw { Line 572  sub user_normal_msg_raw {
                (&Apache::lonnet::allowed('srm',$env{'request.course.id'})                 (&Apache::lonnet::allowed('srm',$env{'request.course.id'})
  || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.   || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
     '/'.$env{'request.course.sec'})))) {      '/'.$env{'request.course.sec'})))) {
              (undef, my $packed_message_no_citation)=
                                &packagemsg($subject,$message,undef     ,$baseurl,
                                             $attachmenturl,$user,$domain,$currid,
                                                                 undef,$crsmsgid);
   
            $status .= &store_sent_mail($msgid,$packed_message_no_citation);             $status .= &store_sent_mail($msgid,$packed_message_no_citation);
        }         }
     } else {      } else {
Line 1424  sub disfacetoface { Line 1436  sub disfacetoface {
         } elsif ($content{'subject'}=~/^Broadcast/) {          } elsif ($content{'subject'}=~/^Broadcast/) {
             $result .='<h3>'.&mt('Broadcast Message').'</h3>';              $result .='<h3>'.&mt('Broadcast Message').'</h3>';
             if ($content{'subject'}=~/^Broadcast\./) {              if ($content{'subject'}=~/^Broadcast\./) {
                 %content=&unpackagemsg($content{'message'});                  if (defined($content{'coursemsgid'})) {
                 $content{'message'}=                      my $crsmsgid = &Apache::lonnet::escape($content{'coursemsgid'});
                       my $broadcast_message = &general_message($crsmsgid);
                       $content{'message'} = '<b>'.&mt('Subject').': '.$content{'message'}.'</b><br />'.$broadcast_message;
                   } else {
                       %content=&unpackagemsg($content{'message'});
                       $content{'message'} =
                     '<b>'.&mt('Subject').': '.$content{'subject'}.'</b><br />'.                      '<b>'.&mt('Subject').': '.$content{'subject'}.'</b><br />'.
                     $content{'message'};                      $content{'message'};
                   }
             }                  }    
         } else {          } else {
             $result.='<h3>'.&mt('Critical Message').'</h3>';              $result.='<h3>'.&mt('Critical Message').'</h3>';
             %content=&unpackagemsg($content{'message'});              if (defined($content{'coursemsgid'})) {
             $content{'message'}=                  my $crsmsgid=&Apache::lonnet::escape($content{'coursemsgid'});
                   my $critical_message = &general_message($crsmsgid);
                   $content{'message'} = '<b>'.&mt('Subject').': '.$content{'message'}.'</b><br />'.$critical_message;
               } else {
                   %content=&unpackagemsg($content{'message'});
                   $content{'message'}=
                 '<b>'.&mt('Subject').': '.$content{'subject'}.'</b><br />'.                  '<b>'.&mt('Subject').': '.$content{'subject'}.'</b><br />'.
  $content{'message'};   $content{'message'};
               }
         }          }
         $result.=&mt('By').': <b>'.          $result.=&mt('By').': <b>'.
 &Apache::loncommon::aboutmewrapper(  &Apache::loncommon::aboutmewrapper(
Line 1457  $content{'sendername'}.'@'. Line 1481  $content{'sendername'}.'@'.
     }      }
 }  }
   
   sub general_message {
       my ($crsmsgid) = @_;
       my %general_content;
       if ($crsmsgid) { 
           my %course_content = &Apache::lonnet::get('nohist_email',[$crsmsgid],
                              $env{'course.'.$env{'request.course.id'}.'.domain'},
                              $env{'course.'.$env{'request.course.id'}.'.num'});
           %general_content = &unpackagemsg($course_content{$crsmsgid});
       }
       return $general_content{'message'};
   }
   
 # ---------------------------------------------------------------- Face to face  # ---------------------------------------------------------------- Face to face
   
 sub facetoface {  sub facetoface {
Line 2160  sub sendoffmail { Line 2196  sub sendoffmail {
         my $savemsg;          my $savemsg;
         my $msgtype;          my $msgtype;
         my %sentmessage;          my %sentmessage;
           my $msgsubj=&Apache::lonfeedback::clear_out_html($env{'form.subject'});
         if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) &&          if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) &&
             (&Apache::lonnet::allowed('srm',$env{'request.course.id'})              (&Apache::lonnet::allowed('srm',$env{'request.course.id'})
      || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.       || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
Line 2181  sub sendoffmail { Line 2218  sub sendoffmail {
  || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.   || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
      '/'.$env{'request.course.sec'}))) {       '/'.$env{'request.course.sec'}))) {
  $r->print(&mt('Sending critical message').' '.$recuname.'@'.$recdomain.': ');   $r->print(&mt('Sending critical message').' '.$recuname.'@'.$recdomain.': ');
  $thismsg=&user_crit_msg($recuname,$recdomain,   $thismsg=&user_crit_msg($recuname,$recdomain,$msgsubj,$msgtxt,
  &Apache::lonfeedback::clear_out_html($env{'form.subject'}),   $env{'form.sendbck'},$env{'form.permanent'},
  $msgtxt,                                                               \$sentmessage{$_});
  $env{'form.sendbck'},$env{'form.permanent'},\$sentmessage{$_});  
     } else {      } else {
  $r->print(&mt('Sending').' '.$recuname.'@'.$recdomain.': ');   $r->print(&mt('Sending').' '.$recuname.'@'.$recdomain.': ');
  $thismsg=&user_normal_msg($recuname,$recdomain,   $thismsg=&user_normal_msg($recuname,$recdomain,$msgsubj,$msgtxt,
   &Apache::lonfeedback::clear_out_html($env{'form.subject'}),  
   $msgtxt,  
   $content{'citation'},undef,undef,$env{'form.permanent'},\$sentmessage{$_});    $content{'citation'},undef,undef,$env{'form.permanent'},\$sentmessage{$_});
             }              }
     if (($env{'request.course.id'}) && (($msgtype eq 'critical') ||       if (($env{'request.course.id'}) && (($msgtype eq 'critical') || 
Line 2225  sub sendoffmail { Line 2259  sub sendoffmail {
                 my $record_sent;                  my $record_sent;
                 my @recusers = ();                  my @recusers = ();
                 my @recudoms = ();                  my @recudoms = ();
                 my ($stamp,$msgsubj,$msgname,$msgdom,$msgcount,$context,$pid) =                   my ($stamp,$crssubj,$msgname,$msgdom,$msgcount,$context,$pid) = 
                             split(/\:/,&Apache::lonnet::unescape($specialmsgid));                              split(/\:/,&Apache::lonnet::unescape($specialmsgid));
                 foreach my $recipient (sort(keys(%toaddr))) {                  foreach my $recipient (sort(keys(%toaddr))) {
                     if ($specialmsg_status{$recipient} eq 'ok') {                      if ($specialmsg_status{$recipient} eq 'ok') {
Line 2233  sub sendoffmail { Line 2267  sub sendoffmail {
                         my $usermsgid = &buildmsgid($stamp,$usersubj,$msgname,                          my $usermsgid = &buildmsgid($stamp,$usersubj,$msgname,
                                               $msgdom,$msgcount,$context,$pid);                                                $msgdom,$msgcount,$context,$pid);
                         &user_normal_msg_raw($cnum,$cdom,$subj_prefix.                          &user_normal_msg_raw($cnum,$cdom,$subj_prefix.
                         ' ['.$recipient.']',$sentmessage{$recipient},                                               ' ['.$recipient.']',$msgsubj,undef,
                         undef,undef,undef,undef,$usermsgid);                          undef,undef,undef,$usermsgid,undef,undef,$specialmsgid);
                         my ($uname,$udom) = split/:/,$recipient;                          my ($uname,$udom) = split/:/,$recipient;
                         push(@recusers,$uname);                          push(@recusers,$uname);
                         push(@recudoms,$udom);                          push(@recudoms,$udom);
Line 2243  sub sendoffmail { Line 2277  sub sendoffmail {
                 if (@recusers) {                  if (@recusers) {
                     my $specialmessage;                      my $specialmessage;
                     my $sentsubj = $subj_prefix.' ('.$numspecial.' sent) '.                      my $sentsubj = $subj_prefix.' ('.$numspecial.' sent) '.
                     &Apache::lonfeedback::clear_out_html($env{'form.subject'});                                                                         $msgsubj;
                     $sentsubj = &HTML::Entities::encode($sentsubj,'<>&"');                      $sentsubj = &HTML::Entities::encode($sentsubj,'<>&"');
                     my $sentmsgid = &buildmsgid($stamp,$sentsubj,$msgname,                      my $sentmsgid = &buildmsgid($stamp,$sentsubj,$msgname,
                                               $msgdom,$msgcount,$context,$pid);                                                $msgdom,$msgcount,$context,$pid);
                     ($specialmsgid,$specialmessage) =                      ($specialmsgid,$specialmessage) = &packagemsg($msgsubj,$savemsg,
                          &packagemsg(&Apache::lonfeedback::clear_out_html(                              undef,undef,undef,\@recusers,\@recudoms,$sentmsgid);
                              $env{'form.subject'}),$savemsg,undef,undef,undef,  
                                             \@recusers,\@recudoms,$sentmsgid);  
                     $record_sent = &store_sent_mail($specialmsgid,$specialmessage);                      $record_sent = &store_sent_mail($specialmsgid,$specialmessage);
                 }                  }
             } else {              } else {

Removed from v.1.173  
changed lines
  Added in v.1.174


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