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

raeburn lon-capa-cvs@mail.lon-capa.org
Sun, 01 Aug 2004 16:05:14 -0000


This is a MIME encoded message

--raeburn1091376314
Content-Type: text/plain

raeburn		Sun Aug  1 12:05:14 2004 EDT

  Modified files:              
    /loncom/interface	lonfeedback.pm 
  Log:
  User can now toggle read/unread for individual discussion posts.
  
  
--raeburn1091376314
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20040801120514.txt"

Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.110 loncom/interface/lonfeedback.pm:1.111
--- loncom/interface/lonfeedback.pm:1.110	Thu Jul 29 18:42:25 2004
+++ loncom/interface/lonfeedback.pm	Sun Aug  1 12:05:14 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.110 2004/07/29 22:42:25 raeburn Exp $
+# $Id: lonfeedback.pm,v 1.111 2004/08/01 16:05:14 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -65,7 +65,6 @@
 
 sub list_discussion {
     my ($mode,$status,$symb)=@_;
-
     my $outputtarget=$ENV{'form.grade_target'};
     if (not &discussion_visible($status)) { return ''; }
     my @bgcols = ("#cccccc","#eeeeee");
@@ -96,12 +95,17 @@
 # Get discussion display settings for this discussion
     my $lastkey = $ressymb.'_lastread';
     my $showkey = $ressymb.'_showonlyunread';
+    my $markkey = $ressymb.'_showonlyunmark',
     my $visitkey = $ressymb.'_visit';
     my $ondispkey = $ressymb.'_markondisp';
     my $userpickkey = $ressymb.'_userpick';
-    my %dischash = &Apache::lonnet::get('nohist_'.$ENV{'request.course.id'}.'_discuss',[$lastkey,$showkey,$visitkey,$ondispkey,$userpickkey],$ENV{'user.domain'},$ENV{'user.name'});
+    my $toggkey = $ressymb.'_readtoggle';
+    my $readkey = $ressymb.'_read';
+
+    my %dischash = &Apache::lonnet::get('nohist_'.$ENV{'request.course.id'}.'_discuss',[$lastkey,$showkey,$markkey,$visitkey,$ondispkey,$userpickkey,$toggkey,$readkey],$ENV{'user.domain'},$ENV{'user.name'});
     my %discinfo = ();
     my $showonlyunread = 0;
+    my $showunmark = 0; 
     my $markondisp = 0;
     my $prevread = 0;
     my $previous = 0;
@@ -176,6 +180,10 @@
         $showonlyunread = $dischash{$showkey};
     }
 
+    if (defined($dischash{$markkey})) {
+        $showunmark = $dischash{$markkey};
+    }
+
     if (defined($dischash{$visitkey})) {
         $visit = $dischash{$visitkey};
     }
@@ -205,7 +213,7 @@
 	    $ENV{'environment.remote'} eq 'off' ) {
 	$target='target="LONcom"';
     }
-    
+
     my $now = time;
     $discinfo{$visitkey} = $visit;
 
@@ -434,6 +442,12 @@
 			$vgrlink=&Apache::loncommon::submlink('Submissions',
             $contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$symb);
 		    }
