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

raeburn raeburn@source.lon-capa.org
Thu, 26 Aug 2010 09:09:24 -0000


raeburn		Thu Aug 26 09:09:24 2010 EDT

  Modified files:              (Branch: version_2_10_X)
    /loncom/interface	lonfeedback.pm 
  Log:
  - Backport 1.300, 1.301.
  
  
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.290.2.2 loncom/interface/lonfeedback.pm:1.290.2.3
--- loncom/interface/lonfeedback.pm:1.290.2.2	Sat Aug 14 18:14:29 2010
+++ loncom/interface/lonfeedback.pm	Thu Aug 26 09:09:24 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.290.2.2 2010/08/14 18:14:29 raeburn Exp $
+# $Id: lonfeedback.pm,v 1.290.2.3 2010/08/26 09:09:24 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -793,7 +793,7 @@
                      '<table width="100%" class="LC_disc_action_table"><tr>'.
                      '<td class="LC_disc_action_left">';
     my $escsymb=&escape($ressymb);
-    if ($visible>2) {
+    if ($visible) {
         $discussion .= '<a href="/adm/feedback?cmd=threadedon&amp;symb='.$escsymb;
         if ($newpostsflag) {
             $discussion .= '&amp;previous='.$prevread;
@@ -856,6 +856,11 @@
     if (&Apache::lonhtmlcommon::htmlareabrowser()) {
         $postingform = &Apache::lonhtmlcommon::htmlareaselectactive();
         $textareaclass = 'class="LC_richDefaultOff"';
+        if ($env{'request.course.id'}) {
+            unless (($env{'course.'.$env{'request.course.id'}.'.allow_limited_html_in_feedback'} =~ /^\s*yes\s*$/i) || ($env{'form.sendmessageonly'})) {
+                undef($textareaclass);
+            }
+        }
     }
     $postingform .= (<<ENDDISCUSS);
 <form action="/adm/feedback" method="post" name="mailform" enctype="multipart/form-data"> <input type="submit" name="discuss" value="$lt{'podi'}" />
@@ -865,7 +870,7 @@
 <br /><a name="newpost"></a>
 <font size="1">$lt{'note'}</font><br />
 <b>$lt{'title'}:</b>&nbsp;<input type="text" name="subject" value="$subject" size="30" /><br /><br />
-<textarea name="comment" cols="80" rows="14"id="comment" $textareaclass>$comment</textarea>
+<textarea name="comment" cols="80" rows="14" id="comment" $textareaclass>$comment</textarea>
 ENDDISCUSS
     if ($env{'form.origpage'}) {
         $postingform .= '<input type="hidden" name="origpage" value="'.
@@ -927,6 +932,19 @@
     if ((@{$grouppick} == 0) || (grep(/^all$/,@{$grouppick}))) {
         $skip_group_check = 1;
     }
+    my (%deletions,%hiddens);
+    if ($contrib{'deleted'}) {
+       my $deleted = $contrib{'deleted'};
+       $deleted =~ s/^\.//;
+       $deleted =~ s/\.$//;
+       %deletions = map { $_ => 1 } (split(/\.\./,$deleted));
+    }
+    if ($contrib{'hidden'}) {
+       my $hidden = $contrib{'hidden'};
+       $hidden =~ s/^\.//;
+       $hidden =~ s/\.$//;
+       %hiddens = map { $_ => 1 } (split(/\.\./,$hidden));
+    }
     if ($contrib{'version'}) {
         my $oldest = $contrib{'1:timestamp'};
         if ($prevread eq '0') {
@@ -940,13 +958,13 @@
         } 
 	for (my $id=1;$id<=$contrib{'version'};$id++) {
 	    my $idx=$id;
+            next if ($contrib{$idx.':deleted'});
+            next if ($contrib{$idx.':hidden'});
             my $posttime = $contrib{$idx.':timestamp'};
             if ($prevread <= $posttime) {
                 $$newpostsflag = 1;
             }
-	    my $hidden=($contrib{'hidden'}=~/\.$idx\./);
             my $studenthidden=($contrib{'studenthidden'}=~/\.$idx\./);
-	    my $deleted=($contrib{'deleted'}=~/\.$idx\./);
 	    my $origindex='0.';
             my $numoldver=0;
 	    if ($contrib{$idx.':replyto'}) {
@@ -970,7 +988,7 @@
 	    } else {
 		$$replies[$$depth[$idx]]=1;
 	    }
-	    unless ((($hidden) && (!$seeid)) || ($deleted)) {
+	    unless ((($hiddens{$idx}) && (!$seeid)) || (deletions{$idx})) {
 		$$visible++;
                 if ($contrib{$idx.':history'}) {
                     if ($contrib{$idx.':history'} =~ /:/) {
@@ -1004,7 +1022,7 @@
                     $message.=$attachtxt{$numoldver};
                     $subject=$subjects{$numoldver};
                     if ($message) {
-	  	        if ($hidden) {
+	  	        if ($hiddens{$idx}) {
 			    $message='<font color="#888888">'.$message.'</font>';
                             if ($studenthidden) {
                                 $message .='<br /><br />Deleted by poster (student).';
@@ -1087,7 +1105,7 @@
                                     }
                                 }
                                 if ($seeid) {
-			            if ($hidden) {
+			            if ($hiddens{$idx}) {
                                         unless ($studenthidden) {
 			                    $sender.=' <a href="/adm/feedback?unhide='.
 				                    $escsymb.':::'.$idx;
@@ -1185,7 +1203,7 @@
                 if ($outputtarget eq 'export') {
                     %{$$imsitems{$idx}} = ();
                     $$imsitems{$idx}{'isvisible'}='true';
-                    if ($hidden) {
+                    if ($hiddens{$idx}) {
                         $$imsitems{$idx}{'isvisible'}='false';
                     }
                     $$imsitems{$idx}{'title'}=$subjects{$numoldver};
@@ -1267,7 +1285,7 @@
                                 $$newitem{$idx} = 1;
                                 $$discussionitems[$idx] .= '
                                   <table border="0" width="100%">
-                                  <tr><td align="left"><font color="#FF0000"><b>'.&mt('NEW').'</b></font></td>';
+                                  <tr><td align="left"><font color="#FF0000"><b>'.&mt('NEW').&nbsp;'</b></font></td>';
                             } else {
                                 $$newitem{$idx} = 0;
                                 $$discussionitems[$idx] .= '
@@ -1692,6 +1710,11 @@
   if (&Apache::lonhtmlcommon::htmlareabrowser()) {
       $textareaheader = &Apache::lonhtmlcommon::htmlareaselectactive();
       $textareaclass = 'class="LC_richDefaultOff"';
+      if ($env{'request.course.id'}) {
+          unless (($env{'course.'.$env{'request.course.id'}.'.allow_limited_html_in_feedback'} =~ /^\s*yes\s*$/i) || ($env{'form.sendmessageonly'})) {
+              undef($textareaclass);
+          }
+      }
   }
 
   # Breadcrumbs
@@ -3915,7 +3938,11 @@
           }
       }
 # Filter HTML out of message (could be nasty)
-      my $message=&clear_out_html($env{'form.comment'});
+      my $override;
+      if ($env{'form.discuss'} =~ /^(?:author|question|course|policy)$/) {
+          $override = 1;
+      }
+      my $message=&clear_out_html($env{'form.comment'},1);
 
 # Assemble email
       my ($email,$citations)=&assemble_email($message,$prevattempts,