Diff for /loncom/interface/lonmsgdisplay.pm between versions 1.3 and 1.9

version 1.3, 2006/04/22 17:03:43 version 1.9, 2006/04/23 05:34:45
Line 184  sub statuschange { Line 184  sub statuschange {
  &Apache::lonnet::put('email_status'.$suffix,{$msgid => $newstatus});   &Apache::lonnet::put('email_status'.$suffix,{$msgid => $newstatus});
     }      }
     if ($newstatus eq 'deleted') {      if ($newstatus eq 'deleted') {
        &movemsg(&Apache::lonnet::unescape($msgid),$folder,'trash');   return &movemsg($msgid,$folder,'trash');
    }      }
       return ;
 }  }
   
 # ============================================================= Make new folder  # ============================================================= Make new folder
Line 206  sub movemsg { Line 207  sub movemsg {
     if ($srcfolder eq 'new') { $srcfolder=''; }      if ($srcfolder eq 'new') { $srcfolder=''; }
     my $srcsuffix=&Apache::lonmsg::foldersuffix($srcfolder);      my $srcsuffix=&Apache::lonmsg::foldersuffix($srcfolder);
     my $trgsuffix=&Apache::lonmsg::foldersuffix($trgfolder);      my $trgsuffix=&Apache::lonmsg::foldersuffix($trgfolder);
       if ($srcsuffix eq $trgsuffix) {
    return (0,&mt('Message not moved, Attempted to move message to the same folder as it already is in.'));
       }
   
 # Copy message  # Copy message
     my %message=&Apache::lonnet::get('nohist_email'.$srcsuffix,[$msgid]);      my %message=&Apache::lonnet::get('nohist_email'.$srcsuffix,[$msgid]);
     &Apache::lonnet::put('nohist_email'.$trgsuffix,{$msgid => $message{$msgid}});      if (!exists($message{$msgid}) || $message{$msgid} eq '') {
    if (&Apache::slotrequest::network_error(%message)) {
       return (0,&mt('Message not moved, A network error occurred.'));
    } else {
       return (0,&mt('Message not moved as the message is no longer in the source folder.'));
    }
       }
   
       my $result =&Apache::lonnet::put('nohist_email'.$trgsuffix,
        {$msgid => $message{$msgid}});
       if (&Apache::slotrequest::network_error($result)) {
    return (0,&mt('Message not moved, A network error occurred.'));
       }
   
 # Copy status  # Copy status
     unless ($trgfolder eq 'trash') {      unless ($trgfolder eq 'trash') {
  my %status=&Apache::lonnet::get('email_status'.$srcsuffix,[$msgid]);          my %status=&Apache::lonnet::get('email_status'.$srcsuffix,[$msgid]);
  &Apache::lonnet::put('email_status'.$trgsuffix,{$msgid => $status{$msgid}});   # a non-existant status is the mark of an unread msg
    if (&Apache::slotrequest::network_error(%status)) {
       return (0,&mt('Message copied to new folder but status was not, A network error occurred.'));
    }
    my $result=&Apache::lonnet::put('email_status'.$trgsuffix,
    {$msgid => $status{$msgid}});
    if (&Apache::slotrequest::network_error($result)) {
       return (0,&mt('Message copied to new folder but status was not, A network error occurred.'));
    }
     }      }
   
 # Delete orginals  # Delete orginals
     &Apache::lonnet::del('nohist_email'.$srcsuffix,[$msgid]);      my $result_del_msg = 
     &Apache::lonnet::del('email_status'.$srcsuffix,[$msgid]);   &Apache::lonnet::del('nohist_email'.$srcsuffix,[$msgid]);
       my $result_del_stat =
    &Apache::lonnet::del('email_status'.$srcsuffix,[$msgid]);
       if (&Apache::slotrequest::network_error($result_del_msg)) {
    return (0,&mt('Message copied, but unable to delete the original from the source folder.'));
       }
       if (&Apache::slotrequest::network_error($result_del_stat)) {
    return (0,&mt('Message copied, but unable to delete the original status from the source folder.'));
       }
   
       return (1);
 }  }
   
 # ======================================================= Display a course list  # ======================================================= Display a course list
