Diff for /loncom/interface/lonmsg.pm between versions 1.6 and 1.7

version 1.6, 2001/02/06 16:51:24 version 1.7, 2001/02/06 18:17:34
Line 24  use Apache::Constants qw(:common); Line 24  use Apache::Constants qw(:common);
 # ===================================================================== Package  # ===================================================================== Package
   
 sub packagemsg {  sub packagemsg {
     my ($subject,$message)=@_;      my ($subject,$message,$citation)=@_;
     $message=~s/\</\&lt\;/g;      $message=~s/\</\&lt\;/g;
     $message=~s/\>/\&gt\;/g;      $message=~s/\>/\&gt\;/g;
       $citation=~s/\</\&lt\;/g;
       $citation=~s/\>/\&gt\;/g;
     $subject=~s/\</\&lt\;/g;      $subject=~s/\</\&lt\;/g;
     $subject=~s/\>/\&gt\;/g;      $subject=~s/\>/\&gt\;/g;
     my $now=time;      my $now=time;
Line 54  sub packagemsg { Line 56  sub packagemsg {
    '<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>'.
    '<message>'.$message.'</message>';     '<message>'.$message.'</message>'.
      '<citation>'.$citation.'</citation>';
 }  }
   
 # ================================================== Unpack message into a hash  # ================================================== Unpack message into a hash
Line 77  sub unpackagemsg { Line 80  sub unpackagemsg {
 # ======================================================= Get info out of msgid  # ======================================================= Get info out of msgid
   
 sub unpackmsgid {  sub unpackmsgid {
     my $msgid=shift;      my $msgid=&Apache::lonnet::unescape(shift);
     my ($sendtime,$shortsubj,$fromname,$fromdomain)=split(/\:/,      my ($sendtime,$shortsubj,$fromname,$fromdomain)=split(/\:/,
                      &Apache::lonnet::unescape(                            &Apache::lonnet::unescape($msgid));
                           &Apache::lonnet::unescape($_)));  
     my %status=&Apache::lonnet::get('email_status',$msgid);      my %status=&Apache::lonnet::get('email_status',$msgid);
     if ($status{$msgid}=~/^error\:/) { $status{$msgid}=''; }      if ($status{$msgid}=~/^error\:/) { $status{$msgid}=''; }
     unless ($status{$msgid}) { $status{$msgid}='new'; }      unless ($status{$msgid}) { $status{$msgid}='new'; }
Line 161  sub user_crit_received { Line 163  sub user_crit_received {
 # ======================================================== Normal communication  # ======================================================== Normal communication
   
 sub user_normal_msg {  sub user_normal_msg {
     my ($user,$domain,$subject,$message)=@_;      my ($user,$domain,$subject,$message,$citation)=@_;
 # Check if allowed missing  # Check if allowed missing
     my $status='';      my $status='';
     my $msgid='undefined';      my $msgid='undefined';
Line 169  sub user_normal_msg { Line 171  sub user_normal_msg {
     my $homeserver=&Apache::lonnet::homeserver($user,$domain);      my $homeserver=&Apache::lonnet::homeserver($user,$domain);
     if ($homeserver ne 'no_host') {      if ($homeserver ne 'no_host') {
        my $msgid;         my $msgid;
        ($msgid,$message)=&packagemsg($subject,$message);         ($msgid,$message)=&packagemsg($subject,$message,$citation);
        $status=&Apache::lonnet::critical(         $status=&Apache::lonnet::critical(
            'put:'.$domain.':'.$user.':nohist_email:'.             'put:'.$domain.':'.$user.':nohist_email:'.
            &Apache::lonnet::escape($msgid).'='.             &Apache::lonnet::escape($msgid).'='.
Line 183  sub user_normal_msg { Line 185  sub user_normal_msg {
     return $status;      return $status;
 }  }
   
   # =============================================================== Status Change
   
   sub statuschange {
       my ($msgid,$newstatus)=@_;
       my %status=&Apache::lonnet::get('email_status',$msgid);
       if ($status{$msgid}=~/^error\:/) { $status{$msgid}=''; }
       unless ($status{$msgid}) { $status{$msgid}='new'; }
       unless (($status{$msgid} eq 'replied') || 
               ($status{$msgid} eq 'forwarded')) {
    &Apache::lonnet::put('email_status',($msgid => $newstatus));
       }
   }
 # ===================================================================== Handler  # ===================================================================== Handler
   
 sub handler {  sub handler {
Line 202  sub handler { Line 216  sub handler {
        $value =~ tr/+/ /;         $value =~ tr/+/ /;
        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;         $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
        if (($name eq 'display') || ($name eq 'replyto') ||          if (($name eq 'display') || ($name eq 'replyto') || 
            ($name eq 'forward') || ($name eq 'mark')) {             ($name eq 'forward') || ($name eq 'mark') ||
              ($name eq 'sendreply')) {
            unless ($ENV{'form.'.$name}) {             unless ($ENV{'form.'.$name}) {
               $ENV{'form.'.$name}=$value;                $ENV{'form.'.$name}=$value;
    }     }
Line 212  sub handler { Line 227  sub handler {
 # --------------------------------------------------------------- Render Output  # --------------------------------------------------------------- Render Output
       
   $r->print('<html><head><title>EMail and Messaging</title></head>');    $r->print('<html><head><title>EMail and Messaging</title></head>');
   $r->print('<body bgcolor="#FFFFFF">');    $r->print(
      '<body bgcolor="#FFFFFF"><img align=right src=/adm/lonIcons/lonlogos.gif>');
   $r->print('<h1>EMail</h1>');    $r->print('<h1>EMail</h1>');
   if ($ENV{'form.display'}) {    if ($ENV{'form.display'}) {
         my $msgid=$ENV{'form.display'};
         &statuschange($msgid,'read');
         my %message=&Apache::lonnet::get('nohist_email',$msgid);
         my %content=&unpackagemsg($message{$msgid});
         $r->print('<b>Subject:</b> '.$content{'subject'}.
                '<br><b>From:</b> '.$content{'sendername'}.' at '.
                                    $content{'senderdomain'}.
                '<br><b>Time:</b> '.$content{'time'}.'<hr>Functions: '.
                '<a href="/adm/email?replyto='.&Apache::lonnet::escape($msgid).
                '"><b>Reply</b></a><hr><pre>'.
                $content{'message'}.'</pre><hr>'.$content{'citation'});
   } elsif ($ENV{'form.replyto'}) {    } elsif ($ENV{'form.replyto'}) {
         my $msgid=$ENV{'form.replyto'};
         my %message=&Apache::lonnet::get('nohist_email',$msgid);
         my %content=&unpackagemsg($message{$msgid});
         my $quotemsg='> '.$content{'message'};
         $quotemsg=~s/\r/\n/g;
         $quotemsg=~s/\f/\n/g;
         $quotemsg=~s/\n+/\n\> /g;
         my $subject='Re: '.$content{'subject'};
         $r->print(<<"ENDREPLY");
   <form action="/adm/email" method=post>
   <input type=hidden name=sendreply value="$msgid">
   Subject: <input type=text size=50 name=subject value="$subject"><p>
   <textarea name=message cols=60 rows=10>
   $quotemsg
   </textarea><p>
   <input type=submit value="Send Reply">
   </form>
   ENDREPLY
     } elsif ($ENV{'form.sendreply'}) {
         my $msgid=$ENV{'form.sendreply'};
         my %message=&Apache::lonnet::get('nohist_email',$msgid);
         my %content=&unpackagemsg($message{$msgid});
         &statuschange($msgid,'replied');
         $r->print('Sending: '.&user_normal_msg($content{'sendername'},
                                    $content{'senderdomain'},
                                    $ENV{'form.subject'},
                                    $ENV{'form.message'}));
   } elsif ($ENV{'form.forward'}) {    } elsif ($ENV{'form.forward'}) {
   } elsif ($ENV{'form.mark'}) {    } elsif ($ENV{'form.mark'}) {
   } else {    } else {
Line 229  sub handler { Line 283  sub handler {
         } 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="#BBBB99">');      $r->print('<tr bgcolor="#AAAA88">');
  } else {   } else {
     $r->print('<tr bgcolor="#99BBBB">');      $r->print('<tr bgcolor="#99BBBB">');
         }          }

Removed from v.1.6  
changed lines
  Added in v.1.7


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