Diff for /loncom/interface/lonmsg.pm between versions 1.68 and 1.78

version 1.68, 2003/10/15 20:34:37 version 1.78, 2004/01/15 03:53:12
Line 25 Line 25
 #  #
 # http://www.lon-capa.org/  # http://www.lon-capa.org/
 #  #
 #  
 # (Routines to control the menu  
 #  
 # (TeX Conversion Module  
 #  
 # 05/29/00,05/30 Gerd Kortemeyer)  
 #  
 # 10/05 Gerd Kortemeyer)  
 #  
 # 10/19,10/20,10/30,  
 # 02/06/01 Gerd Kortemeyer  
 # 07/27 Guy Albertelli  
 # 07/27,07/28,07/30,08/03,08/06,08/08,08/09,08/10,8/13,8/15,  
 # 10/1,11/5 Gerd Kortemeyer  
 # YEAR=2002  
 # 1/1,3/18 Gerd Kortemeyer  
 #  
 package Apache::lonmsg;  package Apache::lonmsg;
   
 =pod  =pod
Line 284  sub author_res_msg { Line 269  sub author_res_msg {
     return 'no_host';      return 'no_host';
 }  }
   
   # =========================================== Retrieve author resource messages
   
   sub retrieve_author_res_msg {
       my $url=shift;
       $url=&Apache::lonnet::declutter($url);
       my ($domain,$author)=($url=~/^(\w+)\/(\w+)\//);
       my %errormsgs=&Apache::lonnet::dump('nohist_res_msgs',$domain,$author);
       my $msgs='';
       foreach (keys %errormsgs) {
    if ($_=~/^\Q$url\E\_\d+$/) {
       my %content=&unpackagemsg($errormsgs{$_});
       $msgs.='<p><img src="/adm/lonMisc/bomb.gif" /><b>'.
    $content{'time'}.'</b>: '.$content{'message'}.
    '<br /></p>';
    }
       } 
       return $msgs;     
   }
   
   
   # =============================== Delete all author messages related to one URL
   
   sub del_url_author_res_msg {
       my $url=shift;
       $url=&Apache::lonnet::declutter($url);
       my ($domain,$author)=($url=~/^(\w+)\/(\w+)\//);
       my @delmsgs=();
       foreach (&Apache::lonnet::getkeys('nohist_res_msgs',$domain,$author)) {
    if ($_=~/^\Q$url\E\_\d+$/) {
       push (@delmsgs,$_);
    }
       }
       return &Apache::lonnet::del('nohist_res_msgs',\@delmsgs,$domain,$author);
   }
   
   # ================= Return hash with URLs for which there is a resource message
   
   sub all_url_author_res_msg {
       my ($author,$domain)=@_;
       my %returnhash=();
       foreach (&Apache::lonnet::getkeys('nohist_res_msgs',$domain,$author)) {
    $_=~/^(.+)\_\d+/;
    $returnhash{$1}=1;
       }
       return %returnhash;
   }
   
 # ================================================== Critical message to a user  # ================================================== Critical message to a user
   
 sub user_crit_msg_raw {  sub user_crit_msg_raw {
Line 607  $content{'sendername'}.'@'. Line 639  $content{'sendername'}.'@'.
  '<input type=checkbox name=sendbck> '.&mt('Send as critical message').' ' .   '<input type=checkbox name=sendbck> '.&mt('Send as critical message').' ' .
  &mt('and return receipt') . $crithelp . '<p>';   &mt('and return receipt') . $crithelp . '<p>';
       }        }
       my %lt=&Apache::lonlocal::texthash(
      'to' => 'To',
      'sb' => 'Subject',
      'sr' => 'Send Reply',
      'ca' => 'Cancel'
      );
       $r->print(<<"ENDREPLY");        $r->print(<<"ENDREPLY");
 <form action="/adm/email" method=post>  <form action="/adm/email" method="post">
 <input type=hidden name=sendreply value="$msgid">  <input type="hidden" name="sendreply" value="$msgid">
 To: $torepl<br />  $lt{'to'}: $torepl<br />
 Subject: <input type=text size=50 name=subject value="$subject"><p>  $lt{'sb'}: <input type="text" size=50 name="subject" value="$subject"><p>
 <textarea name=message cols=84 rows=10 wrap=hard>  <textarea name="message" cols="84" rows="10" wrap="hard">
 $quotemsg  $quotemsg
 </textarea><p>  </textarea></p><br />
 $dispcrit  $dispcrit
 <input type=submit value="Send Reply">  <input type="submit" name="send" value="$lt{'sr'}" />
   <input type="submit" name="cancel" value="$lt{'ca'}"/ >
 </form>  </form>
 ENDREPLY  ENDREPLY
 }  }