+                    my $ctlink;
+                    if ($dischash{$readkey}=~/\.$idx\./) { 
+                        $ctlink = '<b>'.&mt('Mark unread').'?</b>&nbsp;<input type="checkbox" name="postunread_'.$idx.'" />';
+                    } else {
+                        $ctlink = '<b>'.&mt('Mark read').'?</b>&nbsp;<input type="checkbox" name="postread_'.$idx.'" />';
+                    }
 #figure out at what position this needs to print
 		    my $thisindex=$idx;
 		    if ( (($ENV{'environment.threadeddiscussion'}) && (($sortposts eq '') || ($sortposts eq 'ascdate'))) || ($sortposts eq 'thread')) {
@@ -445,6 +459,8 @@
                     my $spansize = 2;
                     if ($showonlyunread && $prevread > $posttime) {
                         $notshown{$idx} = 1;
+                    } elsif ($showunmark && $dischash{$readkey}=~/\.$idx\./) {
+                        $notshown{$idx} = 1;
                     } else {
 # apply filters
                         my $uname = $contrib{$idx.':sendername'};
@@ -508,8 +524,12 @@
                         $discussionitems[$idx] .= '<td align ="left">&nbsp;&nbsp;'.
                             '<b>'.$subject.'</b>&nbsp;&nbsp;'.
                             $sender.'</b> '.$vgrlink.' ('.
-                            &Apache::lonlocal::locallocaltime($posttime).')</td></tr>'.
-                            '</table><blockquote>'.$message.'</blockquote></p>';
+                            &Apache::lonlocal::locallocaltime($posttime).')</td>';
+                        if ($dischash{$toggkey}) {
+                            $discussionitems[$idx].='<td align="right">&nbsp;&nbsp;'.
+                              $ctlink.'</td>';
+                        }
+                        $discussionitems[$idx].= '</tr></table><blockquote>'.$message.'</blockquote></p>';
                         if ($contrib{$idx.':history'}) {
                             my @postversions = ();
                             $discussionitems[$idx] .= '<br />'.&mt('This post has been edited by the author.');
@@ -542,22 +562,31 @@
         'cuse' => 'Current discussion settings',
         'allposts' => 'All posts',
         'unread' => 'New posts only',
+        'unmark' => 'Unread only',
         'ondisp' => 'Once displayed',
-        'onmark' => 'Once marked read',
+        'onmark' => 'Once marked not NEW',
+        'toggoff' => 'Off',
+        'toggon' => 'On',
         'disa' => 'Posts to be displayed',
         'npce' => 'Posts cease to be marked "NEW"',
+        'epcb' => 'Each post can be toggled read/unread', 
         'chgt' => 'Change',
         'disp' => 'Display',
         'nolo' => 'Not new',
+        'togg' => 'Toggle read/unread',
     );
 
     my $currdisp = $lt{'allposts'};
     my $currmark = $lt{'onmark'};
+    my $currtogg = $lt{'toggoff'};
     my $dispchange = $lt{'unread'};
     my $markchange = $lt{'ondisp'};
+    my $toggchange = $lt{'toggon'};
     my $chglink = '/adm/feedback?modifydisp='.$ressymb;
-    my $displink = 'onlyunread';
+    my $displinkA = 'onlyunread';
+    my $displinkB = 'onlyunmark';
     my $marklink = 'markondisp';
+    my $togglink = 'toggon';
 
     if ($markondisp) {
         $currmark = $lt{'ondisp'};
@@ -568,10 +597,24 @@
     if ($showonlyunread) {
         $currdisp = $lt{'unread'};
         $dispchange = $lt{'allposts'};
-        $displink = 'allposts';
+        $displinkA = 'allposts';
     }
+
+    if ($showunmark) {
+        $currdisp = $lt{'unmark'};
+        $dispchange = $lt{'unmark'};
+        $displinkA='allposts';
+        $displinkB='onlyunread';
+        $showonlyunread = 0;
+    }
+
+    if ($dischash{$toggkey}) {
+        $currtogg = $lt{'toggon'};
+        $toggchange = $lt{'toggoff'};
+        $togglink = 'toggoff';
+    } 
    
-    $chglink .= '&changes='.$displink.'_'.$marklink;
+    $chglink .= '&changes='.$displinkA.'_'.$displinkB.'_'.$marklink.'_'.$togglink;
 
     if ($newpostsflag) {
         $chglink .= '&previous='.$prevread;
@@ -595,7 +638,7 @@
    }
 </script>
             |;
-	    $discussion.='<table bgcolor="#AAAAAA" cellpadding="2" cellspacing="2" border="0">';
+	    $discussion.='<form name="readchoices" method="post" action="/adm/feedback?chgreads='.$symb.'"><table bgcolor="#AAAAAA" cellpadding="2" cellspacing="2" border="0">';
 	    $discussion .='<tr><td bgcolor="#DDDDBB" colspan="'.$colspan.'">'.
 		'<table border="0" width="100%" bgcolor="#DDDDBB"><tr>';
 	    if ($visible>2) {
@@ -625,7 +668,7 @@
             $discussion .= '">'.&mt('Export').'?</a>&nbsp;&nbsp;</td>';
 	    if ($newpostsflag) {
 		if (!$markondisp) {
-		    $discussion .='<td align="right"><a href="/adm/feedback?markread='.$ressymb.'">'.&mt('Mark new posts as read').'</a>&nbsp;&nbsp;';
+		    $discussion .='<td align="right"><a href="/adm/feedback?markread='.$ressymb.'">'.&mt('Mark NEW posts no longer new').'</a>&nbsp;&nbsp;';
 		} else {
 		    $discussion .= '<td>&nbsp;</td>';
 		}
@@ -649,8 +692,13 @@
                 $discussion .= '&previous='.$prevread;
             }
             $discussion .= '">'.&mt('Show all posts').'</a> '.&mt('to display').' '.
-                         $numhidden.' '.&mt('previously viewed posts').
-                         '<br/></td></tr>';
+                         $numhidden.' ';
+            if ($showunmark) {
+                $discussion .= &mt('posts previously marked read');
+            } else {
+                $discussion .= &mt('previously viewed posts');
+            }
+            $discussion .= '<br/></td></tr>';
         }
 
 # Choose sort mechanism
@@ -723,7 +771,7 @@
         }
 	if ($outputtarget ne 'tex') {
             my $colspan=$maxdepth+1;
-            $discussion .= <<END; 
+            $discussion .= <<END;
             <tr bgcolor="#FFFFFF">
              <td colspan="$colspan" valign="top">
               <table border="0" bgcolor="#FFFFFF" width="100%" cellspacing="2" cellpadding="2">
@@ -734,27 +782,47 @@
                    <td>
                     <font size="-1"><b>$lt{'cuse'}</b>:</td>
                    <td>&nbsp;</td>
+                   <td><font size="-1">
 END
             if ($newpostsflag) {
                 $discussion .= 
-                   '<td><font size="-1">1.&nbsp;'.$lt{'disp'}.'&nbsp;-&nbsp;<i>'.$currdisp.'</i>&nbsp;&nbsp;2.&nbsp;'.$lt{'nolo'}.'&nbsp;-&nbsp;<i>'.$currmark.'</i></font></td>';
+                   '1.&nbsp;'.$lt{'disp'}.'&nbsp;-&nbsp;<i>'.$currdisp.'</i>&nbsp;&nbsp;2.&nbsp;'.$lt{'nolo'}.'&nbsp;-&nbsp;<i>'.$currmark.'</i>';
+                if ($dischash{$toggkey}) {
+                   $discussion .= '&nbsp;&nbsp;3.&nbsp;'.$lt{'togg'}.'&nbsp;-&nbsp;<i>'.$currtogg.'</i>';
+                }
             } else {
-                $discussion .=
-                   '<td><font size="-1">'.$lt{'disp'}.'&nbsp;-&nbsp;<i>'.$currdisp.'</i></font></td>';
+                if ($dischash{$toggkey}) {
+                   $discussion .= '1.&nbsp;'.$lt{'disp'}.'&nbsp;-&nbsp;<i>'.$currdisp.'</i>&nbsp;2.&nbsp;'.$lt{'togg'}.'&nbsp;-&nbsp;<i>'.$currtogg.'</i>';
+                } else {
+                    $discussion .=
+                         $lt{'disp'}.'&nbsp;-&nbsp;<i>'.$currdisp.'</i>';
+                }
             }
             $discussion .= <<END;
+                   </font></td>
                    <td>&nbsp;</td>
                    <td>
-                    <font size="-1"><b><a href="$chglink">$lt{'chgt'}</a>?</font></b></td>
+                    <font size="-1"><b><a href="$chglink">$lt{'chgt'}</a>?</font></b>
+                   </td>
                   </tr>
                  </table>
                 </td>
+END
+            if ($dischash{$toggkey}) {
+                my $storebutton = &mt('Store read/unread changes');
+                $discussion.='<td align="right">'.
+              '<input type="hidden" name="discsymb" value="'.$ressymb.'">'."\n".
+              '<input type="button" name="readoptions" value="'.$storebutton.'"'.
+              ' onClick="this.form.submit();">'."\n".
+              '</td>';
+            }
+            $discussion .= (<<END);
                </tr>
               </table>
              </td>
             </tr>
            </table>
-           <br /><br />
+           <br /><br /></form>
 END
 	}
     }
@@ -1137,7 +1205,7 @@
 }
 
 sub print_display_options {
-    my ($r,$symb,$previous,$dispchg,$markchg,$feedurl) = @_;
+    my ($r,$symb,$previous,$dispchgA,$dispchgB,$markchg,$toggchg,$feedurl) = @_;
  # backward compatibility (bulletin boards used to be 'wrapped')
     if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) {
         $feedurl=~s|^/adm/wrapper||;
@@ -1157,54 +1225,116 @@
         'deff' => 'Default for all discussions',
         'prca' => 'Preferences can be set for this discussion that determine ....',
         'whpo' => 'Which posts are displayed when you display this bulletin board or resource, and',
-        'unwh' => 'Under what circumstances posts are identfied as "New."',
+        'unwh' => 'Under what circumstances posts are identified as "NEW", and',
+        'wipa' => 'Whether individual posts can be marked as read/unread',
         'allposts' => 'All posts',
         'unread' => 'New posts only',
+        'unmark' => 'Posts not marked read',
         'ondisp' => 'Once displayed',
-        'onmark' => 'Once marked as read',
+        'onmark' => 'Once marked not NEW ',
+        'toggon' => 'Shown',
+        'toggoff' => 'Not shown',
         'disa' => 'Posts displayed?',
-        'npmr' => 'New posts cease to be identified as "New"?',
+        'npmr' => 'New posts cease to be identified as "NEW"?',
+        'dotm' => 'Option to mark each post as read/unread?',  
         'chgt' => 'Change to ',
         'mkdf' => 'Set to ',
-        'yhni' => 'You have not indicated that you wish to change either of the discussion settings',
+        'yhni' => 'You have not indicated that you wish to change any of the discussion settings',
         'ywbr' => 'You will be returned to the previous page if you click OK.'
     );
 
