File:  [LON-CAPA] / loncom / interface / lonfeedback.pm
Revision 1.83: download - view: text, annotated - select for diffs
Tue May 11 10:42:41 2004 UTC (20 years, 1 month ago) by raeburn
Branches: MAIN
CVS tags: HEAD
Set a default display setting for discussions (show only unread/ show all). Default will be overridden by a discussion-specific setting.

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

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