Line 764  sub compout { Line 803  sub compout {
     my $dissub='';      my $dissub='';
     my $dismsg='';      my $dismsg='';
     my $func=&mt('Send New');      my $func=&mt('Send New');
       if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {      my %lt=&Apache::lonlocal::texthash('us' => 'Username',
          'do' => 'Domain',
          'ad' => 'Additional Recipients',
          'sb' => 'Subject',
          'ca' => 'Cancel',
          'ma' => 'Mail');
   
       if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
  my $crithelp = Apache::loncommon::help_open_topic("Course_Critical_Message");   my $crithelp = Apache::loncommon::help_open_topic("Course_Critical_Message");
          $dispcrit=           $dispcrit=
  '<input type=checkbox name=critmsg> '.&mt('Send as critical message').' ' . $crithelp .    '<input type="checkbox" name="critmsg"> '.&mt('Send as critical message').' ' . $crithelp . 
  '<br>'.   '<br>'.
  '<input type=checkbox name=sendbck> '.&mt('Send as critical message').'  ' .   '<input type="checkbox" name="sendbck"> '.&mt('Send as critical message').'  ' .
  &mt('and return receipt') . $crithelp . '<p>';   &mt('and return receipt') . $crithelp . '<p>';
       }        }
     if ($forwarding) {      if ($forwarding) {
        $dispcrit.='<input type=hidden name=forwid value="'.         $dispcrit.='<input type="hidden" name="forwid" value="'.
    $forwarding.'">';     $forwarding.'">';
        $func=&mt('Forward');         $func=&mt('Forward');
       my %message=&Apache::lonnet::get('nohist_email',[$forwarding]);        my %message=&Apache::lonnet::get('nohist_email',[$forwarding]);
Line 796  sub compout { Line 842  sub compout {
     ('compemail','recuname','recdomain');      ('compemail','recuname','recdomain');
        $r->print(<<"ENDREC");         $r->print(<<"ENDREC");
 <table>  <table>
 <tr><td>Username:</td><td><input type=text size=12 name=recuname value="$ENV{'form.recname'}"></td><td rowspan="2">$selectlink</td></tr>  <tr><td>$lt{'us'}:</td><td><input type="text" size="12" name="recuname" value="$ENV{'form.recname'}"></td><td rowspan="2">$selectlink</td></tr>
 <tr><td>Domain:</td>  <tr><td>$lt{'do'}:</td>
 <td>$domform</td></tr>  <td>$domform</td></tr>
 ENDREC  ENDREC
     }      }
     my $latexHelp = Apache::loncommon::helpLatexCheatsheet();      my $latexHelp = Apache::loncommon::helpLatexCheatsheet();
     if ($broadcast ne 'upload') {      if ($broadcast ne 'upload') {
        $r->print(<<"ENDCOMP");         $r->print(<<"ENDCOMP");
 <tr><td>Additional Recipients<br><tt>username\@domain,username\@domain, ...  <tr><td>$lt{'ad'}<br /><tt>username\@domain,username\@domain, ...
 </tt></td><td>  </tt></td><td>
 <input type=text size=50 name=additionalrec></td></tr>  <input type="text" size="50" name="additionalrec"></td></tr>
 <tr><td>Subject:</td><td><input type=text size=50 name=subject value="$dissub">  <tr><td>$lt{'sb'}:</td><td><input type="text" size="50" name="subject" value="$dissub">
 </td></tr></table>  </td></tr></table>
 $latexHelp  $latexHelp
 <textarea name=message cols=80 rows=10 wrap=hard>$dismsg  <textarea name="message" cols="80" rows="10" wrap="hard">$dismsg
 </textarea><p>  </textarea></p><br />
 $dispcrit  $dispcrit
 <input type=submit value="$func Mail">  <input type="submit" name="send" value="$func $lt{'ma'}" />
   <input type="submit" name="cancel" value="$lt{'ca'}" />
 ENDCOMP  ENDCOMP
     } else { # $broadcast is 'upload'      } else { # $broadcast is 'upload'
  $r->print(<<ENDUPLOAD);   $r->print(<<ENDUPLOAD);
Line 866  sub disfacetoface { Line 913  sub disfacetoface {
         next if ($content{'senderdomain'} eq '');          next if ($content{'senderdomain'} eq '');
         $content{'message'}=~s/\n/\<br\>/g;          $content{'message'}=~s/\n/\<br\>/g;
         if ($content{'subject'}=~/^Record/) {          if ($content{'subject'}=~/^Record/) {
     $result.='<h3>Record</h3>';      $result.='<h3>'.&mt('Record').'</h3>';
         } else {          } else {
             $result.='<h3>Sent Message</h3>';              $result.='<h3>'.&mt('Sent Message').'</h3>';
             %content=&unpackagemsg($content{'message'});              %content=&unpackagemsg($content{'message'});
             $content{'message'}=              $content{'message'}=
                 '<b>Subject: '.$content{'subject'}.'</b><br />'.                  '<b>Subject: '.$content{'subject'}.'</b><br />'.
  $content{'message'};   $content{'message'};
         }          }
         $result.='By: <b>'.          $result.=&mt('By').': <b>'.
 &Apache::loncommon::aboutmewrapper(  &Apache::loncommon::aboutmewrapper(
  &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).'</b> ('.   &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).'</b> ('.
 $content{'sendername'}.'@'.  $content{'sendername'}.'@'.
Line 977  sub handler { Line 1024  sub handler {
   if (!$ENV{'form.display'}) {    if (!$ENV{'form.display'}) {
       $r->print('<html><head><title>EMail and Messaging</title>'.        $r->print('<html><head><title>EMail and Messaging</title>'.
  &Apache::loncommon::studentbrowser_javascript().'</head>'.   &Apache::loncommon::studentbrowser_javascript().'</head>'.
  &Apache::loncommon::bodytag('EMail and Messages'));   &Apache::loncommon::bodytag('EMail and Messages').
        &Apache::loncommon::help_open_faq(12).
        &Apache::loncommon::help_open_bug('Communication Tools'));
   }    }
   if ($ENV{'form.display'}) {    if ($ENV{'form.display'}) {
       my $msgid=$ENV{'form.display'};        my $msgid=$ENV{'form.display'};
Line 1004  sub handler { Line 1053  sub handler {
       }        }
       $r->print(&Apache::loncommon::studentbrowser_javascript().        $r->print(&Apache::loncommon::studentbrowser_javascript().
  '</head>'.   '</head>'.
  &Apache::loncommon::bodytag('EMail and Messages'));   &Apache::loncommon::bodytag('EMail and Messages').
        &Apache::loncommon::help_open_faq(12).
        &Apache::loncommon::help_open_bug('Communication Tools'));
       $r->print('<b>'.&mt('Subject').':</b> '.$content{'subject'}.        $r->print('<b>'.&mt('Subject').':</b> '.$content{'subject'}.
              '<br><b>'.&mt('From').':</b> '.               '<br><b>'.&mt('From').':</b> '.
 &Apache::loncommon::aboutmewrapper(  &Apache::loncommon::aboutmewrapper(
Line 1038  $content{'sendername'},$content{'senderd Line 1089  $content{'sendername'},$content{'senderd
   } elsif ($ENV{'form.replyto'}) {    } elsif ($ENV{'form.replyto'}) {
       &comprep($r,$ENV{'form.replyto'});        &comprep($r,$ENV{'form.replyto'});
   } elsif ($ENV{'form.sendreply'}) {    } elsif ($ENV{'form.sendreply'}) {
       my $msgid=$ENV{'form.sendreply'};        if ($ENV{'form.send'}) {
       my %message=&Apache::lonnet::get('nohist_email',[$msgid]);    my $msgid=$ENV{'form.sendreply'};
       my %content=&unpackagemsg($message{$msgid},1);    my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
       &statuschange($msgid,'replied');    my %content=&unpackagemsg($message{$msgid},1);
       if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) &&     &statuschange($msgid,'replied');
           (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {    if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) && 
          $r->print(&mt('Sending critical').': '.        (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
                 &user_crit_msg($content{'sendername'},        $r->print(&mt('Sending critical message').': '.
                                  $content{'senderdomain'},   &user_crit_msg($content{'sendername'},
                                  &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),         $content{'senderdomain'},
                                  &Apache::lonfeedback::clear_out_html($ENV{'form.message'}),         &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
                                  $ENV{'form.sendbck'}));         &Apache::lonfeedback::clear_out_html($ENV{'form.message'}),
       } else {         $ENV{'form.sendbck'}));
          $r->print(&mt('Sending').': '.&user_normal_msg($content{'sendername'},    } else {
                                  $content{'senderdomain'},        $r->print(&mt('Sending').': '.&user_normal_msg($content{'sendername'},
                                  &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),       $content{'senderdomain'},
                                  &Apache::lonfeedback::clear_out_html($ENV{'form.message'})));       &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
        &Apache::lonfeedback::clear_out_html($ENV{'form.message'})));
     }
       }        }
       if ($ENV{'form.displayedcrit'}) {        if ($ENV{'form.displayedcrit'}) {
           &discrit($r);            &discrit($r);
Line 1101  $content{'sendername'},$content{'senderd Line 1154  $content{'sendername'},$content{'senderd
   } elsif ($ENV{'form.recordftf'}) {    } elsif ($ENV{'form.recordftf'}) {
       &facetoface($r,$ENV{'form.recordftf'});        &facetoface($r,$ENV{'form.recordftf'});
   } elsif ($ENV{'form.sendmail'}) {    } elsif ($ENV{'form.sendmail'}) {
       my %content=();        my $sendstatus='';
       undef %content;        if ($ENV{'form.send'}) {
       if ($ENV{'form.forwid'}) {    my %content=();
         my $msgid=$ENV{'form.forwid'};    undef %content;
         my %message=&Apache::lonnet::get('nohist_email',[$msgid]);    if ($ENV{'form.forwid'}) {
         %content=&unpackagemsg($message{$msgid},1);        my $msgid=$ENV{'form.forwid'};
         &statuschange($msgid,'forwarded');        my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
         $ENV{'form.message'}.="\n\n-- Forwarded message --\n\n".        %content=&unpackagemsg($message{$msgid},1);
                        $content{'message'};        &statuschange($msgid,'forwarded');
       }        $ENV{'form.message'}.="\n\n-- Forwarded message --\n\n".
       my %toaddr=();    $content{'message'};
       undef %toaddr;    }
       if ($ENV{'form.sendmode'} eq 'group') {    my %toaddr=();
           foreach (keys %ENV) {    undef %toaddr;
       if ($_=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) {    if ($ENV{'form.sendmode'} eq 'group') {
   $toaddr{$1}='';        foreach (keys %ENV) {
               }    if ($_=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) {
           }        $toaddr{$1}='';
       } elsif ($ENV{'form.sendmode'} eq 'upload') {    }
           foreach (split(/[\n\r\f]+/,$ENV{'form.upfile'})) {        }
               my ($rec,$txt)=split(/\s*\:\s*/,$_);    } elsif ($ENV{'form.sendmode'} eq 'upload') {
               if ($txt) {        foreach (split(/[\n\r\f]+/,$ENV{'form.upfile'})) {
   $rec=~s/\@/\:/;    my ($rec,$txt)=split(/\s*\:\s*/,$_);
                   $toaddr{$rec}.=$txt."\n";    if ($txt) {
               }        $rec=~s/\@/\:/;
           }        $toaddr{$rec}.=$txt."\n";
       } else {    }
   $toaddr{$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}}='';        }
       }    } else {
       if ($ENV{'form.additionalrec'}) {        $toaddr{$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}}='';
   foreach (split(/\,/,$ENV{'form.additionalrec'})) {    }
               my ($auname,$audom)=split(/\@/,$_);    if ($ENV{'form.additionalrec'}) {
               $toaddr{$auname.':'.$audom}='';        foreach (split(/\,/,$ENV{'form.additionalrec'})) {
           }    my ($auname,$audom)=split(/\@/,$_);
       }    $toaddr{$auname.':'.$audom}='';
     foreach (keys %toaddr) {        }
       my ($recuname,$recdomain)=split(/\:/,$_);    }
       my $msgtxt=&Apache::lonfeedback::clear_out_html($ENV{'form.message'});    foreach (keys %toaddr) {
       if ($toaddr{$_}) { $msgtxt.='<hr>'.$toaddr{$_}; }            my ($recuname,$recdomain)=split(/\:/,$_);
       if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) &&         my $msgtxt=&Apache::lonfeedback::clear_out_html($ENV{'form.message'});
           (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {        if ($toaddr{$_}) { $msgtxt.='<hr>'.$toaddr{$_}; }    
          $r->print('Sending critical: '.        if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) && 
                 &user_crit_msg($recuname,$recdomain,    (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
                &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),    $r->print(&mt('Sending critical message').' ...');
                                  $msgtxt,                    $sendstatus.=' '.&user_crit_msg($recuname,$recdomain,
                                  $ENV{'form.sendbck'}));     &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
       } else {     $msgtxt,
          $r->print('Sending: '.&user_normal_msg($recuname,$recdomain,     $ENV{'form.sendbck'});
               &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),        } else {
                                  $msgtxt,    $r->print(&mt('Sending').' ...');
                                  $content{'citation'}));                    $sendstatus.=' '.&user_normal_msg($recuname,$recdomain,
                            &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
    $msgtxt,
    $content{'citation'});
         }
         $r->print('<br />');
     }
       }        }
       $r->print('<br>');        if ($sendstatus=~/^(\s*(?:ok|con_delayed)\s*)*$/) {
     }    if ($ENV{'form.displayedcrit'}) {
       if ($ENV{'form.displayedcrit'}) {        &discrit($r);
           &discrit($r);    } else {
         &disall($r);
     }
       } else {        } else {
   &disall($r);    $r->print(
     '<h2><font color="red">'.&mt('Could not deliver message').'</font></h2>'.
     &mt('Please use the browser "Back" button and correct the recipient addresses')
       );
       }        }
   } else {    } else {
       &disall($r);        &disall($r);

Removed from v.1.68  
changed lines
  Added in v.1.78


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