-    my $dispchange = $lt{'unread'};
+    my $dispchangeA = $lt{'unread'};
+    my $dispchangeB = $lt{'unmark'};
     my $markchange = $lt{'ondisp'};
+    my $toggchange = $lt{'toggon'};
     my $currdisp = $lt{'allposts'};
     my $currmark = $lt{'onmark'};
     my $discdisp = 'allposts';
     my $discmark = 'onmark';
+    my $currtogg = $lt{'toggoff'};
+    my $disctogg = 'toggoff';
                                                                                       
-    if ($dispchg eq 'allposts') {
-        $dispchange = $lt{'allposts'};
+    if ($dispchgA eq 'allposts') {
+        $dispchangeA = $lt{'allposts'};
         $currdisp = $lt{'unread'};
         $discdisp = 'unread';
     }
-                                                                                      
+
     if ($markchg eq 'markonread') {
         $markchange = $lt{'onmark'};
         $currmark = $lt{'ondisp'};
         $discmark = 'ondisp';
     }
+
+    if ($dispchgB eq 'onlyunread') {
+        $dispchangeB = $lt{'unread'};
+        $currdisp = $lt{'unmark'};
+        $discdisp = 'unmark';
+    }
+    if ($toggchg eq 'toggoff') {
+        $toggchange = $lt{'toggoff'};
+        $currtogg = $lt{'toggon'};
+        $disctogg = 'toggon';
+    }
     $r->print(<<END);
 <html>
 <head>
 <title>$lt{'dido'}</title>
 <meta http-equiv="pragma" content="no-cache" />
 <script>
+function discdispChk(caller) {
+    var disctogg = '$toggchg'
+    if (caller == 0) {
+        if (document.modifydisp.discdisp[0].checked == true) {
+            if (document.modifydisp.discdisp[1].checked == true) {
+                document.modifydisp.discdisp[1].checked = false
+            }
+        }
+    }
+    if (caller == 1) {
+        if (document.modifydisp.discdisp[1].checked == true) {
+            if (document.modifydisp.discdisp[0].checked == true) {
+                document.modifydisp.discdisp[0].checked = false
+            }
+            if (disctogg == 'toggon') {
+                document.modifydisp.disctogg.checked = true
+            }
+            if (disctogg == 'toggoff') {
+                document.modifydisp.disctogg.checked = false
+            }
+        }
+    }
+    if (caller == 2) {
+        var dispchgB = '$dispchgB'
+        if (disctogg == 'toggoff') {
+            if (document.modifydisp.disctogg.checked == true) {
+                if (dispchgB == 'onlyunmark') {
+                    document.modifydisp.discdisp[1].checked = false
+                }
+            }
+        }
+    }  
+}
+
 function setDisp() {
     var prev = "$previous"
     var chktotal = 0
-    if (document.modifydisp.discdisp.checked == true) {
-        document.modifydisp.$dispchg.value = "$symb"
+    if (document.modifydisp.discdisp[0].checked == true) {
+        document.modifydisp.$dispchgA.value = "$symb"
+        chktotal ++
+    }
+    if (document.modifydisp.discdisp[1].checked == true) {
+        document.modifydisp.$dispchgB.value = "$symb"
         chktotal ++
     }
     if (document.modifydisp.discmark.checked == true) {
         document.modifydisp.$markchg.value = "$symb"
         chktotal ++
     }
+    if (document.modifydisp.disctogg.checked == true) {
+        document.modifydisp.$toggchg.value = "$symb"
+        chktotal ++
+    }
     if (chktotal > 0) { 
         document.modifydisp.submit()
     } else {
@@ -1221,7 +1351,7 @@
 </head>
 $bodytag
 <form name="modifydisp" method="post" action="/adm/feedback">
-$lt{'sdpf'}<br/> $lt{'prca'}  <ol><li>$lt{'whpo'}</li><li>$lt{'unwh'}</li></ol>
+$lt{'sdpf'}<br/> $lt{'prca'}  <ol><li>$lt{'whpo'}</li><li>$lt{'unwh'}</li><li>$lt{'wipa'}</li></ol>
 <br />
 <table border="0" cellpadding="0" cellspacing="0">
  <tr>
@@ -1238,11 +1368,18 @@
        <tr bgcolor="#dddddd">
        <td>$lt{'disa'}</td>
        <td>$lt{$discdisp}</td>
-       <td><input type="checkbox" name="discdisp" />&nbsp;$lt{'chgt'} "$dispchange"</td>
+       <td><input type="checkbox" name="discdisp" onClick="discdispChk('0')" />&nbsp;$lt{'chgt'} "$dispchangeA"
+           <br />
+           <input type="checkbox" name="discdisp" onClick="discdispChk('1')" />&nbsp;$lt{'chgt'} "$dispchangeB"
+       </td>
       </tr><tr bgcolor="#eeeeee">
        <td>$lt{'npmr'}</td>
        <td>$lt{$discmark}</td>
        <td><input type="checkbox" name="discmark" />$lt{'chgt'} "$markchange"</td>
+      </tr><tr bgcolor="#dddddd">
+       <td>$lt{'dotm'}</td>
+       <td>$lt{$disctogg}</td>
+       <td><input type="checkbox" name="disctogg" onClick="discdispChk('2')" />$lt{'chgt'} "$toggchange"</td>
       </tr>
      </table>
     </td>
@@ -1254,8 +1391,10 @@
 <br />
 <br />
 <input type="hidden" name="previous" value="$previous" />
-<input type="hidden" name="$dispchg" value=""/>
+<input type="hidden" name="$dispchgA" value=""/>
+<input type="hidden" name="$dispchgB" value=""/>
 <input type="hidden" name="$markchg" value=""/>
+<input type="hidden" name="$toggchg" value="" />
 <input type="button" name="sub" value="Store Changes" onClick="javascript:setDisp()" />
 <br />
 <br />
@@ -2258,7 +2397,37 @@
 # --------------------------- Get query string for limited number of parameters
 
   &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
-         ['hide','unhide','deldisc','postdata','preview','replydisc','editdisc','threadedon','threadedoff','onlyunread','allposts','previous','markread','markonread','markondisp','modifydisp','changes','navmaps','navurl','sortfilter','sortposts','applysort','rolefilter','statusfilter','sectionpick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions']);
+         ['hide','unhide','deldisc','postdata','preview','replydisc','editdisc','threadedon','threadedoff','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navmaps','navurl','sortfilter','sortposts','applysort','rolefilter','statusfilter','sectionpick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions']);
+  if ($ENV{'form.discsymb'}) {
+      my $symb = $ENV{'form.discsymb'};
+      my $readkey = $symb.'_read';
+      my %readinghash = ();
+      my $chgcount = 0;
+      %readinghash = &Apache::lonnet::get('nohist_'.$ENV{'request.course.id'}.'_discuss',[$readkey],$ENV{'user.domain'},$ENV{'user.name'});
+      foreach my $key (keys %ENV) {
+          if ($key =~ m/^form\.postunread_(\d+)/) {
+              if ($readinghash{$readkey} =~ /\.$1\./) {
+                  $readinghash{$readkey} =~ s/\.$1\.//;
+                  $chgcount ++;
+              }
+          } elsif ($key =~ m/^form\.postread_(\d+)/) {
+              unless ($readinghash{$readkey} =~ /\.$1\./) {
+                  $readinghash{$readkey} .= '.'.$1.'.';
+                  $chgcount ++;
+              }
+          }
+      }
+      if ($chgcount > 0) {
+          &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%readinghash,$ENV{'user.domain'},$ENV{'user.name'});
+      }
+      &Apache::loncommon::content_type($r,'text/html');
+      $r->send_http_header;
+      my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
+      my $previous=$ENV{'form.previous'};
+      my $feedurl = &Apache::lonnet::clutter($url);
+      &redirect_back($r,$feedurl,&mt('Marked postings read/unread').'<br />','0','0','',$previous,'','','',);
+      return OK;
+  }
   if ($ENV{'form.allversions'}) {
       &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;
@@ -2479,19 +2648,36 @@
       my $symb=$ENV{'form.modifydisp'};
       my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
       my $previous=$ENV{'form.previous'};
-      my ($dispchg,$markchg) = split/_/,$ENV{'form.changes'};
+      my ($dispchgA,$dispchgB,$markchg,$toggchg) = split/_/,$ENV{'form.changes'};
       my $feedurl = &Apache::lonnet::clutter($url);
  # backward compatibility (bulletin boards used to be 'wrapped')  
       if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) {
           $feedurl=~s|^/adm/wrapper||;
       }
-      &print_display_options($r,$symb,$previous,$dispchg,$markchg,$feedurl);
+      &print_display_options($r,$symb,$previous,$dispchgA,$dispchgB,$markchg,$toggchg,$feedurl);
       return OK;
-  } elsif (($ENV{'form.markondisp'}) || ($ENV{'form.markonread'}) || ($ENV{'form.allposts'}) || ($ENV{'form.onlyunread'}) ) {
+  } elsif (($ENV{'form.markondisp'}) || ($ENV{'form.markonread'}) || ($ENV{'form.allposts'}) || ($ENV{'form.onlyunread'}) || $ENV{'form.onlyunmark'} || $ENV{'form.toggoff'} || $ENV{'form.toggon'} ) {
       &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;
       my $previous=$ENV{'form.previous'};
       my ($map,$ind,$url);
+      if ( ($ENV{'form.toggoff'}) || ($ENV{'form.toggon'}) ) {
+# ------------------------------ Modify setting for read/unread toggle for each post 
+          my $symb=$ENV{'form.toggoff'}?$ENV{'form.toggoff'}:$ENV{'form.toggon'};
+          my $ressymb = $symb;
+          ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
+          unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
+              $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
+          }
+          my %discinfo = ();
+          my $toggkey = $ressymb.'_readtoggle';
+          if ($ENV{'form.toggon'}) {
+              $discinfo{$toggkey} = 1;
+          } elsif ($ENV{'form.toggoff'}) {
+              $discinfo{$toggkey} = 0;
+          }
+          &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
+      }
       if (($ENV{'form.markondisp'}) || ($ENV{'form.markonread'})) {
 # ---------------------- Modify setting for identification of 'NEW' posts in this discussion
           my $symb=$ENV{'form.markondisp'}?$ENV{'form.markondisp'}:$ENV{'form.markonread'};
@@ -2514,9 +2700,16 @@
           }
           &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
       }
