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

version 1.84, 2004/01/31 02:42:44 version 1.87, 2004/03/01 01:19:51
Line 139  sub packagemsg { Line 139  sub packagemsg {
            '<browsermathml>'.$ENV{'browser.mathml'}.'</browsermathml>'.             '<browsermathml>'.$ENV{'browser.mathml'}.'</browsermathml>'.
    '<browserraw>'.$ENV{'HTTP_USER_AGENT'}.'</browserraw>'.     '<browserraw>'.$ENV{'HTTP_USER_AGENT'}.'</browserraw>'.
    '<courseid>'.$ENV{'request.course.id'}.'</courseid>'.     '<courseid>'.$ENV{'request.course.id'}.'</courseid>'.
      '<coursesec>'.$ENV{'request.course.sec'}.'</coursesec>'.
    '<role>'.$ENV{'request.role'}.'</role>'.     '<role>'.$ENV{'request.role'}.'</role>'.
    '<resource>'.$ENV{'request.filename'}.'</resource>'.     '<resource>'.$ENV{'request.filename'}.'</resource>'.
            '<msgid>'.$msgid.'</msgid>'.             '<msgid>'.$msgid.'</msgid>'.
Line 867  ENDCOMP Line 868  ENDCOMP
     } else { # $broadcast is 'upload'      } else { # $broadcast is 'upload'
  $r->print(<<ENDUPLOAD);   $r->print(<<ENDUPLOAD);
 <input type=hidden name=sendmode value=upload>  <input type=hidden name=sendmode value=upload>
   <input type="hidden" name="send" value="on" />
 <h3>Generate messages from a file</h3>  <h3>Generate messages from a file</h3>
 <p>  <p>
 Subject: <input type=text size=50 name=subject>  Subject: <input type=text size=50 name=subject>
Line 1008  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 1021  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'));
       $r->print('<b>'.&mt('Subject').':</b> '.$content{'subject'}.   my %courseinfo=&Apache::lonnet::coursedescription($content{'courseid'});
              '<br><b>'.&mt('From').':</b> '.  
 &Apache::loncommon::aboutmewrapper(   $r->print('<br /><b>'.&mt('Subject').':</b> '.$content{'subject'}.
 &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),    '<br /><b>'.&mt('From').':</b> '.
 $content{'sendername'},$content{'senderdomain'}).' ('.    &Apache::loncommon::aboutmewrapper(
                                  $content{'sendername'}.' at '.       &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),
                                  $content{'senderdomain'}.') '.       $content{'sendername'},$content{'senderdomain'}).' ('.
              '<br><b>'.&mt('Time').':</b> '.$content{'time'}.'<p>'.    $content{'sendername'}.' at '.
              '<table border=2><tr bgcolor="#FFFFAA"><td>'.&mt('Functions').':</td>'.    $content{'senderdomain'}.') '.
            '<td><a href="/adm/email?replyto='.&Apache::lonnet::escape($msgid).$sqs.    ($content{'courseid'}?'<br /><b>'.&mt('Course').':</b> '.$courseinfo{'description'}.
              '"><b>'.&mt('Reply').'</b></a></td>'.     ($content{'coursesec'}?' ('.&mt('Group/Section').': '.$content{'coursesec'}.')':''):'').
            '<td><a href="/adm/email?forward='.&Apache::lonnet::escape($msgid).$sqs.    '<br /><b>'.&mt('Time').':</b> '.$content{'time'}.'<p>'.
              '"><b>'.&mt('Forward').'</b></a></td>'.    '<table border=2><tr bgcolor="#FFFFAA"><td>'.&mt('Functions').':</td>'.
         '<td><a href="/adm/email?markunread='.&Apache::lonnet::escape($msgid).$sqs.    '<td><a href="/adm/email?replyto='.&Apache::lonnet::escape($msgid).$sqs.
              '"><b>'.&mt('Mark Unread').'</b></a></td>'.    '"><b>'.&mt('Reply').'</b></a></td>'.
         '<td><a href="/adm/email?markdel='.&Apache::lonnet::escape($msgid).$sqs.    '<td><a href="/adm/email?forward='.&Apache::lonnet::escape($msgid).$sqs.
              '"><b>Delete</b></a></td>'.    '"><b>'.&mt('Forward').'</b></a></td>'.
  '<td><a href="/adm/email?sortedby='.$ENV{'form.sortedby'}.    '<td><a href="/adm/email?markunread='.&Apache::lonnet::escape($msgid).$sqs.
  '"><b>'.&mt('Display all Messages').'</b></a></td>');    '"><b>'.&mt('Mark Unread').'</b></a></td>'.
       if ($counter > 0){    '<td><a href="/adm/email?markdel='.&Apache::lonnet::escape($msgid).$sqs.
    $r->print('<td><a href="/adm/email?display='.$messages[$counter-1]->[5].$sqs.    '"><b>Delete</b></a></td>'.
            '"><b>'.&mt('Previous').'</b></a></td>');    '<td><a href="/adm/email?sortedby='.$ENV{'form.sortedby'}.
        }    '"><b>'.&mt('Display all Messages').'</b></a></td>');
        if ($counter < $number_of_messages - 1){   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('Next').'</b></a></td>');        '"><b>'.&mt('Previous').'</b></a></td>');
        }   }
        $r->print('</tr></table><p><pre>'.   if ($counter < $number_of_messages - 1){
              &Apache::lontexconvert::msgtexconverted($content{'message'},1).      $r->print('<td><a href="/adm/email?display='.$messages[$counter+1]->[5].$sqs.
              '</pre><hr>'.$content{'citation'});        '"><b>'.&mt('Next').'</b></a></td>');
   } elsif ($ENV{'form.replyto'}) {   }
       &comprep($r,$ENV{'form.replyto'});   $r->print('</tr></table><p><pre>'.
   } elsif ($ENV{'form.sendreply'}) {    &Apache::lontexconvert::msgtexconverted($content{'message'},1).
       if ($ENV{'form.send'}) {    '</pre><hr>'.$content{'citation'});
   my $msgid=$ENV{'form.sendreply'};      } elsif ($ENV{'form.replyto'}) {
   my %message=&Apache::lonnet::get('nohist_email',[$msgid]);   &comprep($r,$ENV{'form.replyto'});
   my %content=&unpackagemsg($message{$msgid},1);      } elsif ($ENV{'form.sendreply'}) {
   &statuschange($msgid,'replied');   if ($ENV{'form.send'}) {
   if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) &&       my $msgid=$ENV{'form.sendreply'};
       (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {      my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
       $r->print(&mt('Sending critical message').': '.      my %content=&unpackagemsg($message{$msgid},1);
  &user_crit_msg($content{'sendername'},      &statuschange($msgid,'replied');
        $content{'senderdomain'},      if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) && 
        &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),   (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
        &Apache::lonfeedback::clear_out_html($ENV{'form.message'}),   $r->print(&mt('Sending critical message').': '.
        $ENV{'form.sendbck'}));    &user_crit_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'}),   $ENV{'form.sendbck'}));
      &Apache::lonfeedback::clear_out_html($ENV{'form.message'})));      } else {
   }   $r->print(&mt('Sending').': '.&user_normal_msg($content{'sendername'},
       }         $content{'senderdomain'},
       if ($ENV{'form.displayedcrit'}) {         &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
           &discrit($r);         &Apache::lonfeedback::clear_out_html($ENV{'form.message'})));
       } else {      }
   &disall($r);   }
       }   if ($ENV{'form.displayedcrit'}) {
   } elsif ($ENV{'form.confirm'}) {      &discrit($r);
       foreach (keys %ENV) {   } else {
           if ($_=~/^form\.rec\_(.*)$/) {      &disall($r);
       $r->print('<b>Confirming Receipt:</b> '.   }
                         &user_crit_received($1).'<br>');      } elsif ($ENV{'form.confirm'}) {
           }   foreach (keys %ENV) {
           if ($_=~/^form\.reprec\_(.*)$/) {      if ($_=~/^form\.rec\_(.*)$/) {
               my $msgid=$1;   $r->print('<b>Confirming Receipt:</b> '.
       $r->print('<b>Confirming Receipt:</b> '.    &user_crit_received($1).'<br>');
                         &user_crit_received($msgid).'<br>');      }
               &comprep($r,$msgid);      if ($_=~/^form\.reprec\_(.*)$/) {
           }   my $msgid=$1;
       }   $r->print('<b>Confirming Receipt:</b> '.
       &discrit($r);    &user_crit_received($msgid).'<br>');
   } elsif ($ENV{'form.critical'}) {   &comprep($r,$msgid);
       &discrit($r);      }
   } elsif ($ENV{'form.forward'}) {   }
       &compout($r,$ENV{'form.forward'});   &discrit($r);
   } elsif ($ENV{'form.markread'}) {      } elsif ($ENV{'form.critical'}) {
   } elsif ($ENV{'form.markdel'}) {   &discrit($r);
       &statuschange($ENV{'form.markdel'},'deleted');      } elsif ($ENV{'form.forward'}) {
       &disall($r);   &compout($r,$ENV{'form.forward'});
   } elsif ($ENV{'form.markeddel'}) {      } elsif ($ENV{'form.markread'}) {
       my $total=0;      } elsif ($ENV{'form.markdel'}) {
       foreach (keys %ENV) {   &statuschange($ENV{'form.markdel'},'deleted');
           if ($_=~/^form\.delmark_(.*)$/) {   &disall($r);
       &statuschange(&Apache::lonnet::unescape($1),'deleted');      } elsif ($ENV{'form.markeddel'}) {
               $total++;   my $total=0;
           }   foreach (keys %ENV) {
       }      if ($_=~/^form\.delmark_(.*)$/) {
       $r->print('Deleted '.$total.' message(s)<p>');   &statuschange(&Apache::lonnet::unescape($1),'deleted');
       &disall($r);   $total++;
   } elsif ($ENV{'form.markunread'}) {      }
       &statuschange($ENV{'form.markunread'},'new');   }
       &disall($r);   $r->print('Deleted '.$total.' message(s)<p>');
   } elsif ($ENV{'form.compose'}) {   &disall($r);
       &compout($r,'',$ENV{'form.compose'});      } elsif ($ENV{'form.markunread'}) {
   } elsif ($ENV{'form.recordftf'}) {   &statuschange($ENV{'form.markunread'},'new');
       &facetoface($r,$ENV{'form.recordftf'});   &disall($r);
   } elsif ($ENV{'form.sendmail'}) {      } elsif ($ENV{'form.compose'}) {
       my $sendstatus='';   &compout($r,'',$ENV{'form.compose'});
       if ($ENV{'form.send'}) {      } elsif ($ENV{'form.recordftf'}) {
   my %content=();   &facetoface($r,$ENV{'form.recordftf'});
   undef %content;      } elsif ($ENV{'form.sendmail'}) {
   if ($ENV{'form.forwid'}) {   my $sendstatus='';
       my $msgid=$ENV{'form.forwid'};   if ($ENV{'form.send'}) {
       my %message=&Apache::lonnet::get('nohist_email',[$msgid]);      my %content=();
       %content=&unpackagemsg($message{$msgid},1);      undef %content;
       &statuschange($msgid,'forwarded');      if ($ENV{'form.forwid'}) {
       $ENV{'form.message'}.="\n\n-- Forwarded message --\n\n".   my $msgid=$ENV{'form.forwid'};
   $content{'message'};   my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
   }   %content=&unpackagemsg($message{$msgid},1);
   my %toaddr=();   &statuschange($msgid,'forwarded');
   undef %toaddr;   $ENV{'form.message'}.="\n\n-- Forwarded message --\n\n".
   if ($ENV{'form.sendmode'} eq 'group') {      $content{'message'};
       foreach (keys %ENV) {      }
   if ($_=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) {      my %toaddr=();
       $toaddr{$1}='';      undef %toaddr;
   }      if ($ENV{'form.sendmode'} eq 'group') {
       }   foreach (keys %ENV) {
   } elsif ($ENV{'form.sendmode'} eq 'upload') {      if ($_=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) {
       foreach (split(/[\n\r\f]+/,$ENV{'form.upfile'})) {   $toaddr{$1}='';
   my ($rec,$txt)=split(/\s*\:\s*/,$_);      }
   if ($txt) {   }
       $rec=~s/\@/\:/;      } elsif ($ENV{'form.sendmode'} eq 'upload') {
       $toaddr{$rec}.=$txt."\n";   foreach (split(/[\n\r\f]+/,$ENV{'form.upfile'})) {
   }      my ($rec,$txt)=split(/\s*\:\s*/,$_);
       }      if ($txt) {
   } else {   $rec=~s/\@/\:/;
       $toaddr{$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}}='';   $toaddr{$rec}.=$txt."\n";
   }      }
   if ($ENV{'form.additionalrec'}) {   }
       foreach (split(/\,/,$ENV{'form.additionalrec'})) {      } else {
   my ($auname,$audom)=split(/\@/,$_);   $toaddr{$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}}='';
   $toaddr{$auname.':'.$audom}='';      }
       }      if ($ENV{'form.additionalrec'}) {
   }   foreach (split(/\,/,$ENV{'form.additionalrec'})) {
   foreach (keys %toaddr) {      my ($auname,$audom)=split(/\@/,$_);
       my ($recuname,$recdomain)=split(/\:/,$_);      $toaddr{$auname.':'.$audom}='';
       my $msgtxt=&Apache::lonfeedback::clear_out_html($ENV{'form.message'});   }
       if ($toaddr{$_}) { $msgtxt.='<hr>'.$toaddr{$_}; }          }
       if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) &&       foreach (keys %toaddr) {
   (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {   my ($recuname,$recdomain)=split(/\:/,$_);
   $r->print(&mt('Sending critical message').' ...');   my $msgtxt=&Apache::lonfeedback::clear_out_html($ENV{'form.message'});
                   $sendstatus.=' '.&user_crit_msg($recuname,$recdomain,   if ($toaddr{$_}) { $msgtxt.='<hr>'.$toaddr{$_}; }    
    &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),   if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) && 
    $msgtxt,      (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
    $ENV{'form.sendbck'});      $r->print(&mt('Sending critical message').' ...');
       } else {      $sendstatus.=' '.&user_crit_msg($recuname,$recdomain,
   $r->print(&mt('Sending').' ...');      &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
                   $sendstatus.=' '.&user_normal_msg($recuname,$recdomain,      $msgtxt,
                          &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),      $ENV{'form.sendbck'});
  $msgtxt,   } else {
  $content{'citation'});      $r->print(&mt('Sending').' ...');
       }      $sendstatus.=' '.&user_normal_msg($recuname,$recdomain,
       $r->print('<br />');        &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
   }        $msgtxt,
       }        $content{'citation'});
       if ($sendstatus=~/^(\s*(?:ok|con_delayed)\s*)*$/) {   }
   $r->print('<br /><font color="green">'.&mt('Completed.').'</font>');   $r->print('<br />');
   if ($ENV{'form.displayedcrit'}) {      }
       &discrit($r);   }
   } else {   if ($sendstatus=~/^(\s*(?:ok|con_delayed)\s*)*$/) {
       &disall($r);      $r->print('<br /><font color="green">'.&mt('Completed.').'</font>');
   }      if ($ENV{'form.displayedcrit'}) {
       } else {   &discrit($r);
   $r->print(      } else {
   '<h2><font color="red">'.&mt('Could not deliver message').'</font></h2>'.   &disall($r);
   &mt('Please use the browser "Back" button and correct the recipient addresses')      }
     );   } else {
       }      $r->print(
   } else {        '<h2><font color="red">'.&mt('Could not deliver message').'</font></h2>'.
       &disall($r);        &mt('Please use the browser "Back" button and correct the recipient addresses')
   }        );
   $r->print('</body></html>');   }
   return OK;      } else {
    &disall($r);
       }
       $r->print('</body></html>');
       return OK;
 }  }
 # ================================================= Main program, reset counter  # ================================================= Main program, reset counter
   

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


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