Diff for /loncom/interface/lonmsg.pm between versions 1.59 and 1.65

version 1.59, 2003/07/25 13:13:43 version 1.65, 2003/08/29 20:38:12
Line 116  use Apache::lontexconvert(); Line 116  use Apache::lontexconvert();
 use HTML::Entities();  use HTML::Entities();
 use Mail::Send;  use Mail::Send;
   
   # Querystring component with sorting type
   my $sqs;
   
 # ===================================================================== Package  # ===================================================================== Package
   
 sub packagemsg {  sub packagemsg {
Line 503  sub discourse { Line 506  sub discourse {
 <input type=button onClick="uncheckall()" value="Check for None">  <input type=button onClick="uncheckall()" value="Check for None">
 <p>  <p>
 ENDDISHEADER  ENDDISHEADER
       my %coursepersonnel=
          &Apache::lonnet::get_course_adv_roles();
       foreach my $role (sort keys %coursepersonnel) {
          foreach (split(/\,/,$coursepersonnel{$role})) {
      my ($puname,$pudom)=split(/\:/,$_);
      $r->print(
                '<br /><input type="checkbox" name="send_to_&&&&&&_'.
                $puname.':'.$pudom.'" /> '.
        &Apache::loncommon::plainname($puname,
                             $pudom).' ('.$_.'), <i>'.$role.'</i>');
    }
       }
   
     foreach (sort keys %courselist) {      foreach (sort keys %courselist) {
         my ($end,$start)=split(/\:/,$courselist{$_});          my ($end,$start)=split(/\:/,$courselist{$_});
         my $active=1;          my $active=1;
Line 553  $content{'sendername'}.'@'. Line 569  $content{'sendername'}.'@'.
     }      }
     # Check to see if there were any messages.      # Check to see if there were any messages.
     if ($result eq '') {      if ($result eq '') {
         $result = "<h2>You have no critical messages.</h2>";          $result = "<h2>You have no critical messages.</h2>".
       '<a href="/adm/roles">Select a course</a>';
     } else {      } else {
         $r->print($header);          $r->print($header);
     }      }
Line 599  $dispcrit Line 616  $dispcrit
 ENDREPLY  ENDREPLY
 }  }
   
   sub sortedmessages {
       my @messages = &Apache::lonnet::getkeys('nohist_email');
       #unpack the varibles and repack into temp for sorting
       my @temp;
       foreach (@messages) {
    my $msgid=&Apache::lonnet::escape($_);
    my ($sendtime,$shortsubj,$fromname,$fromdomain,$status)=
       &Apache::lonmsg::unpackmsgid($msgid);
    my @temp1 = ($sendtime,$shortsubj,$fromname,$fromdomain,$status,
        $msgid);
    push @temp ,\@temp1;
       }
       #default sort
       @temp = sort  {$a->[0] <=> $b->[0]} @temp;    
       if ($ENV{'form.sortedby'} eq "date"){
           @temp = sort  {$a->[0] <=> $b->[0]} @temp;    
       }
       if ($ENV{'form.sortedby'} eq "revdate"){
       @temp = sort  {$b->[0] <=> $a->[0]} @temp; 
       }
       if ($ENV{'form.sortedby'} eq "user"){
    @temp = sort  {lc($a->[2]) cmp lc($b->[2])} @temp;
       }
       if ($ENV{'form.sortedby'} eq "revuser"){
    @temp = sort  {lc($b->[2]) cmp lc($a->[2])} @temp;
       }
       if ($ENV{'form.sortedby'} eq "domain"){
           @temp = sort  {$a->[3] cmp $b->[3]} @temp;
       }
       if ($ENV{'form.sortedby'} eq "revdomain"){
           @temp = sort  {$b->[3] cmp $a->[3]} @temp;
       }
       if ($ENV{'form.sortedby'} eq "subject"){
           @temp = sort  {lc($a->[1]) cmp lc($b->[1])} @temp;
       }
       if ($ENV{'form.sortedby'} eq "revsubject"){
           @temp = sort  {lc($b->[1]) cmp lc($a->[1])} @temp;
       }
       if ($ENV{'form.sortedby'} eq "status"){
           @temp = sort  {$a->[4] cmp $b->[4]} @temp;
       }
       if ($ENV{'form.sortedby'} eq "revstatus"){
           @temp = sort  {$b->[4] cmp $a->[4]} @temp;
       }
       return @temp;
   }
   
 # ======================================================== Display all messages  # ======================================================== Display all messages
   
 sub disall {  sub disall {
Line 624  sub disall { Line 688  sub disall {
     }      }
 </script>  </script>
 ENDDISHEADER  ENDDISHEADER
    $r->print(      $r->print('<h1>Display All Messages</h1><form method=post name=disall '.
  '<h1>Display All Messages</h1><form method=post name=disall '.        'action="/adm/email">'.
  'action="/adm/email">'.        '<table border=2><tr><th colspan=2>&nbsp</th><th>');
      '<table border=2><tr><th colspan=2>&nbsp</th><th>Date</th>'.      if ($ENV{'form.sortedby'} eq "revdate") {
      '<th>Username</th><th>Domain</th><th>Subject</th><th>Status</th></tr>');   $r->print('<a href = "?sortedby=date">Date</a></th>');
     foreach (sort split(/\&/,&Apache::lonnet::reply('keys:'.      } else {
  $ENV{'user.domain'}.':'.   $r->print('<a href = "?sortedby=revdate">Date</a></th>');
                                         $ENV{'user.name'}.':nohist_email',      }
                                         $ENV{'user.home'}))) {      $r->print('<th>');
         my ($sendtime,$shortsubj,$fromname,$fromdomain,$status)=      if ($ENV{'form.sortedby'} eq "revuser") {
     &Apache::lonmsg::unpackmsgid($_);   $r->print('<a href = "?sortedby=user">Username</a>');
       } else {
    $r->print('<a href = "?sortedby=revuser">Username</a>');
       }
       $r->print('</th><th>');
       if ($ENV{'form.sortedby'} eq "revdomain") {
    $r->print('<a href = "?sortedby=domain">Domain</a>');
       } else {
    $r->print('<a href = "?sortedby=revdomain">Domain</a>');
       }
       $r->print('</th><th>');
       if ($ENV{'form.sortedby'} eq "revsubject") {
    $r->print('<a href = "?sortedby=subject">Subject</a>');
       } else {
       $r->print('<a href = "?sortedby=revsubject">Subject</a>');
       }
       $r->print('</th><th>');
       if ($ENV{'form.sortedby'} eq "revstatus") {
    $r->print('<a href = "?sortedby=status">Status</th>');
       } else {
         $r->print('<a href = "?sortedby=revstatus">Status</th>');
       }
       $r->print('</tr>');
       my @temp=sortedmessages();
       foreach (@temp){
    my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$origID)= @$_;
  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">');   $r->print('<tr bgcolor="#FFBB77">');
     } elsif ($status eq 'read') {      } elsif ($status eq 'read') {
  $r->print('<tr bgcolor="#BBBB77">');   $r->print('<tr bgcolor="#BBBB77">');
     } elsif ($status eq 'replied') {      } elsif ($status eq 'replied') {
  $r->print('<tr bgcolor="#AAAA88">');   $r->print('<tr bgcolor="#AAAA88">'); 
     } else {      } else {
  $r->print('<tr bgcolor="#99BBBB">');   $r->print('<tr bgcolor="#99BBBB">');
     }      }
     $r->print('<td><a href="/adm/email?display='.$_.      $r->print('<td><a href="/adm/email?display='.$origID.$sqs. 
       '">Open</a></td><td><a href="/adm/email?markdel='.$_.        '">Open</a></td><td><a href="/adm/email?markdel='.$origID.$sqs.
       '">Delete</a><input type=checkbox name="delmark_'.$_.'"></td>'.        '">Delete</a><input type=checkbox name="delmark_'.$origID.'"></td>'.
       '<td>'.localtime($sendtime).'</td><td>'.        '<td>'.localtime($sendtime).'</td><td>'.
       $fromname.'</td><td>'.$fromdomain.'</td><td>'.        $fromname.'</td><td>'.$fromdomain.'</td><td>'.
       &Apache::lonnet::unescape($shortsubj).'</td><td>'.        &Apache::lonnet::unescape($shortsubj).'</td><td>'.
                       $status.'</td></tr>');                        $status.'</td></tr>');
  }   }
     }      }   
     $r->print('</table><p>'.      $r->print('</table><p>'.
               '<a href="javascript:checkall()">Check All</a>&nbsp;'.                '<a href="javascript:checkall()">Check All</a>&nbsp;'.
               '<a href="javascript:uncheckall()">Uncheck All</a><p>'.                '<a href="javascript:uncheckall()">Uncheck All</a><p>'.
         '<input type="hidden" name="sortedby" value="'.$ENV{'form.sortedby'}.'" />'.
               '<input type=submit name="markeddel" value="Delete Checked">'.                '<input type=submit name="markeddel" value="Delete Checked">'.
               '</form></body></html>');                '</form></body></html>');
 }  }
