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

raeburn lon-capa-cvs@mail.lon-capa.org
Fri, 17 Mar 2006 21:33:18 -0000


raeburn		Fri Mar 17 16:33:18 2006 EDT

  Modified files:              
    /loncom/interface	lonnavmaps.pm 
  Log:
  Counts of unread posts was incorrect for bulletin boards, as unwrapped symbs are used in the keys when storing information about BB posts.
  
  
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.371 loncom/interface/lonnavmaps.pm:1.372
--- loncom/interface/lonnavmaps.pm:1.371	Thu Mar 16 15:48:30 2006
+++ loncom/interface/lonnavmaps.pm	Fri Mar 17 16:33:17 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.371 2006/03/16 20:48:30 albertel Exp $
+# $Id: lonnavmaps.pm,v 1.372 2006/03/17 21:33:17 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2355,10 +2355,11 @@
     my $symb = shift;
 
     $self->get_discussion_data();
-    
-    my $ressymb = $self->wrap_symb($symb);
 
-    my $version = $self->{DISCUSSION_DATA}{'version:'.$ressymb};
+    my $ressymb = $self->wrap_symb($symb);
+    # keys used to store bulletinboard postings use 'unwrapped' symb. 
+    my $discsymb = $self->unwrap_symb($ressymb);
+    my $version = $self->{DISCUSSION_DATA}{'version:'.$discsymb};
     if (!$version) { return; }
 
     my $prevread = $self->{LAST_READ}{$ressymb};
@@ -2371,24 +2372,24 @@
     my %subjects;
 
     for (my $id=$version; $id>0; $id--) {
-	my $vkeys=$self->{DISCUSSION_DATA}{$id.':keys:'.$ressymb};
+	my $vkeys=$self->{DISCUSSION_DATA}{$id.':keys:'.$discsymb};
 	my @keys=split(/:/,$vkeys);
 	if (grep(/^hidden$/ ,@keys)) {
 	    if (!$hiddenflag) {
-		$hidden = $self->{DISCUSSION_DATA}{$id.':'.$ressymb.':hidden'};
+		$hidden = $self->{DISCUSSION_DATA}{$id.':'.$discsymb.':hidden'};
 		$hiddenflag = 1;
 	    }
 	} elsif (grep(/^deleted$/,@keys)) {
 	    if (!$deletedflag) {
-		$deleted = $self->{DISCUSSION_DATA}{$id.':'.$ressymb.':deleted'};
+		$deleted = $self->{DISCUSSION_DATA}{$id.':'.$discsymb.':deleted'};
 		$deletedflag = 1;
 	    }
 	} else {
 	    if (($hidden !~/\.$id\./) && ($deleted !~/\.$id\./)
-		&& $prevread < $self->{DISCUSSION_DATA}{$id.':'.$ressymb.':timestamp'}) {
+		&& $prevread < $self->{DISCUSSION_DATA}{$id.':'.$discsymb.':timestamp'}) {
 		    $unreadcount++;
 		    $subjects{$unreadcount}=
-			$id.': '.$self->{DISCUSSION_DATA}{$id.':'.$ressymb.':subject'};
+			$id.': '.$self->{DISCUSSION_DATA}{$id.':'.$discsymb.':subject'};
 		}
 	}
     }
@@ -2409,6 +2410,16 @@
     return $symb;
 }
 
+sub unwrap_symb {
+    my $self = shift;
+    my $ressymb = shift;
+    my $discsymb = $ressymb;
+    if ($ressymb =~ m-^(bulletin___\d+___)adm/wrapper/(adm/\w+/\w+/\d+/bulletinboard)$-) {
+         $discsymb = $1.$2;
+    }
+    return $discsymb;
+}
+
 # Private method: Does the given resource (as a symb string) have
 # current feedback? Returns the string in the feedback hash, which
 # will be false if it does not exist.