File:  [LON-CAPA] / loncom / interface / lonfeedback.pm
Revision 1.82: download - view: text, annotated - select for diffs
Fri May 7 12:03:53 2004 UTC (20 years, 2 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- finishuploadfile works better with a directory specfied
- bb posts, and emails no longer use token wrapper

    1: # The LearningOnline Network
    2: # Feedback
    3: #
    4: # $Id: lonfeedback.pm,v 1.82 2004/05/07 12:03:53 albertel Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: ###
   29: 
   30: package Apache::lonfeedback;
   31: 
   32: use strict;
   33: use Apache::Constants qw(:common);
   34: use Apache::lonmsg();
   35: use Apache::loncommon();
   36: use Apache::lontexconvert();
   37: use Apache::lonlocal;
   38: 
   39: sub list_discussion {
   40:     my ($mode,$status,$symb)=@_;
   41: #    &Apache::lonnet::logthis("status is $status");
   42:     if (!($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER'
   43: 	  || $status eq 'OPEN')) {
   44: 	return '';
   45:     }
   46:     my $discussiononly=0;
   47:     if ($mode eq 'board') { $discussiononly=1; }
   48:     unless ($ENV{'request.course.id'}) { return ''; }
   49:     my $crs='/'.$ENV{'request.course.id'};
   50:     if ($ENV{'request.course.sec'}) {
   51: 	$crs.='_'.$ENV{'request.course.sec'};
   52:     }                 
   53:     $crs=~s/\_/\//g;
   54:     unless ($symb) {
   55: 	$symb=&Apache::lonnet::symbread();
   56:     }
   57:     unless ($symb) { return ''; }
   58: 
   59: # backward compatibility (bulletin boards used to be 'wrapped')
   60:     my $ressymb=$symb;
   61:     if ($mode eq 'board') {
   62:         unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
   63:             $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
   64:         }
   65:     }
   66: 
   67: # Get discussion display settings for this discussion
   68:     my $lastkey = $ressymb.'_lastread';
   69:     my $showkey = $ressymb.'_showonlyunread';
   70:     my $visitkey = $ressymb.'_visit';
   71:     my %dischash = &Apache::lonnet::get('nohist_'.$ENV{'request.course.id'}.'_discuss',[$lastkey,$showkey,$visitkey],$ENV{'user.domain'},$ENV{'user.name'});
   72:     my $showonlyunread = 0;
   73:     my $prevread = 0;
   74:     my $previous = 0;
   75:     my $visit = 0;
   76:     my $newpostsflag = 0;
   77: 
   78: # Retain identification of "NEW" posts identified in last display, if continuing 'previous' browsing of posts.
   79:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['previous']);
   80:     $previous = $ENV{'form.previous'};
   81:     if ($previous > 0) {
   82:         $prevread = $previous;
   83:     } elsif (defined($dischash{$lastkey})) {
   84:         $prevread = $dischash{$lastkey};
   85:     }
   86: 
   87:     if (defined($dischash{$showkey})) {
   88:         $showonlyunread = $dischash{$showkey};
   89:     }
   90: 
   91:     if (defined($dischash{$visitkey})) {
   92:         $visit = $dischash{$visitkey};
   93:     }
   94:     $visit ++;
   95: 
   96:     my $seeid=&Apache::lonnet::allowed('rin',$crs);
   97:     my $viewgrades=(&Apache::lonnet::allowed('vgr',$crs)
   98: 	&& ($symb=~/\.(problem|exam|quiz|assess|survey|form)$/));
   99:     my @discussionitems=();
  100:     my %contrib=&Apache::lonnet::restore($ressymb,$ENV{'request.course.id'},
  101: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  102: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
  103:     my $visible=0;
  104:     my @depth=();
  105:     my @original=();
  106:     my @index=();
  107:     my @replies=();
  108:     my %alldiscussion=();
  109:     my %notshown = ();
  110:     my $maxdepth=0;
  111: 
  112:     my $target='';
  113:     unless ($ENV{'browser.interface'} eq 'textual' ||
  114: 	    $ENV{'environment.remote'} eq 'off' ) {
  115: 	$target='target="LONcom"';
  116:     }
  117:     
  118:     my $now = time;
  119:     my %discinfo = ();
  120:     $discinfo{$visitkey} = $visit;
  121:     $discinfo{$lastkey} = $now;
  122: 
  123:     &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
  124: 
  125:     if ($contrib{'version'}) {
  126: 	for (my $id=1;$id<=$contrib{'version'};$id++) {
  127: 	    my $idx=$id;
  128:             my $posttime = $contrib{$idx.':timestamp'};
  129:             if ($prevread > 0 && $prevread <= $posttime) {
  130:                 $newpostsflag = 1;
  131:             }
  132: 	    my $hidden=($contrib{'hidden'}=~/\.$idx\./);
  133: 	    my $deleted=($contrib{'deleted'}=~/\.$idx\./);
  134: 	    my $origindex='0.';
  135: 	    if (($contrib{$idx.':replyto'}) && ($ENV{'environment.threadeddiscussion'})) {
  136: # this is a follow-up message
  137: 		$original[$idx]=$original[$contrib{$idx.':replyto'}];
  138: 		$depth[$idx]=$depth[$contrib{$idx.':replyto'}]+1;
  139: 		$origindex=$index[$contrib{$idx.':replyto'}];
  140: 		if ($depth[$idx]>$maxdepth) { $maxdepth=$depth[$idx]; }
  141: 	    } else {
  142: # this is an original message
  143: 		$original[$idx]=0;
  144: 		$depth[$idx]=0;
  145: 	    }
  146: 	    if ($replies[$depth[$idx]]) {
  147: 		$replies[$depth[$idx]]++;
  148: 	    } else {
  149: 		$replies[$depth[$idx]]=1;
  150: 	    }
  151: 	    unless ((($hidden) && (!$seeid)) || ($deleted)) {
  152: 		$visible++;
  153: 		my $message=$contrib{$idx.':message'};
  154: 		$message=~s/\n/\<br \/\>/g;
  155: 		$message=&Apache::lontexconvert::msgtexconverted($message);
  156:                 my $subject=$contrib{$idx.':subject'};
  157:                 if (defined($subject)) {
  158:                     $subject=~s/\n/\<br \/\>/g;
  159:                     $subject=&Apache::lontexconvert::msgtexconverted($subject);
  160:                 }
  161: 		if ($contrib{$idx.':attachmenturl'}) {
  162: 		    my ($fname)
  163:                         =($contrib{$idx.':attachmenturl'}=~m|/([^/]+)$|);
  164: 		    &Apache::lonnet::allowuploaded('/adm/feedback',
  165: 					   $contrib{$idx.':attachmenturl'});
  166: 		    $message.='<p>'.&mt('Attachment').
  167: 			': <a href="'.$contrib{$idx.':attachmenturl'}.'"><tt>'.
  168: 			$fname.'</tt></a></p>';
  169: 		}
  170: 		if ($message) {
  171: 		    if ($hidden) {
  172: 			$message='<font color="#888888">'.$message.'</font>';
  173: 		    }
  174: 		    my $screenname=&Apache::loncommon::screenname(
  175: 					    $contrib{$idx.':sendername'},
  176: 					    $contrib{$idx.':senderdomain'});
  177: 		    my $plainname=&Apache::loncommon::nickname(
  178: 					    $contrib{$idx.':sendername'},
  179: 					    $contrib{$idx.':senderdomain'});
  180: 		    
  181: 		    my $sender=&mt('Anonymous');
  182: 		    if ((!$contrib{$idx.':anonymous'}) || ($seeid)) {
  183: 			$sender=&Apache::loncommon::aboutmewrapper(
  184: 					 $plainname,
  185: 					 $contrib{$idx.':sendername'},
  186: 					 $contrib{$idx.':senderdomain'}).' ('.
  187: 					 $contrib{$idx.':sendername'}.' at '.
  188: 					 $contrib{$idx.':senderdomain'}.')';
  189: 			if ($contrib{$idx.':anonymous'}) {
  190: 			    $sender.=' ['.&mt('anonymous').'] '.
  191: 				$screenname;
  192: 			}
  193: 			if ($seeid) {
  194: 			    if ($hidden) {
  195: 				$sender.=' <a href="/adm/feedback?unhide='.
  196: 				    $ressymb.':::'.$idx;
  197:                                 if ($newpostsflag) {
  198:                                     $sender .= '&previous='.$prevread;
  199:                                 }
  200:                                 $sender .= '">'.&mt('Make Visible').'</a>';
  201: 			    } else {
  202: 				$sender.=' <a href="/adm/feedback?hide='.
  203: 				    $ressymb.':::'.$idx;
  204:                                 if ($newpostsflag) {
  205:                                     $sender .= '&previous='.$prevread;
  206:                                 }
  207:                                 $sender .= '">'.&mt('Hide').'</a>';
  208: 			    }                     
  209: 			    $sender.=' <a href="/adm/feedback?deldisc='.
  210: 				$ressymb.':::'.$idx;
  211:                                 if ($newpostsflag) {
  212:                                     $sender .= '&previous='.$prevread;
  213:                                 }
  214:                                 $sender .= '">'.&mt('Delete').'</a>';
  215: 			}
  216: 		    } else {
  217: 			if ($screenname) {
  218: 			    $sender='<i>'.$screenname.'</i>';
  219: 			}
  220: 		    }
  221: 		    if (&Apache::lonnet::allowed('pch',
  222: 						 $ENV{'request.course.id'}.
  223: 						 ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
  224: 			$sender.=' <a href="/adm/feedback?replydisc='.
  225: 			    $ressymb.':::'.$idx;
  226:                         if ($newpostsflag) {
  227:                             $sender .= '&previous='.$prevread;
  228:                         }
  229:                         $sender .= '" '.$target.'>'.&mt('Reply').'</a>';
  230: 		    }
  231: 		    my $vgrlink;
  232: 		    if ($viewgrades) {
  233: 			$vgrlink=&Apache::loncommon::submlink('Submissions',
  234:             $contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$symb);
  235: 		    }
  236: #figure out at what position this needs to print
  237: 		    my $thisindex=$idx;
  238: 		    if ($ENV{'environment.threadeddiscussion'}) {
  239: 			$thisindex=$origindex.substr('00'.$replies[$depth[$idx]],-2,2);	
  240: 		    }
  241: 		    $alldiscussion{$thisindex}=$idx;
  242: 		    $index[$idx]=$thisindex;
  243:                     my $spansize = 2;
  244:                     if ($showonlyunread && $prevread > $posttime) {
  245:                         $notshown{$idx} = 1;
  246:                     } else {
  247:                         $discussionitems[$idx]='<p><table border="0" width="100%"><tr>';
  248:                         if ($prevread > 0 && $prevread <= $posttime) {
  249:                             $discussionitems[$idx] .= '<td align="left" bgcolor="#FFFFFF"><font color="#FF0000">NEW</font></td>';
  250:                         }
  251:                         $discussionitems[$idx] .= '<td align ="left">&nbsp;&nbsp;'.
  252:                             '<b>'.$subject.'</b>&nbsp;&nbsp;'.
  253:                             $sender.'</b> '.$vgrlink.' ('.
  254:                             localtime($posttime).')</td></tr>'.
  255:                             '</table><blockquote>'.$message.'</blockquote></p>';
  256:                     }
  257:                 }
  258:             }
  259: 	}
  260:     }
  261: 
  262:     my $discussion='';
  263:     if ($visible) {
  264: # Print the discusssion
  265: 	$discussion.='<table bgcolor="#AAAAAA" cellpadding="2" cellspacing="2" border="0">';
  266: 	if ($visible>2) {
  267: 	    my $colspan=$maxdepth+1;
  268: 	    $discussion.='<tr><td bgcolor="DDDDBB" colspan="'.$colspan.'">'.
  269:             '<table border="0" width="100%" bgcolor="#DDDDBB"><tr><td align="left">'.
  270:             '<a href="/adm/feedback?threadedon='.$ressymb.'">'.&mt('Threaded View').'</a>&nbsp;&nbsp;'.
  271:             '<a href="/adm/feedback?threadedoff='.$ressymb.'">'.&mt('Chronological View').'</a>&nbsp;&nbsp;</td>'.
  272:             '<td align="right"><a href="/adm/feedback?';
  273:             if ($showonlyunread) {
  274:                 $discussion .= 'allposts='.$ressymb;
  275:                 if ($newpostsflag) {
  276:                     $discussion .= '&previous='.$prevread;
  277:                 }
  278:                 $discussion .='">'.&mt('Show all posts').'?';
  279:             } else {
  280:                 $discussion .= 'onlyunread='.$ressymb;
  281:                 if ($newpostsflag) {
  282:                     $discussion .= '&previous='.$prevread;
  283:                 }
  284:                 $discussion .= '">'.&mt('Show only unread posts').'?';
  285:             }
  286:             $discussion .= '</a>&nbsp;&nbsp;</td></tr></table></td></tr>';
  287: 	}
  288:         my $numhidden = keys %notshown;
  289:         if ($numhidden > 0) {
  290:             my $colspan = $maxdepth+1;
  291:             $discussion.="\n".'<tr><td bgcolor="#CCCCCC" colspan="'.$colspan.'">'.
  292:                          '<a href="/adm/feedback?allposts='.$ressymb;
  293:             if ($newpostsflag) {
  294:                 $discussion .= '&previous='.$prevread;
  295:             }
  296:             $discussion .= '">'.&mt('Show all posts').'</a> '.&mt('to display').' '.
  297:                          $numhidden.' '.&mt('previously viewed posts').
  298:                          '<br/></td></tr>';
  299:         }
  300: 	foreach (sort { $a <=> $b } keys %alldiscussion) {
  301:             unless ($notshown{$alldiscussion{$_}} eq '1') {
  302: 	        $discussion.="\n<tr>";
  303: 	        my $thisdepth=$depth[$alldiscussion{$_}];
  304: 	        for (1..$thisdepth) {
  305: 		    $discussion.='<td>&nbsp;&nbsp;&nbsp;</td>';
  306: 	        }
  307: 	        my $colspan=$maxdepth-$thisdepth+1;
  308:                 $discussion.='<td  bgcolor="#CCCCCC" colspan="'.$colspan.'">'.
  309:                              $discussionitems[$alldiscussion{$_}].
  310: 	                     '</td></tr>';
  311: 	    }
  312:         }
  313:         $discussion.='</table><br /><br />';
  314:     }
  315:     if ($discussiononly) {
  316: 	$discussion.=(<<ENDDISCUSS);
  317: <form action="/adm/feedback" method="post" name="mailform" enctype="multipart/form-data">
  318: <input type="submit" name="discuss" value="Post Discussion" />
  319: <input type="submit" name="anondiscuss" value="Post Anonymous Discussion" />
  320: <input type="hidden" name="symb" value="$ressymb" />
  321: <input type="hidden" name="sendit" value="true" />
  322: <br />
  323: <font size="1">Note: in anonymous discussion, your name is visible only to
  324: course faculty</font><br />
  325: <b>Title:</b>&nbsp;<input type="text" name="subject" value="" size="30" /><br /><br />
  326: <textarea name="comment" cols="60" rows="10" wrap="hard"></textarea>
  327: <p>
  328: Attachment (128 KB max size): <input type="file" name="attachment" />
  329: </p>
  330: </form>
  331: ENDDISCUSS
  332:       $discussion.=&generate_preview_button();
  333:     } else {
  334: 	if (&Apache::lonnet::allowed('pch',
  335: 				   $ENV{'request.course.id'}.
  336: 	($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
  337: 			    $discussion.='<table bgcolor="#BBBBBB"><tr><td><a href="/adm/feedback?replydisc='.
  338: 				$symb.':::" '.$target.'>'.
  339: 				'<img src="/adm/lonMisc/chat.gif" border="0" />'.
  340: 				&mt('Post Discussion').'</a></td></tr></table>';
  341: 			}
  342:     }
  343:    return $discussion;
  344: }
  345: 
  346: sub mail_screen {
  347:   my ($r,$feedurl,$options) = @_;
  348:   my $bodytag=&Apache::loncommon::bodytag('Resource Feedback and Discussion',
  349:                                           '','onLoad="window.focus();"');
  350:   my $title=&Apache::lonnet::gettitle($feedurl);
  351:   if (!$title) { $title = $feedurl; }
  352:   my $quote='';
  353:   my $subject = '';
  354:   my $prevtag = '';
  355:   if ($ENV{'form.replydisc'}) {
  356:       my ($symb,$idx)=split(/\:\:\:/,$ENV{'form.replydisc'});
  357:       my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
  358: 					   $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  359: 					   $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
  360:       unless (($contrib{'hidden'}=~/\.$idx\./) || ($contrib{'deleted'}=~/\.$idx\./)) {
  361: 	  my $message=$contrib{$idx.':message'};
  362: 	  $message=~s/\n/\<br \/\>/g;
  363: 	  $quote='<blockquote>'.&Apache::lontexconvert::msgtexconverted($message).'</blockquote>';
  364:           if ($idx > 0) {
  365:               $subject = 'Re: '.$contrib{$idx.':subject'};
  366:           }
  367:       }
  368:       if ($ENV{'form.previous'}) {
  369:           $prevtag = '<input type="hidden" name="previous" value="'.$ENV{'form.previous'}.'" />';
  370:       }
  371:   }
  372:   my $latexHelp = Apache::loncommon::helpLatexCheatsheet();
  373:   my $send=&mt('Send');
  374:   $r->print(<<ENDDOCUMENT);
  375: <html>
  376: <head>
  377: <title>The LearningOnline Network with CAPA</title>
  378: <meta http-equiv="pragma" content="no-cache"></meta>
  379: <script type="text/javascript">
  380: //<!--
  381:     function gosubmit() {
  382:         var rec=0;
  383:         if (typeof(document.mailform.elements.author)!="undefined") {
  384:           if (document.mailform.elements.author.checked) {
  385:              rec=1;
  386:           } 
  387:         }
  388:         if (typeof(document.mailform.elements.question)!="undefined") {
  389:           if (document.mailform.elements.question.checked) {
  390:              rec=1;
  391:           } 
  392:         }
  393:         if (typeof(document.mailform.elements.course)!="undefined") {
  394:           if (document.mailform.elements.course.checked) {
  395:              rec=1;
  396:           } 
  397:         }
  398:         if (typeof(document.mailform.elements.policy)!="undefined") {
  399:           if (document.mailform.elements.policy.checked) {
  400:              rec=1;
  401:           } 
  402:         }
  403:         if (typeof(document.mailform.elements.discuss)!="undefined") {
  404:           if (document.mailform.elements.discuss.checked) {
  405:              rec=1;
  406:           } 
  407:         }
  408:         if (typeof(document.mailform.elements.anondiscuss)!="undefined") {
  409:           if (document.mailform.elements.anondiscuss.checked) {
  410:              rec=1;
  411:           } 
  412:         }
  413: 
  414:         if (rec) {
  415: 	    document.mailform.submit();
  416:         } else {
  417:             alert('Please check a feedback type.');
  418: 	}
  419:     }
  420: //-->
  421: </script>
  422: </head>
  423: $bodytag
  424: <h2><tt>$title</tt></h2>
  425: <form action="/adm/feedback" method="post" name="mailform"
  426: enctype="multipart/form-data">
  427: $prevtag
  428: <input type="hidden" name="postdata" value="$feedurl" />
  429: <input type="hidden" name="replydisc" value="$ENV{'form.replydisc'}" />
  430: Please check at least one of the following feedback types:
  431: $options<hr />
  432: $quote
  433: <p>My question/comment/feedback:</p>
  434: <p>
  435: $latexHelp
  436: Title: <input type="text" name="subject" size="30" value="$subject" /></p>
  437: <p>
  438: <textarea name="comment" cols="60" rows="10" wrap="hard">
  439: </textarea></p>
  440: <p>
  441: Attachment (128 KB max size): <input type="file" name="attachment" />
  442: </p>
  443: <p>
  444: <input type="hidden" name="sendit" value="1" />
  445: <input type="button" value="$send" onClick='gosubmit();' />
  446: </p>
  447: </form>
  448: ENDDOCUMENT
  449: $r->print(&generate_preview_button().'</body></html>');
  450: }
  451: 
  452: sub fail_redirect {
  453:   my ($r,$feedurl) = @_;
  454:   if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' };
  455:   $r->print (<<ENDFAILREDIR);
  456: <html>
  457: <head><title>Feedback not sent</title>
  458: <meta http-equiv="pragma" content="no-cache" />
  459: <meta HTTP-EQUIV="Refresh" CONTENT="2; url=$feedurl" />
  460: </head>
  461: <body bgcolor="#FFFFFF">
  462: <img align="right" src="/adm/lonIcons/lonlogos.gif" />
  463: <b>Sorry, no recipients  ...</b>
  464: </body>
  465: </html>
  466: ENDFAILREDIR
  467: }
  468: 
  469: sub redirect_back {
  470:   my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$status,$previous) = @_;
  471:   my $prevtag = '';
  472:   my $qrystr = '';
  473:   if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' };
  474:   if ($previous > 0) {
  475:       $qrystr = 'previous='.$previous;
  476:       if ($feedurl =~ /\?register=1/) {
  477:           $feedurl .= '&'.$qrystr;
  478:       } else {
  479:           $feedurl .= '?'.$qrystr;
  480:       }
  481:       $prevtag = '<input type="hidden" name="previous" value="'.$previous.'" />';
  482:   }
  483:   $r->print (<<ENDREDIR);
  484: <html>
  485: <head>
  486: <title>Feedback sent</title>
  487: <meta http-equiv="pragma" content="no-cache" />
  488: <meta HTTP-EQUIV="Refresh" CONTENT="2; url=$feedurl" />
  489: </head>
  490: <body bgcolor="#FFFFFF" onLoad='if (window.name!="loncapaclient") { this.document.reldt.submit(); self.close(); }'>
  491: <img align="right" src="/adm/lonIcons/lonlogos.gif" />
  492: $typestyle
  493: <b>Sent $sendsomething message(s), and $sendposts post(s).</b>
  494: <font color="red">$status</font>
  495: <form name="reldt" action="$feedurl" target="loncapaclient">
  496: $prevtag
  497: </form>
  498: </body>
  499: </html>
  500: ENDREDIR
  501: }
  502: 
  503: sub no_redirect_back {
  504:   my ($r,$feedurl) = @_;
  505:   $r->print (<<ENDNOREDIR);
  506: <html>
  507: <head><title>Feedback not sent</title>
  508: <meta http-equiv="pragma" content="no-cache" />
  509: ENDNOREDIR
  510: 
  511:   if ($feedurl!~/^\/adm\/feedback/) { 
  512:     $r->print('<meta HTTP-EQUIV="Refresh" CONTENT="2; url='.$feedurl.'">');
  513:   }
  514:   
  515:   $r->print (<<ENDNOREDIRTWO);
  516: </head>
  517: <body bgcolor="#FFFFFF" onLoad='if (window.name!="loncapaclient") { self.close(); }'>
  518: <img align="right" src="/adm/lonIcons/lonlogos.gif" />
  519: <b>Sorry, no feedback possible on this resource  ...</b>
  520: </body>
  521: </html>
  522: ENDNOREDIRTWO
  523: }
  524: 
  525: sub screen_header {
  526:     my ($feedurl) = @_;
  527:     my $msgoptions='';
  528:     my $discussoptions='';
  529:     unless ($ENV{'form.replydisc'}) {
  530: 	if (($feedurl=~/^\/res\//) && ($feedurl!~/^\/res\/adm/)) {
  531: 	    $msgoptions= 
  532: 		'<p><input type="checkbox" name="author" /> '.
  533: 		&mt('Feedback to resource author').'</p>';
  534: 	}
  535: 	if (&feedback_available(1)) {
  536: 	    $msgoptions.=
  537: 		'<br /><input type="checkbox" name="question" /> '.
  538: 		&mt('Question about resource content');
  539: 	}
  540: 	if (&feedback_available(0,1)) {
  541: 	    $msgoptions.=
  542: 		'<br /><input type="checkbox" name="course" /> '.
  543: 		&mt('Question/Comment/Feedback about course content');
  544: 	}
  545: 	if (&feedback_available(0,0,1)) {
  546: 	    $msgoptions.=
  547: 		'<br /><input type="checkbox" name="policy" /> '.
  548: 		&mt('Question/Comment/Feedback about course policy');
  549: 	}
  550:     }
  551:     if ($ENV{'request.course.id'}) {
  552: 	if (&Apache::lonnet::allowed('pch',
  553: 				     $ENV{'request.course.id'}.
  554: 				     ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
  555: 	    $discussoptions='<input type="checkbox" name="discuss" onClick="this.form.anondiscuss.checked=false;" '.
  556: 		($ENV{'form.replydisc'}?' checked="1"':'').' /> '.
  557: 		&mt('Contribution to course discussion of resource');
  558: 	    $discussoptions.='<br /><input type="checkbox" name="anondiscuss" onClick="this.form.discuss.checked=false;" /> '.
  559: 		&mt('Anonymous contribution to course discussion of resource').
  560: 		' <i>('.&mt('name only visible to course faculty').')</i>';
  561:       }
  562:     }
  563:     if ($msgoptions) { $msgoptions='<h2><img src="/adm/lonMisc/feedback.gif" />'.&mt('Sending Messages').'</h2>'.$msgoptions; }
  564:     if ($discussoptions) { 
  565: 	$discussoptions='<h2><img src="/adm/lonMisc/chat.gif" />'.&mt('Discussion Contributions').'</h2>'.$discussoptions; }
  566:     return $msgoptions.$discussoptions;
  567: }
  568: 
  569: sub resource_output {
  570:   my ($feedurl) = @_;
  571:   my $usersaw=&Apache::lonnet::ssi_body($feedurl);
  572:   $usersaw=~s/\<body[^\>]*\>//gi;
  573:   $usersaw=~s/\<\/body\>//gi;
  574:   $usersaw=~s/\<html\>//gi;
  575:   $usersaw=~s/\<\/html\>//gi;
  576:   $usersaw=~s/\<head\>//gi;
  577:   $usersaw=~s/\<\/head\>//gi;
  578:   $usersaw=~s/action\s*\=/would_be_action\=/gi;
  579:   return $usersaw;
  580: }
  581: 
  582: sub clear_out_html {
  583:   my ($message,$override)=@_;
  584:   my $cid=$ENV{'request.course.id'};
  585:   if (($ENV{"course.$cid.allow_limited_html_in_feedback"} =~ m/yes/i) ||
  586:       ($override)) {
  587:       # allows <B> <I> <P> <A> <LI> <OL> <UL> <EM> <BR> <TT> <STRONG> 
  588:       # <BLOCKQUOTE> <DIV .*> <DIV> <IMG>
  589:       my %html=(B=>1, I=>1, P=>1, A=>1, LI=>1, OL=>1, UL=>1, EM=>1,
  590: 		BR=>1, TT=>1, STRONG=>1, BLOCKQUOTE=>1, DIV=>1, IMG=>1,
  591:                 M=>1);
  592: 
  593:       $message =~ s/\<(\/?\s*(\w+)[^\>\<]*)/
  594: 	  {($html{uc($2)}&&(length($1)<1000))?"\<$1":"\&lt;$1"}/ge;
  595:       $message =~ s/(\<?\s*(\w+)[^\<\>]*)\>/
  596: 	  {($html{uc($2)}&&(length($1)<1000))?"$1\>":"$1\&gt;"}/ge;
  597:   } else {
  598:       $message=~s/\</\&lt\;/g;
  599:       $message=~s/\>/\&gt\;/g;
  600:   }
  601:   return $message;
  602: }
  603: 
  604: sub assemble_email {
  605:   my ($feedurl,$message,$prevattempts,$usersaw,$useranswer)=@_;
  606:   my $email=<<"ENDEMAIL";
  607: Refers to <a href="$feedurl">$feedurl</a>
  608: 
  609: $message
  610: ENDEMAIL
  611:     my $citations=<<"ENDCITE";
  612: <h2>Previous attempts of student (if applicable)</h2>
  613: $prevattempts
  614: <br /><hr />
  615: <h2>Original screen output (if applicable)</h2>
  616: $usersaw
  617: <h2>Correct Answer(s) (if applicable)</h2>
  618: $useranswer
  619: ENDCITE
  620:   return ($email,$citations);
  621: }
  622: 
  623: sub secapply {
  624:     my $rec=shift;
  625:     my $defaultflag=shift;
  626:     $rec=~s/\s+//g;
  627:     $rec=~s/\@/\:/g;
  628:     my ($adr,$sections)=($rec=~/^([^\(]+)\(([^\)]+)\)/);
  629:     if ($sections) {
  630: 	foreach (split(/\;/,$sections)) {
  631:             if (($_ eq $ENV{'request.course.sec'}) ||
  632:                 ($defaultflag && ($_ eq '*'))) {
  633:                 return $adr; 
  634:             }
  635:         }
  636:     } else {
  637:        return $rec;
  638:     }
  639:     return '';
  640: }
  641: 
  642: sub decide_receiver {
  643:   my ($feedurl,$author,$question,$course,$policy,$defaultflag) = @_;
  644:   my $typestyle='';
  645:   my %to=();
  646:   if ($ENV{'form.author'}||$author) {
  647:     $typestyle.='Submitting as Author Feedback<br>';
  648:     $feedurl=~/^\/res\/(\w+)\/(\w+)\//;
  649:     $to{$2.':'.$1}=1;
  650:   }
  651:   if ($ENV{'form.question'}||$question) {
  652:     $typestyle.='Submitting as Question<br>';
  653:     foreach (split(/\,/,
  654: 		   $ENV{'course.'.$ENV{'request.course.id'}.'.question.email'})
  655: 	     ) {
  656: 	my $rec=&secapply($_,$defaultflag);
  657:         if ($rec) { $to{$rec}=1; }
  658:     } 
  659:   }
  660:   if ($ENV{'form.course'}||$course) {
  661:     $typestyle.='Submitting as Comment<br />';
  662:     foreach (split(/\,/,
  663: 		   $ENV{'course.'.$ENV{'request.course.id'}.'.comment.email'})
  664: 	     ) {
  665: 	my $rec=&secapply($_,$defaultflag);
  666:         if ($rec) { $to{$rec}=1; }
  667:     } 
  668:   }
  669:   if ($ENV{'form.policy'}||$policy) {
  670:     $typestyle.='Submitting as Policy Feedback<br />';
  671:     foreach (split(/\,/,
  672: 		   $ENV{'course.'.$ENV{'request.course.id'}.'.policy.email'})
  673: 	     ) {
  674: 	my $rec=&secapply($_,$defaultflag);
  675:         if ($rec) { $to{$rec}=1; }
  676:     } 
  677:   }
  678:   if ((scalar(%to) eq '0') && (!$defaultflag)) {
  679:      ($typestyle,%to)=
  680: 	 &decide_receiver($feedurl,$author,$question,$course,$policy,1);
  681:   }
  682:   return ($typestyle,%to);
  683: }
  684: 
  685: sub feedback_available {
  686:     my ($question,$course,$policy)=@_;
  687:     my ($typestyle,%to)=&decide_receiver('',0,$question,$course,$policy);
  688:     return scalar(%to);
  689: }
  690: 
  691: sub send_msg {
  692:   my ($feedurl,$email,$citations,$attachmenturl,%to)=@_;
  693:   my $status='';
  694:   my $sendsomething=0;
  695:   foreach (keys %to) {
  696:     if ($_) {
  697:       my $declutter=&Apache::lonnet::declutter($feedurl);
  698:       unless (&Apache::lonmsg::user_normal_msg(split(/\:/,$_),
  699:                'Feedback ['.$declutter.']',$email,$citations,$feedurl,
  700:                 $attachmenturl)=~/ok/) {
  701: 	$status.='<br />'.&mt('Error sending message to').' '.$_.'<br />';
  702:       } else {
  703: 	$sendsomething++;
  704:       }
  705:     }
  706:   }
  707: 
  708:     my %record=&Apache::lonnet::restore('_feedback');
  709:     my ($temp)=keys %record;
  710:     unless ($temp=~/^error\:/) {
  711:        my %newrecord=();
  712:        $newrecord{'resource'}=$feedurl;
  713:        $newrecord{'subnumber'}=$record{'subnumber'}+1;
  714:        unless (&Apache::lonnet::cstore(\%newrecord,'_feedback') eq 'ok') {
  715: 	   $status.='<br />'.&mt('Not registered').'<br />';
  716:        }
  717:     }
  718:        
  719:   return ($status,$sendsomething);
  720: }
  721: 
  722: sub adddiscuss {
  723:     my ($symb,$email,$anon,$attachmenturl,$subject)=@_;
  724:     my $status='';
  725:     if (&Apache::lonnet::allowed('pch',$ENV{'request.course.id'}.
  726:         ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
  727: 
  728:     my %contrib=('message'      => $email,
  729:                  'sendername'   => $ENV{'user.name'},
  730:                  'senderdomain' => $ENV{'user.domain'},
  731:                  'screenname'   => $ENV{'environment.screenname'},
  732:                  'plainname'    => $ENV{'environment.firstname'}.' '.
  733: 		                   $ENV{'environment.middlename'}.' '.
  734:                                    $ENV{'environment.lastname'}.' '.
  735:                                    $ENV{'enrironment.generation'},
  736:                  'attachmenturl'=> $attachmenturl,
  737:                  'subject'      => $subject);
  738:     if ($ENV{'form.replydisc'}) {
  739: 	$contrib{'replyto'}=(split(/\:\:\:/,$ENV{'form.replydisc'}))[1];
  740:     }
  741:     if ($anon) {
  742: 	$contrib{'anonymous'}='true';
  743:     }
  744:     if (($symb) && ($email)) {
  745:        $status='Adding to class discussion'.($anon?' (anonymous)':'').': '.
  746:         &Apache::lonnet::store(\%contrib,$symb,$ENV{'request.course.id'},
  747:                      $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  748: 		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
  749:         my %storenewentry=($symb => time);
  750:         $status.='<br />'.&mt('Updating discussion time').': '.
  751:         &Apache::lonnet::put('discussiontimes',\%storenewentry,
  752:                      $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  753: 		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
  754:     }
  755:     my %record=&Apache::lonnet::restore('_discussion');
  756:     my ($temp)=keys %record;
  757:     unless ($temp=~/^error\:/) {
  758:        my %newrecord=();
  759:        $newrecord{'resource'}=$symb;
  760:        $newrecord{'subnumber'}=$record{'subnumber'}+1;
  761:        $status.='<br />'.&mt('Registering').': '.
  762:                &Apache::lonnet::cstore(\%newrecord,'_discussion');
  763:     }
  764:     } else {
  765: 	$status.='Failed.';
  766:     }
  767:     return $status.'<br />';   
  768: }
  769: 
  770: # ----------------------------------------------------------- Preview function
  771: 
  772: sub show_preview {
  773:     my $r=shift;
  774:     my $message=&clear_out_html($ENV{'form.comment'});
  775:     $message=~s/\n/\<br \/\>/g;
  776:     $message=&Apache::lontexconvert::msgtexconverted($message);
  777:     my $subject=&clear_out_html($ENV{'form.subject'});
  778:     $subject=~s/\n/\<br \/\>/g;
  779:     $subject=&Apache::lontexconvert::msgtexconverted($subject);
  780:     $r->print('<table border="2"><tr><td>'.
  781:        '<b>Subject:</b> '.$subject.'<br /><br />'.
  782:        $message.'</td></tr></table>');
  783: }
  784: 
  785: sub generate_preview_button {
  786:     my $pre=&mt("Show Preview");
  787:     return(<<ENDPREVIEW);
  788: <form name="preview" action="/adm/feedback?preview=1" method="post" target="preview">
  789: <input type="hidden" name="subject">
  790: <input type="hidden" name="comment" />
  791: <input type="button" value="$pre"
  792: onClick="this.form.comment.value=document.mailform.comment.value;this.form.subject.value=document.mailform.subject.value;this.form.submit();" />
  793: </form>
  794: ENDPREVIEW
  795: }
  796: 
  797: sub handler {
  798:   my $r = shift;
  799:   if ($r->header_only) {
  800:      &Apache::loncommon::content_type($r,'text/html');
  801:      $r->send_http_header;
  802:      return OK;
  803:   }
  804: 
  805: # --------------------------- Get query string for limited number of parameters
  806: 
  807:    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
  808:          ['hide','unhide','deldisc','postdata','preview','replydisc','threadedon','threadedoff','onlyunread','allposts','previous']);
  809: 
  810:   if (($ENV{'form.allposts'}) || ($ENV{'form.onlyunread'})) {
  811: # ----------------------------------------------------------------- Modify display setting for this discussion 
  812:       &Apache::loncommon::content_type($r,'text/html');
  813:       $r->send_http_header;
  814:       my $symb=$ENV{'form.allposts'}?$ENV{'form.allposts'}:$ENV{'form.onlyunread'};
  815:       my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
  816:       my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
  817:                           $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  818:                           $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
  819:       my %readinghash = ();
  820:                                                                                  
  821:       if ($contrib{'version'}) {
  822:           if ($ENV{'form.allposts'}) {
  823:               $readinghash{$symb.'_showonlyunread'} = 0;
  824:           } elsif ($ENV{'form.onlyunread'}) {
  825:               $readinghash{$symb.'_showonlyunread'} = 1;
  826:           }
  827:           &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%readinghash,$ENV{'user.domain'},$ENV{'user.name'});
  828:       }
  829:       &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed reading status').'<br />','0','0','',$ENV{'form.previous'});
  830:       return OK;
  831:   } elsif (($ENV{'form.hide'}) || ($ENV{'form.unhide'})) {
  832: # ----------------------------------------------------------------- Hide/unhide
  833:     &Apache::loncommon::content_type($r,'text/html');
  834:     $r->send_http_header;
  835: 
  836:     my $entry=$ENV{'form.hide'}?$ENV{'form.hide'}:$ENV{'form.unhide'};
  837: 
  838:     my ($symb,$idx)=split(/\:\:\:/,$entry);
  839:     my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
  840: 
  841:     my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
  842:                      $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  843: 		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
  844: 
  845:         
  846:     my $currenthidden=$contrib{'hidden'};
  847:     
  848:     if ($ENV{'form.hide'}) {
  849: 	$currenthidden.='.'.$idx.'.';
  850:     } else {
  851:         $currenthidden=~s/\.$idx\.//g;
  852:     }
  853:     my %newhash=('hidden' => $currenthidden);
  854: 
  855:     &Apache::lonnet::store(\%newhash,$symb,$ENV{'request.course.id'},
  856:                      $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  857: 		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
  858: 
  859:     &redirect_back($r,&Apache::lonnet::clutter($url),
  860:        &mt('Changed discussion status').'<br />','0','0','',$ENV{'form.previous'});
  861:   } elsif (($ENV{'form.threadedon'}) || ($ENV{'form.threadedoff'})) {
  862:       &Apache::loncommon::content_type($r,'text/html');
  863:       $r->send_http_header;
  864:       if ($ENV{'form.threadedon'}) {
  865: 	  &Apache::lonnet::put('environment',{'threadeddiscussion' => 'on'});
  866: 	  &Apache::lonnet::appenv('environment.threadeddiscussion' => 'on');
  867:       } else {
  868:  	  &Apache::lonnet::del('environment',['threadeddiscussion']);
  869: 	  &Apache::lonnet::delenv('environment\.threadeddiscussion');
  870:       }
  871:       my $symb=$ENV{'form.threadedon'}?$ENV{'form.threadedon'}:$ENV{'form.threadedoff'};
  872:       my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
  873:       &redirect_back($r,&Apache::lonnet::clutter($url),
  874: 		     &mt('Changed discussion view mode').'<br />','0','0','',$ENV{'form.previous'});
  875:   } elsif ($ENV{'form.deldisc'}) {
  876: # --------------------------------------------------------------- Hide for good
  877:     &Apache::loncommon::content_type($r,'text/html');
  878:     $r->send_http_header;
  879: 
  880:     my $entry=$ENV{'form.deldisc'};
  881: 
  882:     my ($symb,$idx)=split(/\:\:\:/,$entry);
  883:     my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
  884: 
  885:     my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
  886:                      $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  887: 		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
  888: 
  889:         
  890:     my $currentdeleted=$contrib{'deleted'};
  891:     
  892:     $currentdeleted.='.'.$idx.'.';
  893: 
  894:     my %newhash=('deleted' => $currentdeleted);
  895: 
  896:     &Apache::lonnet::store(\%newhash,$symb,$ENV{'request.course.id'},
  897:                      $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  898: 		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
  899: 
  900:     &redirect_back($r,&Apache::lonnet::clutter($url),
  901:        &mt('Changed discussion status').'<br />','0','0','',$ENV{'form.previous'});
  902:   } elsif ($ENV{'form.preview'}) {
  903: # -------------------------------------------------------- User wants a preview
  904:       $r->content_type('text/html');
  905:       $r->send_http_header;
  906:       &show_preview($r);
  907:   } else {
  908: # ------------------------------------------------------------- Normal feedback
  909:   my $feedurl=$ENV{'form.postdata'};
  910:   $feedurl=~s/^http\:\/\///;
  911:   $feedurl=~s/^$ENV{'SERVER_NAME'}//;
  912:   $feedurl=~s/^$ENV{'HTTP_HOST'}//;
  913:   $feedurl=~s/\?.+$//;
  914: 
  915:   my $symb;
  916:   if ($ENV{'form.replydisc'}) {
  917:       $symb=(split(/\:\:\:/,$ENV{'form.replydisc'}))[0];
  918:       my ($map,$id,$url)=&Apache::lonnet::decode_symb($symb);
  919:       $feedurl=&Apache::lonnet::clutter($url);
  920:   } else {
  921:       $symb=&Apache::lonnet::symbread($feedurl);
  922:   }
  923:   unless ($symb) {
  924:       $symb=$ENV{'form.symb'};
  925:       if ($symb) {
  926: 	  my ($map,$id,$url)=&Apache::lonnet::decode_symb($symb);
  927:           $feedurl=&Apache::lonnet::clutter($url);
  928:       }
  929:   }
  930:   my $goahead=1;
  931:   if ($feedurl=~/\.(problem|exam|quiz|assess|survey|form)$/) {
  932:       unless ($symb) { $goahead=0; }
  933:   }
  934:   # backward compatibility (bulltin boards used to be 'wrapped')
  935:   if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) {
  936:       $feedurl=~s|^/adm/wrapper||;
  937:   }
  938:   if ($goahead) {
  939: # Go ahead with feedback, no ambiguous reference
  940:     &Apache::loncommon::content_type($r,'text/html');
  941:     $r->send_http_header;
  942:   
  943:     if (
  944:       (
  945:        ($feedurl=~m:^/res:) && ($feedurl!~m:^/res/adm:)
  946:       ) 
  947:       || 
  948:       ($ENV{'request.course.id'} && ($feedurl!~m:^/adm:))
  949:       ||
  950:       ($ENV{'request.course.id'} && ($symb=~/^bulletin\_\_\_/))
  951:      ) {
  952: # --------------------------------------------------- Print login screen header
  953:     unless ($ENV{'form.sendit'}) {
  954:       my $options=&screen_header($feedurl);
  955:       if ($options) {
  956: 	&mail_screen($r,$feedurl,$options);
  957:       } else {
  958: 	&fail_redirect($r,$feedurl);
  959:       }
  960:     } else {
  961:       
  962: # Get previous user input
  963:       my $prevattempts=&Apache::loncommon::get_previous_attempt(
  964:             $symb,$ENV{'user.name'},$ENV{'user.domain'},
  965:             $ENV{'request.course.id'});
  966: 
  967: # Get output from resource
  968:       my $usersaw=&resource_output($feedurl);
  969: 
  970: # Get resource answer (need to allow student to view grades for this to work)
  971:       &Apache::lonnet::appenv(('allowed.vgr'=>'F'));
  972:       my $useranswer=&Apache::loncommon::get_student_answers(
  973:                        $symb,$ENV{'user.name'},$ENV{'user.domain'},
  974: 		       $ENV{'request.course.id'});
  975:       &Apache::lonnet::delenv('allowed.vgr');
  976: # Get attachments, if any, and not too large
  977:       my $attachmenturl='';
  978:       if ($ENV{'form.attachment.filename'}) {
  979: 	  unless (length($ENV{'form.attachment'})>131072) {
  980: 	      $attachmenturl=&Apache::lonnet::userfileupload('attachment',undef,'feedback');
  981: 	  }
  982:       }
  983: # Filter HTML out of message (could be nasty)
  984:       my $message=&clear_out_html($ENV{'form.comment'});
  985: 
  986: # Assemble email
  987:       my ($email,$citations)=&assemble_email($feedurl,$message,$prevattempts,
  988:           $usersaw,$useranswer);
  989:  
  990: # Who gets this?
  991:       my ($typestyle,%to) = &decide_receiver($feedurl);
  992: 
  993: # Actually send mail
  994:       my ($status,$numsent)=&send_msg($feedurl,$email,$citations,
  995:           $attachmenturl,%to);
  996: 
  997: # Discussion? Store that.
  998: 
  999:       my $numpost=0;
 1000:       if ($ENV{'form.discuss'}) {
 1001:           my $subject = &clear_out_html($ENV{'form.subject'});
 1002: 	  $typestyle.=&adddiscuss($symb,$message,0,$attachmenturl,$subject);
 1003: 	  $numpost++;
 1004:       }
 1005: 
 1006:       if ($ENV{'form.anondiscuss'}) {
 1007:           my $subject = &clear_out_html($ENV{'form.subject'});
 1008: 	  $typestyle.=&adddiscuss($symb,$message,1,$attachmenturl,$subject);
 1009: 	  $numpost++;
 1010:       }
 1011: 
 1012: 
 1013: # Receipt screen and redirect back to where came from
 1014:       &redirect_back($r,$feedurl,$typestyle,$numsent,$numpost,$status,$ENV{'form.previous'});
 1015: 
 1016:     }
 1017:    } else {
 1018: # Unable to give feedback
 1019:     &no_redirect_back($r,$feedurl);
 1020:    }
 1021:   } else {
 1022: # Ambiguous Problem Resource
 1023:       if ( &Apache::lonnet::mod_perl_version() == 2 ) {
 1024: 	  &Apache::lonnet::cleanenv();
 1025:       }
 1026:       $r->internal_redirect('/adm/ambiguous');
 1027:   }
 1028: }
 1029:   return OK;
 1030: } 
 1031: 
 1032: 1;
 1033: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>