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

raeburn raeburn at source.lon-capa.org
Sun Apr 29 18:02:02 EDT 2012


raeburn		Sun Apr 29 22:02:02 2012 EDT

  Modified files:              
    /loncom/interface	lonfeedback.pm 
  Log:
  - Streamline the code used to retrieve old versions of a post when
    replying to, or editing a discussion post.
  
  
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.351 loncom/interface/lonfeedback.pm:1.352
--- loncom/interface/lonfeedback.pm:1.351	Sat Mar 17 14:49:29 2012
+++ loncom/interface/lonfeedback.pm	Sun Apr 29 22:02:02 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.351 2012/03/17 14:49:29 raeburn Exp $
+# $Id: lonfeedback.pm,v 1.352 2012/04/29 22:02:02 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1807,6 +1807,7 @@
 					   $env{'course.'.$env{'request.course.id'}.'.domain'},
 					   $env{'course.'.$env{'request.course.id'}.'.num'});
       unless (($contrib{'hidden'}=~/\.$idx\./) || ($contrib{'deleted'}=~/\.$idx\./)) {
+          my $numoldver = 0;
           if ($contrib{$idx.':history'}) {
               if ($contrib{$idx.':history'} =~ /:/) {
                   my @oldversions = split(/:/,$contrib{$idx.':history'});
@@ -1815,36 +1816,25 @@
                   $numoldver = 1;
               }
           }
-          if ($env{'form.replydisc'}) {
-              if ($contrib{$idx.':history'}) {
-                  if ($contrib{$idx.':history'} =~ /:/) {
-                      my @oldversions = split(/:/,$contrib{$idx.':history'});
-                      $numoldver = @oldversions;
-                  } else {
-                      $numoldver = 1;
-                  }
+          if ($idx > 0) {
+              my (%msgversions,%subversions,$htmldecode);
+              $htmldecode = 0;
+              if ($env{'form.replydisc'}) {
+                  $htmldecode = 1;
               }
-              if ($idx > 0) {
-                  my %msgversions = ();
-                  &get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver);
+              &get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver);
+              &get_post_versions(\%subversions,$contrib{$idx.':subject'},$htmldecode,
+                                 $numoldver);
+              $subject = $subversions{$numoldver};
+              if ($env{'form.replydisc'}) {
                   $quote = $msgversions{$numoldver};
-              }
-              if ($idx > 0) {
-                  my %subversions = ();
-                  &get_post_versions(\%subversions,$contrib{$idx.':subject'},1,$numoldver);
-                  $subject = &mt('Re: ').$subversions{$numoldver};
-              }
-              $subject = &HTML::Entities::encode($subject,'<>&"');
-          } else {
-              $attachmenturls = $contrib{$idx.':attachmenturl'};
-              if ($idx > 0) {
-                  my %msgversions = ();
-                  &get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver);
+                  $subject = &HTML::Entities::encode(&mt('Re: ').$subject,'<>&"');
+              } else {
                   $comment = $msgversions{$numoldver};
-                  my %subversions = ();
-                  &get_post_versions(\%subversions,$contrib{$idx.':subject'},0,$numoldver);
-                  $subject = $subversions{$numoldver}; 
               }
+          }
+          if ($env{'form.editdisc'}) {
+              $attachmenturls = $contrib{$idx.':attachmenturl'};
               if (defined($contrib{$idx.':replyto'})) {
                   $parentmsg = $contrib{$idx.':replyto'};
               }




More information about the LON-CAPA-cvs mailing list