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

www lon-capa-cvs@mail.lon-capa.org
Sun, 30 Mar 2003 21:58:17 -0000


www		Sun Mar 30 16:58:17 2003 EDT

  Modified files:              
    /loncom/interface	lonfeedback.pm lonmsg.pm 
    /loncom/xml	lonxml.pm 
  Log:
  Attachments in discussions work, but not yet in other messages.
  
  
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.42 loncom/interface/lonfeedback.pm:1.43
--- loncom/interface/lonfeedback.pm:1.42	Sat Mar 29 17:50:22 2003
+++ loncom/interface/lonfeedback.pm	Sun Mar 30 16:58:17 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.42 2003/03/29 22:50:22 www Exp $
+# $Id: lonfeedback.pm,v 1.43 2003/03/30 21:58:17 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -105,7 +105,8 @@
 </head>
 $bodytag
 <h2><tt>$feedurl</tt></h2>
-<form action="/adm/feedback" method=post name=mailform>
+<form action="/adm/feedback" method="post" name="mailform"
+enctype="multipart/form-data">
 <input type=hidden name=postdata value="$feedurl">
 Please check at least one of the following feedback types:
 $options<hr>
@@ -339,14 +340,15 @@
 }
 
 sub send_msg {
-  my ($feedurl,$email,$citations,%to)=@_;
+  my ($feedurl,$email,$citations,$attachmenturl,%to)=@_;
   my $status='';
   my $sendsomething=0;
   foreach (keys %to) {
     if ($_) {
       my $declutter=&Apache::lonnet::declutter($feedurl);
       unless (&Apache::lonmsg::user_normal_msg(split(/\:/,$_),
-               'Feedback ['.$declutter.']',$email,$citations,$feedurl)=~/ok/) {
+               'Feedback ['.$declutter.']',$email,$citations,$feedurl,
+                $attachmenturl)=~/ok/) {
 	$status.='<br>Error sending message to '.$_.'<br>';
       } else {
 	$sendsomething++;
@@ -382,7 +384,7 @@
 		                   $ENV{'environment.middlename'}.' '.
                                    $ENV{'environment.lastname'}.' '.
                                    $ENV{'enrironment.generation'},
-                 'attachment'   => $attachmenturl);
+                 'attachmenturl'=> $attachmenturl);
     if ($anon) {
 	$contrib{'anonymous'}='true';
     }
@@ -565,7 +567,7 @@
       my $attachmenturl='';
       if ($ENV{'form.attachment.filename'}) {
 	  unless (length($ENV{'form.attachment'})>131072) {
-	      $attachmenturl=&Apache::lonnet::userfileupload('attachment',1);
+	      $attachmenturl=&Apache::lonnet::userfileupload('attachment');
 	  }
       }
 # Filter HTML out of message (could be nasty)
@@ -579,7 +581,8 @@
       my ($typestyle,%to) = &decide_receiver($feedurl);
 
 # Actually send mail
-      my ($status,$numsent)=&send_msg($feedurl,$email,$citations,%to);
+      my ($status,$numsent)=&send_msg($feedurl,$email,$citations,
+          $attachmenturl,%to);
 
 # Discussion? Store that.
 
Index: loncom/interface/lonmsg.pm
diff -u loncom/interface/lonmsg.pm:1.50 loncom/interface/lonmsg.pm:1.51
--- loncom/interface/lonmsg.pm:1.50	Mon Mar 17 12:02:38 2003
+++ loncom/interface/lonmsg.pm	Sun Mar 30 16:58:17 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging
 #
-# $Id: lonmsg.pm,v 1.50 2003/03/17 17:02:38 albertel Exp $
+# $Id: lonmsg.pm,v 1.51 2003/03/30 21:58:17 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -56,13 +56,17 @@
 # ===================================================================== Package
 
 sub packagemsg {
-    my ($subject,$message,$citation,$baseurl)=@_;
+    my ($subject,$message,$citation,$baseurl,$attachmenturl)=@_;
     $message =&HTML::Entities::encode($message);
     $citation=&HTML::Entities::encode($citation);
     $subject =&HTML::Entities::encode($subject);
     #remove machine specification
     $baseurl =~ s|^http://[^/]+/|/|;
     $baseurl =&HTML::Entities::encode($baseurl);
+    #remove machine specification
+    $attachmenturl =~ s|^http://[^/]+/|/|;
+    $attachmenturl =&HTML::Entities::encode($baseurl);
+
     my $now=time;
     $msgcount++;
     my $partsubj=$subject;
@@ -93,6 +97,9 @@
     if (defined($baseurl)) {
 	$result.= '<baseurl>'.$baseurl.'</baseurl>';
     }
+    if (defined($attachmenturl)) {
+	$result.= '<attachmenturl>'.$baseurl.'</attachmenturl>';
+    }
     return $msgid,$result;
 }
 
@@ -242,14 +249,15 @@
 # ======================================================== Normal communication
 
 sub user_normal_msg_raw {
-    my ($user,$domain,$subject,$message,$citation,$baseurl)=@_;
+    my ($user,$domain,$subject,$message,$citation,$baseurl,$attachmenturl)=@_;
 # Check if allowed missing
     my $status='';
     my $msgid='undefined';
     unless (($message)&&($user)&&($domain)) { $status='empty'; };
     my $homeserver=&Apache::lonnet::homeserver($user,$domain);
     if ($homeserver ne 'no_host') {
-       ($msgid,$message)=&packagemsg($subject,$message,$citation,$baseurl);
+       ($msgid,$message)=&packagemsg($subject,$message,$citation,$baseurl,
+                                     $attachmenturl);
        $status=&Apache::lonnet::critical(
            'put:'.$domain.':'.$user.':nohist_email:'.
            &Apache::lonnet::escape($msgid).'='.
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.242 loncom/xml/lonxml.pm:1.243
--- loncom/xml/lonxml.pm:1.242	Sat Mar 29 17:50:22 2003
+++ loncom/xml/lonxml.pm	Sun Mar 30 16:58:17 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.242 2003/03/29 22:50:22 www Exp $
+# $Id: lonxml.pm,v 1.243 2003/03/30 21:58:17 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -196,6 +196,13 @@
                  my $message=$contrib{$idx.':message'};
                  $message=~s/\n/\<br \/\>/g;
 		 $message=&Apache::lontexconvert::msgtexconverted($message);
+                 if ($contrib{$idx.':attachmenturl'}) {
+                     my ($fname,$ft)
+                        =($contrib{$idx.':attachmenturl'}=~/\/(\w+)\.(\w+)$/);
+		     $message.='<p>Attachment: <a href="'.
+	       &Apache::lonnet::tokenwrapper($contrib{$idx.':attachmenturl'}).
+                     '"><tt>'.$fname.'.'.$ft.'</tt></a>';
+                 }
                  if ($message) {
                   if ($hidden) {
 		      $message='<font color="#888888">'.$message.'</font>';
@@ -248,7 +255,7 @@
           }
           if ($discussiononly) {
 	      $discussion.=(<<ENDDISCUSS);
-<form action="/adm/feedback" method="post" name="mailform">
+<form action="/adm/feedback" method="post" name="mailform" enctype="multipart/form-data">
 <input type="submit" name="discuss" value="Post Discussion" />
 <input type="submit" name="anondiscuss" value="Post Anonymous Discussion" />
 <input type="hidden" name="symb" value="$symb" />