[LON-CAPA-cvs] cvs: loncom /interface lonmsg.pm /xml lontexconvert.pm

www lon-capa-cvs@mail.lon-capa.org
Mon, 31 Mar 2003 16:34:08 -0000


www		Mon Mar 31 11:34:08 2003 EDT

  Modified files:              
    /loncom/interface	lonmsg.pm 
    /loncom/xml	lontexconvert.pm 
  Log:
  Attachments displayed in normal messages.
  
  
Index: loncom/interface/lonmsg.pm
diff -u loncom/interface/lonmsg.pm:1.51 loncom/interface/lonmsg.pm:1.52
--- loncom/interface/lonmsg.pm:1.51	Sun Mar 30 16:58:17 2003
+++ loncom/interface/lonmsg.pm	Mon Mar 31 11:34:08 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging
 #
-# $Id: lonmsg.pm,v 1.51 2003/03/30 21:58:17 www Exp $
+# $Id: lonmsg.pm,v 1.52 2003/03/31 16:34:08 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -65,7 +65,7 @@
     $baseurl =&HTML::Entities::encode($baseurl);
     #remove machine specification
     $attachmenturl =~ s|^http://[^/]+/|/|;
-    $attachmenturl =&HTML::Entities::encode($baseurl);
+    $attachmenturl =&HTML::Entities::encode($attachmenturl);
 
     my $now=time;
     $msgcount++;
@@ -98,7 +98,7 @@
 	$result.= '<baseurl>'.$baseurl.'</baseurl>';
     }
     if (defined($attachmenturl)) {
-	$result.= '<attachmenturl>'.$baseurl.'</attachmenturl>';
+	$result.= '<attachmenturl>'.$attachmenturl.'</attachmenturl>';
     }
     return $msgid,$result;
 }
@@ -106,7 +106,7 @@
 # ================================================== Unpack message into a hash
 
 sub unpackagemsg {
-    my $message=shift;
+    my ($message,$notoken)=@_;
     my %content=();
     my $parser=HTML::TokeParser->new(\$message);
     my $token;
@@ -117,6 +117,16 @@
            $content{$entry}=$value;
        }
     }
+    if ($content{'attachmenturl'}) {
+       my ($fname,$ft)=($content{'attachmenturl'}=~/\/(\w+)\.(\w+)$/);
+       if ($notoken) {
+	   $content{'message'}.='<p>Attachment: <tt>'.$fname.'.'.$ft.'</tt>';
+       } else {
+	   $content{'message'}.='<p>Attachment: <a href="'.
+	       &Apache::lonnet::tokenwrapper($content{'attachmenturl'}).
+	       '"><tt>'.$fname.'.'.$ft.'</tt></a>';
+       }
+    }
     return %content;
 }
 
@@ -225,7 +235,7 @@
 sub user_crit_received {
     my $msgid=shift;
     my %message=&Apache::lonnet::get('critical',[$msgid]);
-    my %contents=&unpackagemsg($message{$msgid});
+    my %contents=&unpackagemsg($message{$msgid},1);
     my $status='rec: '.($contents{'sendback'}?
      &user_normal_msg($contents{'sendername'},$contents{'senderdomain'},
                      'Receipt: '.$ENV{'user.name'}.' at '.$ENV{'user.domain'},
@@ -276,7 +286,7 @@
 # New routine that respects "forward" and calls old routine
 
 sub user_normal_msg {
-    my ($user,$domain,$subject,$message,$citation,$baseurl)=@_;
+    my ($user,$domain,$subject,$message,$citation,$baseurl,$attachmenturl)=@_;
     my $status='';
     my %userenv = &Apache::lonnet::get('environment',['msgforward'],
                                        $domain,$user);
@@ -286,11 +296,11 @@
 	 my ($forwuser,$forwdomain)=split(/\:/,$_);
          $status.=
 	  &user_normal_msg_raw($forwuser,$forwdomain,$subject,$message,
-			       $citation,$baseurl).' ';
+			       $citation,$baseurl,$attachmenturl).' ';
        }
     } else { 
 	$status=&user_normal_msg_raw($user,$domain,$subject,$message,
-				     $citation,$baseurl);
+				     $citation,$baseurl,$attachmenturl);
     }
     return $status;
 }
@@ -421,7 +431,7 @@
 sub comprep {
     my ($r,$msgid)=@_;
       my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
-      my %content=&unpackagemsg($message{$msgid});
+      my %content=&unpackagemsg($message{$msgid},1);
       my $quotemsg='> '.$content{'message'};
       $quotemsg=~s/\r/\n/g;
       $quotemsg=~s/\f/\n/g;
@@ -770,7 +780,7 @@
   } elsif ($ENV{'form.sendreply'}) {
       my $msgid=$ENV{'form.sendreply'};
       my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
-      my %content=&unpackagemsg($message{$msgid});
+      my %content=&unpackagemsg($message{$msgid},1);
       &statuschange($msgid,'replied');
       if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) && 
           (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
@@ -836,7 +846,7 @@
       if ($ENV{'form.forwid'}) {
         my $msgid=$ENV{'form.forwid'};
         my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
-        %content=&unpackagemsg($message{$msgid});
+        %content=&unpackagemsg($message{$msgid},1);
         &statuschange($msgid,'forwarded');
         $ENV{'form.message'}.="\n\n-- Forwarded message --\n\n".
 	                       $content{'message'};
Index: loncom/xml/lontexconvert.pm
diff -u loncom/xml/lontexconvert.pm:1.20 loncom/xml/lontexconvert.pm:1.21
--- loncom/xml/lontexconvert.pm:1.20	Thu Mar 13 11:16:07 2003
+++ loncom/xml/lontexconvert.pm	Mon Mar 31 11:34:08 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # TeX Conversion Module
 #
-# $Id: lontexconvert.pm,v 1.20 2003/03/13 16:16:07 www Exp $
+# $Id: lontexconvert.pm,v 1.21 2003/03/31 16:34:08 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -142,7 +142,7 @@
                 '\:\-*(o|O|\(\))' => 'shocked',
                 '\;\-*\)' => 'wink',
                 '\:\-*P'  => 'baeh',
-                '\:\-*(\\\|\\/)' => 'hrrm',
+                '\:\-(\\\|\\/)' => 'hrrm',
                 '\:\-*D'  => 'bigsmile',
                 '\:\-*C'  => 'angry',
                 '\:(\'|\`)\-*\(' => 'cry',