Line 313  ENDDISHEADER Line 348  ENDDISHEADER
   
 sub discrit {  sub discrit {
     my $r=shift;      my $r=shift;
     my $header = '<h1><font color=red>'.&mt('Critical Messages').'</font></h1>'.      my $header = '<h1><font color="red">'.&mt('Critical Messages').'</font></h1>'.
         '<form action="/adm/email" method="POST">'.          '<form action="/adm/email" method="POST">'.
         '<input type="hidden" name="confirm" value="true" />';          '<input type="hidden" name="confirm" value="true" />';
     my %what=&Apache::lonnet::dump('critical');      my %what=&Apache::lonnet::dump('critical');
Line 478  sub disnew { Line 513  sub disnew {
                     push @newmsgs, {                       push @newmsgs, { 
                         msgid    => $msgid,                          msgid    => $msgid,
                         sendtime => $sendtime,                          sendtime => $sendtime,
                         shortsub => &Apache::lonnet::unescape($shortsubj),                          shortsub => $shortsubj,
                         from     => $fromname,                          from     => $fromname,
                         fromdom  => $fromdom,                          fromdom  => $fromdom,
                         course   => $description                           course   => $description 
Line 490  sub disnew { Line 525  sub disnew {
     if ($#newmsgs >= 0) {      if ($#newmsgs >= 0) {
         $r->print(<<TABLEHEAD);          $r->print(<<TABLEHEAD);
 <h2>$lt{'nm'}</h2>  <h2>$lt{'nm'}</h2>
 <table border=2><tr><th>&nbsp</th>  <table class="LC_mail_list"><tr><th>&nbsp</th>
 <th>$lt{'da'}</th><th>$lt{'us'}</th><th>$lt{'do'}</th><th>$lt{'su'}</th><th>$lt{'co'}</th></tr>  <th>$lt{'da'}</th><th>$lt{'us'}</th><th>$lt{'do'}</th><th>$lt{'su'}</th><th>$lt{'co'}</th></tr>
 TABLEHEAD  TABLEHEAD
         foreach my $msg (@newmsgs) {          foreach my $msg (@newmsgs) {
             $r->print(<<"ENDLINK");              $r->print(<<"ENDLINK");
 <tr class="new" bgcolor="#FFBB77" onMouseOver="javascript:style.backgroundColor='#DD9955'"   <tr class="LC_mail_new">
 onMouseOut="javascript:style.backgroundColor='#FFBB77'">  
 <td><a href="/adm/email?dismode=new&display=$msg->{'msgid'}">$lt{'op'}</a></td>  <td><a href="/adm/email?dismode=new&display=$msg->{'msgid'}">$lt{'op'}</a></td>
 ENDLINK  ENDLINK
             foreach ('sendtime','from','fromdom','shortsub','course') {              foreach ('sendtime','from','fromdom','shortsub','course') {
Line 588  ENDDISHEADER Line 622  ENDDISHEADER
     if ($lastdis>$#temp) { $lastdis=$#temp; }      if ($lastdis>$#temp) { $lastdis=$#temp; }
     $r->print(&scrollbuttons($startdis,$number,$firstdis,$lastdis,$totalnumber));      $r->print(&scrollbuttons($startdis,$number,$firstdis,$lastdis,$totalnumber));
     $r->print('<form method="post" name="disall" action="/adm/email">'.      $r->print('<form method="post" name="disall" action="/adm/email">'.
       '<table border=2><tr><th colspan="3">&nbsp</th><th>');        '<table class="LC_mail_list"><tr><th colspan="3">&nbsp</th><th>');
     if ($env{'form.sortedby'} eq "revdate") {      if ($env{'form.sortedby'} eq "revdate") {
  $r->print('<a href = "?sortedby=date'.$fsqs.'">'.&mt('Date').'</a></th>');   $r->print('<a href = "?sortedby=date'.$fsqs.'">'.&mt('Date').'</a></th>');
     } else {      } else {
Line 625  ENDDISHEADER Line 659  ENDDISHEADER
       $r->print('<a href = "?sortedby=revstatus'.$fsqs.'">'.&mt('Status').'</a></th>');        $r->print('<a href = "?sortedby=revstatus'.$fsqs.'">'.&mt('Status').'</a></th>');
     }      }
     $r->print("</tr>\n");      $r->print("</tr>\n");
   
       my $suffix = &Apache::lonmsg::foldersuffix($folder);
     for (my $n=$firstdis;$n<=$lastdis;$n++) {      for (my $n=$firstdis;$n<=$lastdis;$n++) {
  my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$origID,$description)= @{$temp[$n]};   my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$origID,$description)= @{$temp[$n]};
  if (($status ne 'deleted') && defined($sendtime) && $sendtime!~/error/) {   if (($status ne 'deleted') && defined($sendtime) && $sendtime!~/error/) {
     if ($status eq 'new') {      if ($status eq 'new') {
  $r->print('<tr bgcolor="#FFBB77" onMouseOver="javascript:style.backgroundColor=\'#DD9955\'"  onMouseOut="javascript:style.backgroundColor=\'#FFBB77\'">');   $r->print('<tr class="LC_mail_new">');
     } elsif ($status eq 'read') {      } elsif ($status eq 'read') {
  $r->print('<tr bgcolor="#BBBB77" onMouseOver="javascript:style.backgroundColor=\'#999944\'"  onMouseOut="javascript:style.backgroundColor=\'#BBBB77\'">');   $r->print('<tr class="LC_mail_read">');
     } elsif ($status eq 'replied') {      } elsif ($status eq 'replied') {
  $r->print('<tr bgcolor="#AAAA88" onMouseOver="javascript:style.backgroundColor=\'#888855\'"  onMouseOut="javascript:style.backgroundColor=\'#AAAA88\'">');    $r->print('<tr class="LC_mail_replied">'); 
     } else {      } else {
  $r->print('<tr bgcolor="#99BBBB" onMouseOver="javascript:style.backgroundColor=\'#669999\'"  onMouseOut="javascript:style.backgroundColor=\'#99BBBB\'">');   $r->print('<tr class="LC_mail_other">');
       }
       my ($dis_name,$dis_domain) = ($fromname,$fromdomain);
       if ($folder eq 'sent') {
    my $msg_id = &Apache::lonnet::unescape($origID);
    my %message=&Apache::lonnet::get('nohist_email'.$suffix,
    [$msg_id]);
    my %content=&Apache::lonmsg::unpackagemsg($message{$msg_id});
    $dis_name   = join('<br />',@{$content{'recuser'}});
    $dis_domain = join('<br />',@{$content{'recdomain'}});
     }      }
     $r->print('<td><input type="checkbox" name="delmark_'.$origID.'" /></td><td><a href="/adm/email?display='.$origID.$sqs.       $r->print('<td><input type="checkbox" name="delmark_'.$origID.'" /></td><td><a href="/adm/email?display='.$origID.$sqs. 
       '">'.&mt('Open').'</a></td><td>'.        '">'.&mt('Open').'</a></td><td>'.
       ($folder ne 'trash'?'<a href="/adm/email?markdel='.$origID.$sqs.        ($folder ne 'trash'?'<a href="/adm/email?markdel='.$origID.$sqs.
       '">'.&mt('Delete'):'&nbsp').'</a></td>'.        '">'.&mt('Delete'):'&nbsp').'</a></td>'.
       '<td>'.&Apache::lonlocal::locallocaltime($sendtime).'</td><td>'.        '<td>'.&Apache::lonlocal::locallocaltime($sendtime).'</td><td>'.
       $fromname.'</td><td>'.$fromdomain.'</td><td>'.        $dis_name.'</td><td>'.$dis_domain.'</td><td>'.
       &Apache::lonnet::unescape($shortsubj).'</td><td>'.        $shortsubj.'</td><td>'.
                       $description.'</td><td>'.$status.'</td></tr>'."\n");                        $description.'</td><td>'.$status.'</td></tr>'."\n");
  } elsif ($status eq 'deleted') {   } elsif ($status eq 'deleted') {
 # purge  # purge
     &movemsg(&Apache::lonnet::unescape($origID),$folder,'trash');      my ($result,$msg) = 
    &movemsg(&Apache::lonnet::unescape($origID),$folder,'trash');
       
  }   }
     }         }   
     $r->print("</table>\n<p>".      $r->print("</table>\n<p>".
Line 1666  sub sendoffmail { Line 1713  sub sendoffmail {
         my $savemsg;          my $savemsg;
         my $msgtype;          my $msgtype;
         my %sentmessage;          my %sentmessage;
         my $msgsubj=&Apache::lonfeedback::clear_out_html($env{'form.subject'});          my $msgsubj=&Apache::lonfeedback::clear_out_html($env{'form.subject'},
    undef,1);
         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 1768  sub sendoffmail { Line 1816  sub sendoffmail {
  &printheader($r,'','No messages sent.');    &printheader($r,'','No messages sent.'); 
     }      }
     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 /><span class="LC_success">'.&mt('Completed.').'</span>');
  if ($env{'form.displayedcrit'}) {   if ($env{'form.displayedcrit'}) {
     &discrit($r);      &discrit($r);
  } else {   } else {
     &Apache::loncommunicate::menu($r);      &Apache::loncommunicate::menu($r);
  }   }
     } else {      } else {
  $r->print(   $r->print('<p><span class="LC_error">'.&mt('Could not deliver message').'</span> '.
   '<h2><font color="red">'.&mt('Could not deliver message').'</font></h2>'.    &mt('Please use the browser "Back" button and correct the recipient addresses').'</p>');
   &mt('Please use the browser "Back" button and correct the recipient addresses')  
   );  
     }      }
 }  }
   
Line 1885  sub handler { Line 1931  sub handler {
  &compout($r,$env{'form.forward'},undef,undef,undef,$folder);   &compout($r,$env{'form.forward'},undef,undef,undef,$folder);
     } elsif ($env{'form.markdel'}) {      } elsif ($env{'form.markdel'}) {
  &printheader($r,'','Deleted Message');   &printheader($r,'','Deleted Message');
  &statuschange($env{'form.markdel'},'deleted',$folder);   my ($result,$msg) = 
       &statuschange($env{'form.markdel'},'deleted',$folder);
    if (!$result) {
       $r->print('<p class="LC_error">Failed to delete the message.</p>'.
         '<p class="LC_error">'.$msg."</p>\n");
    }
  &Apache::loncommunicate::menu($r);   &Apache::loncommunicate::menu($r);
  &disall($r,($folder?$folder:$dismode));   &disall($r,($folder?$folder:$dismode));
     } elsif ($env{'form.markedmove'}) {      } elsif ($env{'form.markedmove'}) {
  my $total=0;   my ($total,$failed,@failed_msg)=(0,0);
  foreach (keys %env) {   foreach my $key (keys(%env)) {
     if ($_=~/^form\.delmark_(.*)$/) {      if ($key=~/^form\.delmark_(.*)$/) {
  &movemsg(&Apache::lonnet::unescape($1),$folder,   my ($result,$msg) =
  $env{'form.movetofolder'});      &movemsg(&Apache::lonnet::unescape($1),$folder,
  $total++;       $env{'form.movetofolder'});
    if ($result) {
       $total++;
    } else {
       $failed++;
       push(@failed_msg,$msg);
    }
     }      }
  }   }
  &printheader($r,'','Moved Messages');   &printheader($r,'','Moved Messages');
    if ($failed) {
       $r->print('<p class="LC_error">
                             Failed to move '.$failed.' message(s)</p>');
       $r->print('<p class="LC_error">'.
         join("</p>\n<p class=\"LC_error\">",@failed_msg).
         "</p>\n");
    }
  $r->print('Moved '.$total.' message(s)<p>');   $r->print('Moved '.$total.' message(s)<p>');
  &Apache::loncommunicate::menu($r);   &Apache::loncommunicate::menu($r);
  &disall($r,($folder?$folder:$dismode));   &disall($r,($folder?$folder:$dismode));
     } elsif ($env{'form.markeddel'}) {      } elsif ($env{'form.markeddel'}) {
  my $total=0;   my ($total,$failed,@failed_msg)=(0,0);
  foreach (keys %env) {   foreach my $key (keys(%env)) {
     if ($_=~/^form\.delmark_(.*)$/) {      if ($key=~/^form\.delmark_(.*)$/) {
  &statuschange(&Apache::lonnet::unescape($1),'deleted',$folder);   my ($result,$msg) = 
  $total++;      &statuschange(&Apache::lonnet::unescape($1),'deleted',
     $folder);
    if ($result) {
       $total++;
    } else {
       $failed++;
       push(@failed_msg,$msg);
    }
     }      }
  }   }
  &printheader($r,'','Deleted Messages');   &printheader($r,'','Deleted Messages');
    if ($failed) {
       $r->print('<p class="LC_error">
                             Failed to delete '.$failed.' message(s)</p>');
       $r->print('<p class="LC_error">'.
         join("</p>\n<p class=\"LC_error\">",@failed_msg).
         "</p>\n");
    }
  $r->print('Deleted '.$total.' message(s)<p>');   $r->print('Deleted '.$total.' message(s)<p>');
  &Apache::loncommunicate::menu($r);   &Apache::loncommunicate::menu($r);
  &disall($r,($folder?$folder:$dismode));   &disall($r,($folder?$folder:$dismode));

Removed from v.1.3  
changed lines
  Added in v.1.9


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