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

raeburn lon-capa-cvs@mail.lon-capa.org
Wed, 28 Apr 2004 23:59:53 -0000


raeburn		Wed Apr 28 19:59:53 2004 EDT

  Modified files:              
    /loncom/interface	lonfeedback.pm 
  Log:
  nohist db file now used.  Also fix bug 2962. Time now recorded for last visit to discussion. "NEW" tag displayed alongside more recent posts.
  
  
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.78 loncom/interface/lonfeedback.pm:1.79
--- loncom/interface/lonfeedback.pm:1.78	Wed Apr 28 17:13:13 2004
+++ loncom/interface/lonfeedback.pm	Wed Apr 28 19:59:53 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.78 2004/04/28 21:13:13 raeburn Exp $
+# $Id: lonfeedback.pm,v 1.79 2004/04/28 23:59:53 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -56,10 +56,15 @@
     }
     unless ($symb) { return ''; }
 
-    my %dischash = &Apache::lonnet::restore($symb,$ENV{'request.course.id'}.'_discuss',$ENV{'user.domain'},$ENV{'user.name'});
+    my %dischash = &Apache::lonnet::restore($symb,'nohist_'.$ENV{'request.course.id'}.'_discuss',$ENV{'user.domain'},$ENV{'user.name'});
     my %readids = ();
     my $showonlyunread;
+    my $prevread = 0;
+
     foreach my $key (keys %dischash) {
+        if ($key eq 'lastread') {
+            $prevread = $dischash{$key};
+        }
         if ($key eq 'showonlyunread') {
             $showonlyunread = $dischash{$key};
         } else {
@@ -94,6 +99,13 @@
 	    $ENV{'environment.remote'} eq 'off' ) {
 	$target='target="LONcom"';
     }
+    
+    my $now = time;
+    my %discinfo = (
+                   'lastread' => $now,
+                   ); 
+    &Apache::lonnet::cstore(\%discinfo,$symb,'nohist_'.$ENV{'request.course.id'}.'_discuss',$ENV{'user.domain'},$ENV{'user.name'});
+
     if ($contrib{'version'}) {
 	for (my $id=1;$id<=$contrib{'version'};$id++) {
 	    my $idx=$id;
@@ -201,13 +213,21 @@
 		    }
 		    $alldiscussion{$thisindex}=$idx;
 		    $index[$idx]=$thisindex;
-                    $discussionitems[$idx]='<p><table border="0" width="100%">'.
-                        '<tr><td align="left"><b>'.$subject.'</b>&nbsp;&nbsp;'.
+                    my $posttime = $contrib{$idx.':timestamp'};
+                    my $spansize = 2;
+                    $discussionitems[$idx]='<p><table border="0" width="100%"><tr>';
+                    if ($prevread > 0 && $prevread < $posttime) {
+                        $discussionitems[$idx] .= '<td align="left" bgcolor="#FFFFFF"><font color="#FF0000">NEW</font></td>';
+                        $spansize ++;
+                    }
+                    $discussionitems[$idx] .= '<td align ="left">&nbsp;&nbsp;'.
+                        '<b>'.$subject.'</b>&nbsp;&nbsp;'.
                         $sender.'</b> '.$vgrlink.' ('.
-                        localtime($contrib{$idx.':timestamp'}).
-                        ')</td><td align="right">&nbsp;&nbsp;'.$ctlink.'</td></tr>';
+                        localtime($posttime).')'.
+                        '</td><td align="right">&nbsp;&nbsp;'.
+                        $ctlink.'</td></tr>';
                     if ($showonlyunread && $readids{$idx}) {
-                        $discussionitems[$idx] .= '<tr><td colspan="2" align="right"><i><font size="-1">Check "Show all posts?" or "Mark unread?", then "Save read settings" to display message</font></i></td></tr></table>';
+                        $discussionitems[$idx] .= '<tr><td colspan="'.$spansize.'" align="right"><i><font size="-1">Check "Show all posts?" or "Mark unread?", then "Save read settings" to display message</font></i></td></tr></table>';
                     } else {
                         $discussionitems[$idx] .= '</table><blockquote>'.$message.'</blockquote></p>';
                     }
@@ -306,7 +326,9 @@
 	  my $message=$contrib{$idx.':message'};
 	  $message=~s/\n/\<br \/\>/g;
 	  $quote='<blockquote>'.&Apache::lontexconvert::msgtexconverted($message).'</blockquote>';
-          $subject = 'Re: '.$contrib{$idx.':subject'};
+          if ($idx > 0) {
+              $subject = 'Re: '.$contrib{$idx.':subject'};
+          }
       }
   }
   my $latexHelp = Apache::loncommon::helpLatexCheatsheet();
@@ -764,7 +786,7 @@
           } elsif ($ENV{'form.onlyunread'}) {
               $readinghash{'showonlyunread'} = 1;
           }
-          &Apache::lonnet::cstore(\%readinghash,$symb,$ENV{'request.course.id'}.'_discuss',$ENV{'user.domain'},$ENV{'user.name'});
+          &Apache::lonnet::cstore(\%readinghash,$symb,'nohist_'.$ENV{'request.course.id'}.'_discuss',$ENV{'user.domain'},$ENV{'user.name'});
       }
                                                                                  
       &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed reading status'),'0','0');
@@ -791,7 +813,7 @@
       }
                                                                                  
       if ($chgcount > 0) {
-          &Apache::lonnet::cstore(\%readinghash,$symb,$ENV{'request.course.id'}.'_discuss',$ENV{'user.domain'},$ENV{'user.name'});
+          &Apache::lonnet::cstore(\%readinghash,$symb,'nohist_'.$ENV{'request.course.id'}.'_discuss',$ENV{'user.domain'},$ENV{'user.name'});
       }
   }
 
@@ -830,7 +852,7 @@
 		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
 
     &redirect_back($r,&Apache::lonnet::clutter($url),
-       &mt('Changed read status').'<br />','0','0');
+       &mt('Changed discussion status').'<br />','0','0');
   } elsif (($ENV{'form.threadedon'}) || ($ENV{'form.threadedoff'})) {
       &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;