Diff for /loncom/interface/lonmsg.pm between versions 1.86 and 1.87

version 1.86, 2004/03/01 01:06:10 version 1.87, 2004/03/01 01:19:51
Line 1010  sub handler { Line 1010  sub handler {
     my $r=shift;      my $r=shift;
   
 # ----------------------------------------------------------- Set document type  # ----------------------------------------------------------- Set document type
       
   &Apache::loncommon::content_type($r,'text/html');      &Apache::loncommon::content_type($r,'text/html');
   $r->send_http_header;      $r->send_http_header;
       
   return OK if $r->header_only;      return OK if $r->header_only;
       
 # --------------------------- Get query string for limited number of parameters  # --------------------------- Get query string for limited number of parameters
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
         ['display','replyto','forward','markread','markdel','markunread',          ['display','replyto','forward','markread','markdel','markunread',
Line 1023  sub handler { Line 1023  sub handler {
          'recordftf','sortedby']);           'recordftf','sortedby']);
     $sqs='&sortedby='.$ENV{'form.sortedby'};      $sqs='&sortedby='.$ENV{'form.sortedby'};
 # ------------------------------------------------------ They checked for email  # ------------------------------------------------------ They checked for email
   &Apache::lonnet::put('email_status',{'recnewemail'=>0});      &Apache::lonnet::put('email_status',{'recnewemail'=>0});
 # --------------------------------------------------------------- Render Output  # --------------------------------------------------------------- Render Output
   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_faq(12).
      &Apache::loncommon::help_open_bug('Communication Tools'));    &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'};
       &statuschange($msgid,'read');   &statuschange($msgid,'read');
       my %message=&Apache::lonnet::get('nohist_email',[$msgid]);   my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
       my %content=&unpackagemsg($message{$msgid});   my %content=&unpackagemsg($message{$msgid});
 # info to generate "next" and "previous" buttons  # info to generate "next" and "previous" buttons
       my @messages=&sortedmessages();   my @messages=&sortedmessages();
       my $counter=0;   my $counter=0;
       $r->print('<pre>');   $r->print('<pre>');
       my $escmsgid=&Apache::lonnet::escape($msgid);   my $escmsgid=&Apache::lonnet::escape($msgid);
       foreach (@messages) {   foreach (@messages) {
    if ($_->[5] eq $escmsgid){      if ($_->[5] eq $escmsgid){
        last;   last;
    }      }
    $counter++;      $counter++;
       }   }
       $r->print('</pre>');   $r->print('</pre>');
       my $number_of_messages = scalar(@messages); #subtract 1 for last index   my $number_of_messages = scalar(@messages); #subtract 1 for last index
 # start output  # start output
       $r->print('<html><head><title>EMail and Messaging</title>');   $r->print('<html><head><title>EMail and Messaging</title>');
       if (defined($content{'baseurl'})) {   if (defined($content{'baseurl'})) {
   $r->print("<base href=\"http://$ENV{'SERVER_NAME'}/$content{'baseurl'}\" />");      $r->print("<base href=\"http://$ENV{'SERVER_NAME'}/$content{'baseurl'}\" />");
       }   }
       $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_faq(12).
      &Apache::loncommon::help_open_bug('Communication Tools'));    &Apache::loncommon::help_open_bug('Communication Tools'));
       my %courseinfo=&Apache::lonnet::coursedescription($content{'courseid'});   my %courseinfo=&Apache::lonnet::coursedescription($content{'courseid'});
   
       $r->print('<br /><b>'.&mt('Subject').':</b> '.$content{'subject'}.   $r->print('<br /><b>'.&mt('Subject').':</b> '.$content{'subject'}.
              '<br /><b>'.&mt('From').':</b> '.    '<br /><b>'.&mt('From').':</b> '.
 &Apache::loncommon::aboutmewrapper(    &Apache::loncommon::aboutmewrapper(
 &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),       &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),
 $content{'sendername'},$content{'senderdomain'}).' ('.       $content{'sendername'},$content{'senderdomain'}).' ('.
                                  $content{'sendername'}.' at '.    $content{'sendername'}.' at '.
                                  $content{'senderdomain'}.') '.    $content{'senderdomain'}.') '.
      ($content{'courseid'}?'<br /><b>'.&mt('Course').':</b> '.$courseinfo{'description'}.    ($content{'courseid'}?'<br /><b>'.&mt('Course').':</b> '.$courseinfo{'description'}.
 ($content{'coursesec'}?' ('.&mt('Group/Section').': '.$content{'coursesec'}.')':''):'').     ($content{'coursesec'}?' ('.&mt('Group/Section').': '.$content{'coursesec'}.')':''):'').
              '<br /><b>'.&mt('Time').':</b> '.$content{'time'}.'<p>'.    '<br /><b>'.&mt('Time').':</b> '.$content{'time'}.'<p>'.
              '<table border=2><tr bgcolor="#FFFFAA"><td>'.&mt('Functions').':</td>'.    '<table border=2><tr bgcolor="#FFFFAA"><td>'.&mt('Functions').':</td>'.
            '<td><a href="/adm/email?replyto='.&Apache::lonnet::escape($msgid).$sqs.    '<td><a href="/adm/email?replyto='.&Apache::lonnet::escape($msgid).$sqs.
              '"><b>'.&mt('Reply').'</b></a></td>'.    '"><b>'.&mt('Reply').'</b></a></td>'.
            '<td><a href="/adm/email?forward='.&Apache::lonnet::escape($msgid).$sqs.    '<td><a href="/adm/email?forward='.&Apache::lonnet::escape($msgid).$sqs.
              '"><b>'.&mt('Forward').'</b></a></td>'.    '"><b>'.&mt('Forward').'</b></a></td>'.
         '<td><a href="/adm/email?markunread='.&Apache::lonnet::escape($msgid).$sqs.    '<td><a href="/adm/email?markunread='.&Apache::lonnet::escape($msgid).$sqs.
              '"><b>'.&mt('Mark Unread').'</b></a></td>'.    '"><b>'.&mt('Mark Unread').'</b></a></td>'.
         '<td><a href="/adm/email?markdel='.&Apache::lonnet::escape($msgid).$sqs.    '<td><a href="/adm/email?markdel='.&Apache::lonnet::escape($msgid).$sqs.
              '"><b>Delete</b></a></td>'.    '"><b>Delete</b></a></td>'.
  '<td><a href="/adm/email?sortedby='.$ENV{'form.sortedby'}.    '<td><a href="/adm/email?sortedby='.$ENV{'form.sortedby'}.
  '"><b>'.&mt('Display all Messages').'</b></a></td>');    '"><b>'.&mt('Display all Messages').'</b></a></td>');
       if ($counter > 0){   if ($counter > 0){
    $r->print('<td><a href="/adm/email?display='.$messages[$counter-1]->[5].$sqs.      $r->print('<td><a href="/adm/email?display='.$messages[$counter-1]->[5].$sqs.
            '"><b>'.&mt('Previous').'</b></a></td>');        '"><b>'.&mt('Previous').'</b></a></td>');
        }   }
        if ($counter < $number_of_messages - 1){   if ($counter < $number_of_messages - 1){
    $r->print('<td><a href="/adm/email?display='.$messages[$counter+1]->[5].$sqs.      $r->print('<td><a href="/adm/email?display='.$messages[$counter+1]->[5].$sqs.
            '"><b>'.&mt('Next').'</b></a></td>');        '"><b>'.&mt('Next').'</b></a></td>');
        }   }
        $r->print('</tr></table><p><pre>'.   $r->print('</tr></table><p><pre>'.
              &Apache::lontexconvert::msgtexconverted($content{'message'},1).    &Apache::lontexconvert::msgtexconverted($content{'message'},1).
              '</pre><hr>'.$content{'citation'});    '</pre><hr>'.$content{'citation'});
   } 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'}) {
       if ($ENV{'form.send'}) {   if ($ENV{'form.send'}) {
   my $msgid=$ENV{'form.sendreply'};      my $msgid=$ENV{'form.sendreply'};
   my %message=&Apache::lonnet::get('nohist_email',[$msgid]);      my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
   my %content=&unpackagemsg($message{$msgid},1);      my %content=&unpackagemsg($message{$msgid},1);
   &statuschange($msgid,'replied');      &statuschange($msgid,'replied');
   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'}))) {
       $r->print(&mt('Sending critical message').': '.   $r->print(&mt('Sending critical message').': '.
  &user_crit_msg($content{'sendername'},    &user_crit_msg($content{'sendername'},
        $content{'senderdomain'},   $content{'senderdomain'},
        &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),   &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
        &Apache::lonfeedback::clear_out_html($ENV{'form.message'}),   &Apache::lonfeedback::clear_out_html($ENV{'form.message'}),
        $ENV{'form.sendbck'}));   $ENV{'form.sendbck'}));
   } else {      } else {
       $r->print(&mt('Sending').': '.&user_normal_msg($content{'sendername'},   $r->print(&mt('Sending').': '.&user_normal_msg($content{'sendername'},
      $content{'senderdomain'},         $content{'senderdomain'},
      &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),         &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
      &Apache::lonfeedback::clear_out_html($ENV{'form.message'})));         &Apache::lonfeedback::clear_out_html($ENV{'form.message'})));
   }      }
       }   }
       if ($ENV{'form.displayedcrit'}) {   if ($ENV{'form.displayedcrit'}) {
           &discrit($r);      &discrit($r);
       } else {   } else {
   &disall($r);      &disall($r);
       }   }
   } elsif ($ENV{'form.confirm'}) {      } elsif ($ENV{'form.confirm'}) {
       foreach (keys %ENV) {   foreach (keys %ENV) {
           if ($_=~/^form\.rec\_(.*)$/) {      if ($_=~/^form\.rec\_(.*)$/) {
       $r->print('<b>Confirming Receipt:</b> '.   $r->print('<b>Confirming Receipt:</b> '.
                         &user_crit_received($1).'<br>');    &user_crit_received($1).'<br>');
           }      }
           if ($_=~/^form\.reprec\_(.*)$/) {      if ($_=~/^form\.reprec\_(.*)$/) {
               my $msgid=$1;   my $msgid=$1;
       $r->print('<b>Confirming Receipt:</b> '.   $r->print('<b>Confirming Receipt:</b> '.
                         &user_crit_received($msgid).'<br>');    &user_crit_received($msgid).'<br>');
               &comprep($r,$msgid);   &comprep($r,$msgid);
           }      }
       }   }
       &discrit($r);   &discrit($r);
   } elsif ($ENV{'form.critical'}) {      } elsif ($ENV{'form.critical'}) {
       &discrit($r);   &discrit($r);
   } elsif ($ENV{'form.forward'}) {      } elsif ($ENV{'form.forward'}) {
       &compout($r,$ENV{'form.forward'});   &compout($r,$ENV{'form.forward'});
   } elsif ($ENV{'form.markread'}) {      } elsif ($ENV{'form.markread'}) {
   } elsif ($ENV{'form.markdel'}) {      } elsif ($ENV{'form.markdel'}) {
       &statuschange($ENV{'form.markdel'},'deleted');   &statuschange($ENV{'form.markdel'},'deleted');
       &disall($r);   &disall($r);
   } elsif ($ENV{'form.markeddel'}) {      } elsif ($ENV{'form.markeddel'}) {
       my $total=0;   my $total=0;
       foreach (keys %ENV) {   foreach (keys %ENV) {
           if ($_=~/^form\.delmark_(.*)$/) {      if ($_=~/^form\.delmark_(.*)$/) {
       &statuschange(&Apache::lonnet::unescape($1),'deleted');   &statuschange(&Apache::lonnet::unescape($1),'deleted');
               $total++;   $total++;
           }      }
       }   }
       $r->print('Deleted '.$total.' message(s)<p>');   $r->print('Deleted '.$total.' message(s)<p>');
       &disall($r);   &disall($r);
   } elsif ($ENV{'form.markunread'}) {      } elsif ($ENV{'form.markunread'}) {
       &statuschange($ENV{'form.markunread'},'new');   &statuschange($ENV{'form.markunread'},'new');
       &disall($r);   &disall($r);
   } elsif ($ENV{'form.compose'}) {      } elsif ($ENV{'form.compose'}) {
       &compout($r,'',$ENV{'form.compose'});   &compout($r,'',$ENV{'form.compose'});
   } 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 $sendstatus='';   my $sendstatus='';
       if ($ENV{'form.send'}) {   if ($ENV{'form.send'}) {
   my %content=();      my %content=();
   undef %content;      undef %content;
   if ($ENV{'form.forwid'}) {      if ($ENV{'form.forwid'}) {
       my $msgid=$ENV{'form.forwid'};   my $msgid=$ENV{'form.forwid'};
       my %message=&Apache::lonnet::get('nohist_email',[$msgid]);   my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
       %content=&unpackagemsg($message{$msgid},1);   %content=&unpackagemsg($message{$msgid},1);
       &statuschange($msgid,'forwarded');   &statuschange($msgid,'forwarded');
       $ENV{'form.message'}.="\n\n-- Forwarded message --\n\n".   $ENV{'form.message'}.="\n\n-- Forwarded message --\n\n".
   $content{'message'};      $content{'message'};
   }      }
   my %toaddr=();      my %toaddr=();
   undef %toaddr;      undef %toaddr;
   if ($ENV{'form.sendmode'} eq 'group') {      if ($ENV{'form.sendmode'} eq 'group') {
       foreach (keys %ENV) {   foreach (keys %ENV) {
   if ($_=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) {      if ($_=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) {
       $toaddr{$1}='';   $toaddr{$1}='';
   }      }
       }   }
   } elsif ($ENV{'form.sendmode'} eq 'upload') {      } elsif ($ENV{'form.sendmode'} eq 'upload') {
       foreach (split(/[\n\r\f]+/,$ENV{'form.upfile'})) {   foreach (split(/[\n\r\f]+/,$ENV{'form.upfile'})) {
   my ($rec,$txt)=split(/\s*\:\s*/,$_);      my ($rec,$txt)=split(/\s*\:\s*/,$_);
   if ($txt) {      if ($txt) {
       $rec=~s/\@/\:/;   $rec=~s/\@/\:/;
       $toaddr{$rec}.=$txt."\n";   $toaddr{$rec}.=$txt."\n";
   }      }
       }   }
   } else {      } else {
       $toaddr{$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}}='';   $toaddr{$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}}='';
   }      }
   if ($ENV{'form.additionalrec'}) {      if ($ENV{'form.additionalrec'}) {
       foreach (split(/\,/,$ENV{'form.additionalrec'})) {   foreach (split(/\,/,$ENV{'form.additionalrec'})) {
   my ($auname,$audom)=split(/\@/,$_);      my ($auname,$audom)=split(/\@/,$_);
   $toaddr{$auname.':'.$audom}='';      $toaddr{$auname.':'.$audom}='';
       }   }
   }      }
   foreach (keys %toaddr) {      foreach (keys %toaddr) {
       my ($recuname,$recdomain)=split(/\:/,$_);   my ($recuname,$recdomain)=split(/\:/,$_);
       my $msgtxt=&Apache::lonfeedback::clear_out_html($ENV{'form.message'});   my $msgtxt=&Apache::lonfeedback::clear_out_html($ENV{'form.message'});
       if ($toaddr{$_}) { $msgtxt.='<hr>'.$toaddr{$_}; }       if ($toaddr{$_}) { $msgtxt.='<hr>'.$toaddr{$_}; }    
       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'}))) {
   $r->print(&mt('Sending critical message').' ...');      $r->print(&mt('Sending critical message').' ...');
                   $sendstatus.=' '.&user_crit_msg($recuname,$recdomain,      $sendstatus.=' '.&user_crit_msg($recuname,$recdomain,
    &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),      &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
    $msgtxt,      $msgtxt,
    $ENV{'form.sendbck'});      $ENV{'form.sendbck'});
       } else {   } else {
   $r->print(&mt('Sending').' ...');      $r->print(&mt('Sending').' ...');
                   $sendstatus.=' '.&user_normal_msg($recuname,$recdomain,      $sendstatus.=' '.&user_normal_msg($recuname,$recdomain,
                          &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),        &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
  $msgtxt,        $msgtxt,
  $content{'citation'});        $content{'citation'});
       }   }
       $r->print('<br />');   $r->print('<br />');
   }      }
       }   }
       if ($sendstatus=~/^(\s*(?:ok|con_delayed)\s*)*$/) {   if ($sendstatus=~/^(\s*(?:ok|con_delayed)\s*)*$/) {
   $r->print('<br /><font color="green">'.&mt('Completed.').'</font>');      $r->print('<br /><font color="green">'.&mt('Completed.').'</font>');
   if ($ENV{'form.displayedcrit'}) {      if ($ENV{'form.displayedcrit'}) {
       &discrit($r);   &discrit($r);
   } else {      } else {
       &disall($r);   &disall($r);
   }      }
       } else {   } else {
   $r->print(      $r->print(
   '<h2><font color="red">'.&mt('Could not deliver message').'</font></h2>'.        '<h2><font color="red">'.&mt('Could not deliver message').'</font></h2>'.
   &mt('Please use the browser "Back" button and correct the recipient addresses')        &mt('Please use the browser "Back" button and correct the recipient addresses')
     );        );
       }   }
   } else {      } else {
       &disall($r);   &disall($r);
   }      }
   $r->print('</body></html>');      $r->print('</body></html>');
   return OK;      return OK;
   
 }  }
 # ================================================= Main program, reset counter  # ================================================= Main program, reset counter
   

Removed from v.1.86  
changed lines
  Added in v.1.87


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