File:  [LON-CAPA] / loncom / interface / lonfeedback.pm
Revision 1.81: download - view: text, annotated - select for diffs
Wed May 5 23:04:57 2004 UTC (20 years ago) by raeburn
Branches: MAIN
CVS tags: HEAD
Reverting lonbulletin to v 1.120. Time of the previous visit passed in a query string retrieved in lonfeedback instead, so labelling of posts as "NEW" until user leaves board/resource works for both boards and resources.

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

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