-      if (($ENV{'form.allposts'}) || ($ENV{'form.onlyunread'})) {
+      if (($ENV{'form.allposts'}) || ($ENV{'form.onlyunread'}) || ($ENV{'form.onlyunmark'}) ) {
 # ----------------------------------------------------------------- Modify display setting for this discussion 
-          my $symb=$ENV{'form.allposts'}?$ENV{'form.allposts'}:$ENV{'form.onlyunread'};
+          my $symb;
+          if ($ENV{'form.allposts'}) {
+              $symb = $ENV{'form.allposts'};
+          } elsif ($ENV{'form.onlyunread'}) {
+              $symb = $ENV{'form.onlyunread'};
+          } else {
+              $symb = $ENV{'form.onlyunmark'};
+          }
           my $ressymb = $symb;
           ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
           unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
@@ -2525,19 +2718,22 @@
           my %discinfo = ();
           if ($ENV{'form.allposts'}) {
               $discinfo{$ressymb.'_showonlyunread'} = 0;
+              $discinfo{$ressymb.'_showonlyunmark'} = 0;
           } elsif ($ENV{'form.onlyunread'}) {
               $discinfo{$ressymb.'_showonlyunread'} = 1;
+          } else {
+              $discinfo{$ressymb.'_showonlyunmark'} = 1;
           }
           &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
       }
-      if (($ENV{'form.markonread'}) || ($ENV{'form.allposts'}) || ($ENV{'form.onlyunread'}) ) {
+      if (($ENV{'form.markonread'}) || ($ENV{'form.allposts'}) || ($ENV{'form.onlyunread'}) || ($ENV{'form.onlyunmark'}) ||($ENV{'form.toggoff'}) || ($ENV{'form.toggon'}) ) {
           &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed display status').'<br />','0','0','',$previous);
       } else {
           &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed display status').'<br />','0','0');
       }
       return OK;
   } elsif ($ENV{'form.markread'}) {
-# ----------------------------------------------------------------- Mark new posts as read
+# ----------------------------------------------------------------- Mark new posts not NEW 
       &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;
       my $symb=$ENV{'form.markread'};
@@ -2668,6 +2864,12 @@
           $attachmenturls = $contrib{$idx.':attachmenturl'};
       }
       &modify_attachments($r,\@currnewattach,\@currdelold,$symb,$idx,$attachmenturls);
+  } elsif ($ENV{'form.chgreads'}) {
+      &Apache::loncommon::content_type($r,'text/html');
+      $r->send_http_header;
+      my ($map,$ind,$url)=&Apache::lonnet::decode_symb($ENV{'form.chgreads'});
+      &redirect_back($r,&Apache::lonnet::clutter($url),
+       &mt('Changed read status').'<br />','0','0');
   } else {
 # ------------------------------------------------------------- Normal feedback
   my $feedurl=$ENV{'form.postdata'};

--raeburn1091376314--