Line 874  sub handler { Line 964  sub handler {
     &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',
          'sendreply','compose','sendmail','critical','recname','recdom',           'sendreply','compose','sendmail','critical','recname','recdom',
          'recordftf']);           'recordftf','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
Line 889  sub handler { Line 979  sub handler {
       &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
         my @messages=&sortedmessages();
         my $counter=0;
         $r->print('<pre>');
         my $escmsgid=&Apache::lonnet::escape($msgid);
         foreach (@messages) {
      if ($_->[5] eq $escmsgid){
          last;
      }
      $counter++;
         }
         $r->print('</pre>');
         my $number_of_messages = scalar(@messages); #subtract 1 for last index
   # 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'}\" />");
Line 905  $content{'sendername'},$content{'senderd Line 1009  $content{'sendername'},$content{'senderd
                                  $content{'senderdomain'}.') '.                                   $content{'senderdomain'}.') '.
              '<br><b>Time:</b> '.$content{'time'}.'<p>'.               '<br><b>Time:</b> '.$content{'time'}.'<p>'.
              '<table border=2><tr bgcolor="#FFFFAA"><td>Functions:</td>'.               '<table border=2><tr bgcolor="#FFFFAA"><td>Functions:</td>'.
            '<td><a href="/adm/email?replyto='.&Apache::lonnet::escape($msgid).             '<td><a href="/adm/email?replyto='.&Apache::lonnet::escape($msgid).$sqs.
              '"><b>Reply</b></a></td>'.               '"><b>Reply</b></a></td>'.
            '<td><a href="/adm/email?forward='.&Apache::lonnet::escape($msgid).             '<td><a href="/adm/email?forward='.&Apache::lonnet::escape($msgid).$sqs.
              '"><b>Forward</b></a></td>'.               '"><b>Forward</b></a></td>'.
         '<td><a href="/adm/email?markunread='.&Apache::lonnet::escape($msgid).          '<td><a href="/adm/email?markunread='.&Apache::lonnet::escape($msgid).$sqs.
              '"><b>Mark Unread</b></a></td>'.               '"><b>Mark Unread</b></a></td>'.
         '<td><a href="/adm/email?markdel='.&Apache::lonnet::escape($msgid).          '<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"><b>Display all Messages</b></a></td>'.   '<td><a href="/adm/email?sortedby='.$ENV{'form.sortedby'}.
              '</tr></table><p><pre>'.   '"><b>Display all Messages</b></a></td>');
         if ($counter > 0){
      $r->print('<td><a href="/adm/email?display='.$messages[$counter-1]->[5].$sqs.
              '"><b>Previous</b></a></td>');
          }
          if ($counter < $number_of_messages - 1){
      $r->print('<td><a href="/adm/email?display='.$messages[$counter+1]->[5].$sqs.
              '"><b>Next</b></a></td>');
          }
          $r->print('</tr></table><p><pre>'.
              &Apache::lontexconvert::msgtexconverted($content{'message'}).               &Apache::lontexconvert::msgtexconverted($content{'message'}).
              '</pre><hr>'.$content{'citation'});               '</pre><hr>'.$content{'citation'});
   } elsif ($ENV{'form.replyto'}) {    } elsif ($ENV{'form.replyto'}) {

Removed from v.1.59  
changed lines
  Added in v.1.65


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