--- loncom/interface/lonfeedback.pm	2005/10/04 18:27:32	1.169
+++ loncom/interface/lonfeedback.pm	2005/11/20 02:12:35	1.176
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.169 2005/10/04 18:27:32 albertel Exp $
+# $Id: lonfeedback.pm,v 1.176 2005/11/20 02:12:35 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -39,12 +39,14 @@ use Apache::lonnet;
 use Apache::lonhtmlcommon();
 use Apache::lonnavmaps;
 use Apache::lonenc();
+use Apache::lonrss();
 use HTML::LCParser();
 use Apache::lonspeller();
 use Cwd;
 
 sub discussion_open {
     my ($status,$symb)=@_;
+    if ($env{'request.role.adv'}) { return 1; }
     if (defined($status) &&
 	!($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER'
 	  || $status eq 'OPEN')) {
@@ -236,7 +238,8 @@ sub list_discussion {
     my %notshown = ();
     my %newitem = ();
     my $maxdepth=0;
-
+    my %anonhash=();
+    my $anoncnt=0;
     my $target='';
     unless ($env{'browser.interface'} eq 'textual' ||
 	    $env{'environment.remote'} eq 'off' ) {
@@ -247,7 +250,7 @@ sub list_discussion {
     $discinfo{$visitkey} = $visit;
 
     &Apache::lonnet::put('nohist_'.$cid.'_discuss',\%discinfo,$env{'user.domain'},$env{'user.name'});
-    &build_posting_display(\%usernamesort,\%subjectsort,\%namesort,\%notshown,\%newitem,\%dischash,\%shown,\%alldiscussion,\%imsitems,\%imsfiles,\%roleinfo,\@discussionitems,\@replies,\@depth,\@posters,\$maxdepth,\$visible,\$newpostsflag,\$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$encsymb,$target,$readkey,$showunmark,$showonlyunread,$totposters,\@rolefilter,\@sectionpick,$statusfilter,$toggkey,$outputtarget);
+    &build_posting_display(\%usernamesort,\%subjectsort,\%namesort,\%notshown,\%newitem,\%dischash,\%shown,\%alldiscussion,\%imsitems,\%imsfiles,\%roleinfo,\@discussionitems,\@replies,\@depth,\@posters,\$maxdepth,\$visible,\$newpostsflag,\$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$encsymb,$target,$readkey,$showunmark,$showonlyunread,$totposters,\@rolefilter,\@sectionpick,$statusfilter,$toggkey,$outputtarget,\%anonhash,$anoncnt);
 
     my $discussion='';
     my $manifestfile;
@@ -391,19 +394,20 @@ imscp_v1p1.xsd http://www.imsglobal.org/
 	    $discussion.='<form name="readchoices" method="post" action="/adm/feedback?chgreads='.$ressymb.'" ><table bgcolor="#AAAAAA" cellpadding="2" cellspacing="2" border="0">';
 	    $discussion .='<tr><td bgcolor="#DDDDBB" colspan="'.$colspan.'">'.
 		'<table border="0" width="100%" bgcolor="#DDDDBB"><tr>';
+	    my $escsymb=&Apache::lonnet::escape($ressymb);
 	    if ($visible>2) {
 		$discussion.='<td align="left">'.
-		    '<a href="/adm/feedback?cmd=threadedon&amp;symb='.$ressymb;
+		    '<a href="/adm/feedback?cmd=threadedon&amp;symb='.$escsymb;
 		if ($newpostsflag) {
 		    $discussion .= '&previous='.$prevread;
 		}
 		$discussion .='">'.&mt('Threaded View').'</a>&nbsp;&nbsp;'.
-		    '<a href="/adm/feedback?cmd=threadedoff&amp;symb='.$ressymb;
+		    '<a href="/adm/feedback?cmd=threadedoff&amp;symb='.$escsymb;
 		if ($newpostsflag) {
 		    $discussion .= '&previous='.$prevread;
 		}
 		$discussion .='">'.&mt('Chronological View').'</a>&nbsp;&nbsp;
-                              <a href= "/adm/feedback?cmd=sortfilter&amp;symb='.$ressymb;
+                              <a href= "/adm/feedback?cmd=sortfilter&amp;symb='.$escsymb;
                 if ($newpostsflag) {
                     $discussion .= '&previous='.$prevread;
                 }
@@ -411,14 +415,16 @@ imscp_v1p1.xsd http://www.imsglobal.org/
             } else {
                 $discussion .= '<td align="left">';
             }
-            $discussion .='<a href= "/adm/feedback?export='.$ressymb;
+            $discussion .='<a href= "/adm/feedback?export='.$escsymb;
             if ($newpostsflag) {
                 $discussion .= '&previous='.$prevread;
             }
             $discussion .= '">'.&mt('Export').'?</a>&nbsp;&nbsp;</td>';
 	    if ($newpostsflag) {
 		if (!$markondisp) {
-		    $discussion .='<td align="right"><a href="/adm/feedback?markread=1&amp;symb='.$ressymb.'">'.&mt('Mark NEW posts no longer new').'</a>&nbsp;&nbsp;';
+		    $discussion .='<td align="right"><a href="/adm/preferences?action=changediscussions">'.
+			&mt('Preferences on what is marked as NEW').
+			'</a><br /><a href="/adm/feedback?markread=1&amp;symb='.$escsymb.'">'.&mt('Mark NEW posts no longer new').'</a>';
 		} else {
 		    $discussion .= '<td>&nbsp;</td>';
 		}
@@ -431,7 +437,7 @@ imscp_v1p1.xsd http://www.imsglobal.org/
             if ($numhidden > 0) {
                 my $colspan = $maxdepth+1;
                 $discussion.="\n".'<tr><td bgcolor="#CCCCCC" colspan="'.$colspan.'">'.
-                         '<a href="/adm/feedback?allposts=1&amp;symb='.$ressymb;
+                         '<a href="/adm/feedback?allposts=1&amp;symb='.$escsymb;
                 if ($newpostsflag) {
                     $discussion .= '&previous='.$prevread;
                 }
@@ -744,7 +750,7 @@ ENDDISCUSS
 	        ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
 	    if ($outputtarget ne 'tex') {
 		$discussion.='<table bgcolor="#BBBBBB"><tr><td><a href="/adm/feedback?replydisc='.
-		    $ressymb.':::" '.$target.'>'.
+		    &Apache::lonnet::escape($ressymb).':::" '.$target.'>'.
 		    '<img src="'.&Apache::loncommon::lonhttpdurl('/adm/lonMisc/chat.gif').'" border="0" />'.
 		    &mt('Post Discussion').'</a></td></tr></table>';
 	    }
@@ -754,10 +760,11 @@ ENDDISCUSS
 }
 
 sub build_posting_display {
-    my ($usernamesort,$subjectsort,$namesort,$notshown,$newitem,$dischash,$shown,$alldiscussion,$imsitems,$imsfiles,$roleinfo,$discussionitems,$replies,$depth,$posters,$maxdepth,$visible,$newpostsflag,$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$ressymb,$target,$readkey,$showunmark,$showonlyunread,$totposters,$rolefilter,$sectionpick,$statusfilter,$toggkey,$outputtarget) = @_;
+    my ($usernamesort,$subjectsort,$namesort,$notshown,$newitem,$dischash,$shown,$alldiscussion,$imsitems,$imsfiles,$roleinfo,$discussionitems,$replies,$depth,$posters,$maxdepth,$visible,$newpostsflag,$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$ressymb,$target,$readkey,$showunmark,$showonlyunread,$totposters,$rolefilter,$sectionpick,$statusfilter,$toggkey,$outputtarget,$anonhash,$anoncnt) = @_;
     my @original=();
     my @index=();
     my $symb=&Apache::lonenc::check_decrypt($ressymb);
+    my $escsymb=&Apache::lonnet::escape($ressymb);
     my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
 			  $env{'course.'.$env{'request.course.id'}.'.domain'},
 			  $env{'course.'.$env{'request.course.id'}.'.num'});
@@ -821,6 +828,13 @@ sub build_posting_display {
                 my %allattachments = ();
                 my ($screenname,$plainname);
                 my $sender = &mt('Anonymous');
+# Anonymous users getting number within a discussion
+# Since idx is in static order, this should give the same sequence every time. 
+		my $key=$contrib{$idx.':sendername'}.'@'.$contrib{$idx.':senderdomain'};
+		unless ($$anonhash{$key}) {
+                    $anoncnt++;
+		    $$anonhash{$key}=&mt('Anonymous').' '.$anoncnt;
+		}
                 my ($message,$subject,$vgrlink,$ctlink);
                 &get_post_contents(\%contrib,$idx,$seeid,$outputtarget,\%messages,\%subjects,\%allattachments,\%attachtxt,$imsfiles,\$screenname,\$plainname,$numoldver);
 
@@ -859,7 +873,7 @@ sub build_posting_display {
 					 $contrib{$idx.':sendername'}.' at '.
 					 $contrib{$idx.':senderdomain'}.')';
 			    if ($contrib{$idx.':anonymous'}) {
-			        $sender.=' <font color="red"><b>['.&mt('anonymous').']</b></font> '.
+			        $sender.=' <font color="red"><b>['.$$anonhash{$key}.']</b></font> '.
 				    $screenname;
 			    }
 
@@ -895,13 +909,13 @@ sub build_posting_display {
                             if ($env{'course.'.$env{'request.course.id'}.'.allow_discussion_post_editing'} =~ m/yes/i) {
                                 if (($env{'user.domain'} eq $contrib{$idx.':senderdomain'}) && ($env{'user.name'} eq $contrib{$idx.':sendername'})) {
                                     $sender.=' <a href="/adm/feedback?editdisc='.
-                                         $ressymb.':::'.$idx;
+                                         $escsymb.':::'.$idx;
                                     if ($newpostsflag) {
                                         $sender .= '&previous='.$prevread;
                                     }
                                     $sender .= '" '.$target.'>'.&mt('Edit').'</a>';                                             
                                     unless ($seeid) {
-                                        $sender.=" <a href=\"javascript:studentdelete('$ressymb','$idx','$newpostsflag','$prevread')";
+                                        $sender.=" <a href=\"javascript:studentdelete('$escsymb','$idx','$newpostsflag','$prevread')";
                                         $sender .= '">'.&mt('Delete').'</a>';
                                     }
                                 }
@@ -910,7 +924,7 @@ sub build_posting_display {
 			        if ($hidden) {
                                     unless ($studenthidden) {
 			                $sender.=' <a href="/adm/feedback?unhide='.
-				                $ressymb.':::'.$idx;
+				                $escsymb.':::'.$idx;
                                         if ($newpostsflag) {
                                              $sender .= '&previous='.$prevread;
                                         }
@@ -918,14 +932,14 @@ sub build_posting_display {
                                     }
 			        } else {
 				    $sender.=' <a href="/adm/feedback?hide='.
-				        $ressymb.':::'.$idx;
+				        $escsymb.':::'.$idx;
                                     if ($newpostsflag) {
                                         $sender .= '&previous='.$prevread;
                                     }
                                     $sender .= '">'.&mt('Hide').'</a>';
 			        }                     
 			        $sender.=' <a href="/adm/feedback?deldisc='.
-				        $ressymb.':::'.$idx;
+				        $escsymb.':::'.$idx;
                                 if ($newpostsflag) {
                                     $sender .= '&previous='.$prevread;
                                 }
@@ -934,6 +948,8 @@ sub build_posting_display {
 		        } else {
 			    if ($screenname) {
 			        $sender='<i>'.$screenname.'</i>';
+			    } else {
+				$sender='<i>'.$$anonhash{$key}.'</i>';
 			    }
 # Set up for sorting by domain, then username for anonymous
                             unless (defined($$usernamesort{'__anon'})) {
@@ -959,7 +975,7 @@ sub build_posting_display {
 						 $env{'request.course.id'}.
 						 ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
 			    $sender.=' <a href="/adm/feedback?replydisc='.
-			            $ressymb.':::'.$idx;
+			            $escsymb.':::'.$idx;
                             if ($newpostsflag) {
                                     $sender .= '&previous='.$prevread;
                             }
@@ -1075,7 +1091,7 @@ sub build_posting_display {
                                 my @postversions = ();
                                 $$discussionitems[$idx] .= &mt('This post has been edited by the author.');
                                 if ($seeid) {
-                                    $$discussionitems[$idx] .= '&nbsp;&nbsp;<a href="/adm/feedback?allversions='.$ressymb.':::'.$idx.'">'.&mt('Display all versions').'</a>';
+                                    $$discussionitems[$idx] .= '&nbsp;&nbsp;<a href="/adm/feedback?allversions='.$escsymb.':::'.$idx.'">'.&mt('Display all versions').'</a>';
                                 }
                                 $$discussionitems[$idx].='<br/>'.&mt('Earlier version(s) were posted on: ');
                                 if ($contrib{$idx.':history'} =~ m/:/) {
@@ -1165,11 +1181,11 @@ sub get_post_contents {
 #    $$screenname=&Apache::loncommon::screenname(
 #                                        $$contrib{$idx.':sendername'},
 #                                        $$contrib{$idx.':senderdomain'});
-#    $$plainname=&Apache::loncommon::nickname(
-#                                        $$contrib{$idx.':sendername'},
-#                                        $$contrib{$idx.':senderdomain'});
-    ($$screenname,$$plainname)=($$contrib{$idx.':screenname'},
-				$$contrib{$idx.':plainname'});
+    $$plainname=&Apache::loncommon::nickname(
+                                        $$contrib{$idx.':sendername'},
+                                        $$contrib{$idx.':senderdomain'});
+    $$screenname=$$contrib{$idx.':screenname'};
+
     my $sender=&Apache::loncommon::aboutmewrapper(
                                  $$plainname,
                                  $$contrib{$idx.':sendername'},
@@ -1181,11 +1197,7 @@ sub get_post_contents {
     if ($type eq 'allversions' || $type eq 'export') {
         $start = 0;
         if ($$contrib{$idx.':history'}) {
-            if ($$contrib{$idx.':history'} =~ m/:/) {
-                @postversions = split/:/,$$contrib{$idx.':history'};
-            } else {
-                @postversions = ("$$contrib{$idx.':history'}");
-            }
+	    @postversions = split(/:/,$$contrib{$idx.':history'});
         }
         &get_post_versions($messages,$$contrib{$idx.':message'},1);
         &get_post_versions($subjects,$$contrib{$idx.':subject'},1);
@@ -1289,7 +1301,7 @@ sub replicate_attachments {
 sub mail_screen {
   my ($r,$feedurl,$options) = @_;
   if (exists($env{'form.origpage'})) {
-      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','currnewattach','addnewattach','deloldattach','delnewattach','timestamp','idx','anondiscuss','discuss']);
+      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','currnewattach','addnewattach','deloldattach','delnewattach','timestamp','idx','anondiscuss','discuss','blog']);
   }
   my $bodytag=&Apache::loncommon::bodytag('Resource Feedback and Discussion',
                                           '','onLoad="window.focus();setposttype();"');
@@ -1473,6 +1485,11 @@ $htmlheader
              rec=1;
           } 
         }
+        if (typeof(document.mailform.elements.blog)!="undefined") {
+          if (document.mailform.elements.blog.checked) {
+             rec=1;
+          } 
+        }
 
         if (rec) {
             if (typeof(document.mailform.onsubmit)=='function') {
@@ -2129,7 +2146,7 @@ ENDFAILREDIR
 }
 
 sub redirect_back {
-  my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$status,$previous,$sort,$rolefilter,$statusfilter,$sectionpick,$numpicks) = @_;
+  my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$blog,$status,$previous,$sort,$rolefilter,$statusfilter,$sectionpick,$numpicks) = @_;
   my $sorttag = '';
   my $roletag = '';
   my $statustag = '';
@@ -2211,6 +2228,7 @@ $html
 <img align="right" src="$logo" />
 $typestyle
 <b>Sent $sendsomething message(s), and $sendposts post(s).</b>
+$blog
 <font color="red">$status</font>
 <form name="reldt" action="$feedurl" target="loncapaclient">
 $prevtag
@@ -2293,8 +2311,11 @@ sub screen_header {
 		&mt('Contribution to course discussion of resource');
 	    $discussoptions.='</label><br /><label><input type="checkbox" name="anondiscuss" onClick="this.form.discuss.checked=false;" /> '.
 		&mt('Anonymous contribution to course discussion of resource').
-		' <i>('.&mt('name only visible to course faculty').')</i></label>';
+		' <i>('.&mt('name only visible to course faculty').')</i></label> '.
+		'<a href="/adm/preferences?action=changescreenname">'.&mt('Change Screenname').'</a>';
         }
+        $discussoptions.='<br /><label><input type="checkbox" name="blog" /> '.
+	    &mt('Add to my public course blog').'</label>';
     }
     if ($msgoptions) { $msgoptions='<h2><img src="'.&Apache::loncommon::lonhttpdurl('/adm/lonMisc/feedback.gif').'" />'.&mt('Sending Messages').'</h2>'.$msgoptions; }
     if ($discussoptions) { 
@@ -2640,13 +2661,16 @@ sub newline_to_br {
 }
 
 sub generate_preview_button {
+    my ($formname,$fieldname)=@_;
+    unless ($formname) { $formname='mailform'; }
+    unless ($fieldname) { $fieldname='comment'; }
     my $pre=&mt("Show Preview and Check Spelling");
     return(<<ENDPREVIEW);
 <form name="preview" action="/adm/feedback?preview=1" method="post" target="preview">
 <input type="hidden" name="subject">
 <input type="hidden" name="comment" />
 <input type="button" value="$pre"
-onClick="if (typeof(document.mailform.onsubmit)=='function') {document.mailform.onsubmit();};this.form.comment.value=document.mailform.comment.value;this.form.subject.value=document.mailform.subject.value;this.form.submit();" />
+onClick="if (typeof(document.$formname.onsubmit)=='function') {document.$formname.onsubmit();};this.form.comment.value=document.$formname.$fieldname.value;this.form.subject.value=document.$formname.subject.value;this.form.submit();" />
 </form>
 ENDPREVIEW
 }
@@ -2721,6 +2745,7 @@ END
 <input type="hidden" name="numoldver" value="$env{'form.numoldver'}" />
 <input type="hidden" name="origpage" value="$env{'form.origpage'}" />
 <input type="hidden" name="anondiscuss" value="$env{'form.anondiscuss'}" />
+<input type="hidden" name="blog" value="$env{'form.blog'}" />
 <input type="hidden" name="discuss" value="$env{'form.discuss'}" />
 END
     foreach (@{$currnewattach}) {
@@ -2785,6 +2810,7 @@ this.form.submit();" />
 <input type="hidden" name="timestamp" value="$now" />
 <input type="hidden" name="subject" />
 <input type="hidden" name="comment" />
+<input type="hidden" name="blog" value = "0" />
 <input type="hidden" name="anondiscuss" value = "0" />
 <input type="hidden" name="discuss" value = "0" />
 <input type="hidden" name="numoldver" value="$numoldver" />
@@ -2990,7 +3016,7 @@ sub handler {
 			  \%readinghash,$env{'user.domain'},$env{'user.name'});
       }
       &redirect_back($r,$feedurl,&mt('Marked postings read/unread').'<br />',
-		     '0','0','',$env{'form.previous'},'','','',);
+		     '0','0','','',$env{'form.previous'},'','','',);
       return OK;
   }
   if ($env{'form.allversions'}) {
@@ -3042,14 +3068,14 @@ END
       $discinfo{$symb.'_userpick'} = join('&',@posters);
       &Apache::lonnet::put('nohist_'.$env{'request.course.id'}.'_discuss',
 			   \%discinfo,$env{'user.domain'},$env{'user.name'});
-      &redirect_back($r,$feedurl,&mt('Changed sort/filter').'<br />','0','0',
+      &redirect_back($r,$feedurl,&mt('Changed sort/filter').'<br />','0','0','',
 		     '',$env{'form.previous'},$env{'form.sortposts'},'','','',
 		     $numpicks);
       return OK;
   }
   if ($env{'form.applysort'}) {
       my ($symb,$feedurl)=&get_feedurl_and_clean_symb($env{'form.applysort'});
-      &redirect_back($r,$feedurl,&mt('Changed sort/filter').'<br />','0','0',
+      &redirect_back($r,$feedurl,&mt('Changed sort/filter').'<br />','0','0','',
 		     '',$env{'form.previous'},$env{'form.sortposts'},
 		     $env{'form.rolefilter'},$env{'form.statusfilter'},
 		     $env{'form.sectionpick'});
@@ -3153,7 +3179,7 @@ ENDREDIR
       my $previous=$env{'form.previous'};
       if ($env{'form.markondisp'}) { $previous=undef; }
       &redirect_back($r,$feedurl,&mt('Changed display status').'<br />',
-		     '0','0','',$previous);
+		     '0','0','','',$previous);
       return OK;
   } elsif (($env{'form.hide'}) || ($env{'form.unhide'})) {
 # ----------------------------------------------------------------- Hide/unhide
@@ -3193,7 +3219,7 @@ ENDREDIR
 			   $env{'course.'.$env{'request.course.id'}.'.num'});
 
       &redirect_back($r,$feedurl,&mt('Changed discussion status').'<br />',
-		     '0','0','',$env{'form.previous'});
+		     '0','0','','',$env{'form.previous'});
       return OK;
   } elsif ($env{'form.cmd'}=~/^(threadedoff|threadedon)$/) {
       my ($symb,$feedurl)=&get_feedurl_and_clean_symb($env{'form.symb'});
@@ -3205,7 +3231,7 @@ ENDREDIR
 	  &Apache::lonnet::delenv('environment\.threadeddiscussion');
       }
       &redirect_back($r,$feedurl,&mt('Changed discussion view mode').'<br />',
-		     '0','0','',$env{'form.previous'});
+		     '0','0','','',$env{'form.previous'});
       return OK;
   } elsif ($env{'form.deldisc'}) {
 # --------------------------------------------------------------- Hide for good
@@ -3219,7 +3245,7 @@ ENDREDIR
 			   $env{'course.'.$env{'request.course.id'}.'.domain'},
 			   $env{'course.'.$env{'request.course.id'}.'.num'});
       &redirect_back($r,$feedurl,&mt('Changed discussion status').'<br />',
-		     '0','0','',$env{'form.previous'});
+		     '0','0','','',$env{'form.previous'});
       return OK;
   } elsif ($env{'form.preview'}) {
 # -------------------------------------------------------- User wants a preview
@@ -3229,7 +3255,7 @@ ENDREDIR
 # -------------------------------------------------------- Work on attachments
       &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;
-      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','addnewattach','delnewattach','timestamp','numoldver','idx','anondiscuss','discuss']);
+      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','addnewattach','delnewattach','timestamp','numoldver','idx','anondiscuss','discuss','blog']);
       my (@currnewattach,@currdelold,@keepold);
       &process_attachments(\@currnewattach,\@currdelold,\@keepold);
       if (exists($env{'form.addnewattach.filename'})) {
@@ -3397,9 +3423,21 @@ ENDREDIR
 				  $subject);
 	  $numpost++;
       }
+
+# Add to blog?
+
+      my $blog='';
+      if ($env{'form.blog'}) {
+	  my $subject = &clear_out_html($env{'form.subject'});
+	  $status.=&Apache::lonrss::addentry($env{'user.name'},
+				    $env{'user.domain'},
+				    'CourseBlog_'.$env{'request.course.id'},
+				    $subject,$message,$feedurl,'public');
+	  $blog='<br />'.&mt('Added to my course blog').'<br />';
+      }
 	  
 # Receipt screen and redirect back to where came from
-      &redirect_back($r,$feedurl,$typestyle,$numsent,$numpost,$status,$env{'form.previous'});
+      &redirect_back($r,$feedurl,$typestyle,$numsent,$numpost,$blog,$status,$env{'form.previous'});
   }
   return OK;
 }