Annotation of loncom/interface/lonfeedback.pm, revision 1.311
1.1 www 1: # The LearningOnline Network
2: # Feedback
3: #
1.311 ! www 4: # $Id: lonfeedback.pm,v 1.310 2011/12/12 00:13:43 www Exp $
1.19 albertel 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: #
1.77 www 28: ###
1.7 albertel 29:
1.1 www 30: package Apache::lonfeedback;
31:
32: use strict;
33: use Apache::Constants qw(:common);
1.3 www 34: use Apache::lonmsg();
1.9 albertel 35: use Apache::loncommon();
1.33 www 36: use Apache::lontexconvert();
1.86 www 37: use Apache::lonlocal; # must not have ()
1.157 albertel 38: use Apache::lonnet;
1.86 www 39: use Apache::lonhtmlcommon();
1.128 raeburn 40: use Apache::lonnavmaps;
1.130 albertel 41: use Apache::lonenc();
1.175 www 42: use Apache::lonrss();
1.112 raeburn 43: use HTML::LCParser();
1.283 faziophi 44: #use HTML::Tidy::libXML;
1.106 www 45: use Apache::lonspeller();
1.208 raeburn 46: use Apache::longroup;
1.116 raeburn 47: use Cwd;
1.204 www 48: use LONCAPA;
1.54 www 49:
1.92 albertel 50: sub discussion_open {
1.122 raeburn 51: my ($status,$symb)=@_;
1.294 www 52: # Advanced roles can always discuss
1.249 albertel 53: if ($env{'request.role.adv'}) { return 1; }
1.294 www 54: # Get discussion closing date
55: my $close=&Apache::lonnet::EXT('resource.0.discussend',$symb);
56: # If it is defined and in the future, the instructor wants this discussion to be open
57: if (defined($close) && $close ne '' && $close > time) {
58: return 1;
59: }
60: # It was not explicitly open, check if the problem is available.
61: # If the problem is not available, close the discussion
1.92 albertel 62: if (defined($status) &&
63: !($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER'
1.77 www 64: || $status eq 'OPEN')) {
1.92 albertel 65: return 0;
1.75 albertel 66: }
1.294 www 67: # The problem is available, but check if the instructor explictly closed discussion
1.89 albertel 68: if (defined($close) && $close ne '' && $close < time) {
1.92 albertel 69: return 0;
1.89 albertel 70: }
1.92 albertel 71: return 1;
72: }
73:
74: sub discussion_visible {
75: my ($status)=@_;
76: if (not &discussion_open($status)) {
77: my $hidden=&Apache::lonnet::EXT('resource.0.discusshide');
78: if (lc($hidden) eq 'yes' or $hidden eq '' or !defined($hidden)) {
1.157 albertel 79: if (!$env{'request.role.adv'}) { return 0; }
1.92 albertel 80: }
81: }
82: return 1;
1.90 albertel 83: }
1.84 raeburn 84:
1.90 albertel 85: sub list_discussion {
1.208 raeburn 86: my ($mode,$status,$ressymb,$imsextras,$group)=@_;
1.232 raeburn 87: unless ($ressymb) { $ressymb=&Apache::lonnet::symbread(); }
88: unless ($ressymb) { return ''; }
89: $ressymb=&wrap_symb($ressymb);
1.157 albertel 90: my $outputtarget=$env{'form.grade_target'};
91: if (defined($env{'form.export'})) {
92: if($env{'form.export'}) {
1.116 raeburn 93: $outputtarget = 'export';
94: }
1.140 raeburn 95: }
1.147 raeburn 96: if (defined($imsextras)) {
97: if ($$imsextras{'caller'} eq 'imsexport') {
98: $outputtarget = 'export';
99: }
100: }
1.232 raeburn 101: if (not &discussion_visible($status)) {
102: if ($mode ne 'board') {
1.233 raeburn 103: &Apache::lonenc::check_encrypt(\$ressymb);
1.274 kalberla 104: return '<br /><div class="LC_feedback_link">'.&send_message_link($ressymb)."</div>";
1.232 raeburn 105: }
106: }
1.208 raeburn 107: if ($group ne '' && $mode eq 'board') {
108: if (&check_group_priv($group,'vgb') ne 'ok') {
109: return '';
110: }
111: }
1.219 raeburn 112:
1.235 raeburn 113: my ($blocked,$blocktext) =
114: &Apache::loncommon::blocking_status('boards');
1.223 raeburn 115: if ($blocked) {
1.275 kalberla 116: $blocktext = '<br /><div class="LC_feedback_link"><span class="LC_feedback_link">'.$blocktext."</span>";
1.234 raeburn 117: &Apache::lonenc::check_encrypt(\$ressymb);
1.232 raeburn 118: if ($mode ne 'board') {
1.275 kalberla 119: $blocktext.=&send_message_link($ressymb).'</div>';
120: }else{
121: $blocktext.="</div>";
1.232 raeburn 122: }
1.234 raeburn 123: return $blocktext;
1.223 raeburn 124: }
125:
1.270 www 126: my @bgcols = ("LC_disc_old_item","LC_disc_new_item");
1.57 www 127: my $discussiononly=0;
128: if ($mode eq 'board') { $discussiononly=1; }
1.157 albertel 129: unless ($env{'request.course.id'}) { return ''; }
130: my $crs='/'.$env{'request.course.id'};
131: my $cid=$env{'request.course.id'};
132: if ($env{'request.course.sec'}) {
133: $crs.='_'.$env{'request.course.sec'};
1.143 raeburn 134: }
1.55 www 135: $crs=~s/\_/\//g;
1.133 albertel 136: my $encsymb=&Apache::lonenc::check_encrypt($ressymb);
137: my $viewgrades=(&Apache::lonnet::allowed('vgr',$crs)
1.305 www 138: && ($ressymb=~/$LONCAPA::assess_re/));
1.133 albertel 139:
1.100 raeburn 140: my %usernamesort = ();
141: my %namesort =();
142: my %subjectsort = ();
1.133 albertel 143:
1.80 raeburn 144: # Get discussion display settings for this discussion
145: my $lastkey = $ressymb.'_lastread';
146: my $showkey = $ressymb.'_showonlyunread';
1.111 raeburn 147: my $markkey = $ressymb.'_showonlyunmark',
1.80 raeburn 148: my $visitkey = $ressymb.'_visit';
1.84 raeburn 149: my $ondispkey = $ressymb.'_markondisp';
1.101 raeburn 150: my $userpickkey = $ressymb.'_userpick';
1.111 raeburn 151: my $toggkey = $ressymb.'_readtoggle';
152: my $readkey = $ressymb.'_read';
1.139 albertel 153: $ressymb=$encsymb;
1.169 albertel 154: my %dischash = &Apache::lonnet::get('nohist_'.$cid.'_discuss',[$lastkey,$showkey,$markkey,$visitkey,$ondispkey,$userpickkey,$toggkey,$readkey],$env{'user.domain'},$env{'user.name'});
1.84 raeburn 155: my %discinfo = ();
1.80 raeburn 156: my $showonlyunread = 0;
1.111 raeburn 157: my $showunmark = 0;
1.84 raeburn 158: my $markondisp = 0;
1.79 raeburn 159: my $prevread = 0;
1.81 raeburn 160: my $previous = 0;
1.80 raeburn 161: my $visit = 0;
162: my $newpostsflag = 0;
1.221 raeburn 163: my @posters = split(/\&/,$dischash{$userpickkey});
1.80 raeburn 164:
1.81 raeburn 165: # Retain identification of "NEW" posts identified in last display, if continuing 'previous' browsing of posts.
1.208 raeburn 166: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['previous','sortposts','rolefilter','statusfilter','sectionpick','grouppick','totposters']);
1.157 albertel 167: my $sortposts = $env{'form.sortposts'};
168: my $statusfilter = $env{'form.statusfilter'};
1.209 albertel 169: my @sectionpick = split(/,/,$env{'form.sectionpick'});
170: my @grouppick = split(/,/,$env{'form.grouppick'});
171: my @rolefilter = split(/,/,$env{'form.rolefilter'});
1.208 raeburn 172:
1.157 albertel 173: my $totposters = $env{'form.totposters'};
174: $previous = $env{'form.previous'};
1.80 raeburn 175: if ($previous > 0) {
176: $prevread = $previous;
177: } elsif (defined($dischash{$lastkey})) {
1.84 raeburn 178: unless ($dischash{$lastkey} eq '') {
179: $prevread = $dischash{$lastkey};
180: }
1.80 raeburn 181: }
1.79 raeburn 182:
1.208 raeburn 183: my $cdom = $env{'course.'.$cid.'.domain'};
184: my $cnum = $env{'course.'.$cid.'.num'};
1.278 raeburn 185: my $crstype = &Apache::loncommon::course_type();
1.208 raeburn 186:
1.108 raeburn 187: # Get information about students and non-students in course for filtering display of posts
1.101 raeburn 188: my %roleshash = ();
189: my %roleinfo = ();
1.208 raeburn 190: my ($classgroups,$studentgroups);
1.157 albertel 191: if ($env{'form.rolefilter'}) {
1.208 raeburn 192: %roleshash = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum);
1.221 raeburn 193: foreach my $rolekey (keys(%roleshash)) {
194: my ($role,$uname,$udom,$sec) = split(/:/,$rolekey);
1.144 raeburn 195: if ($role =~ /^cr/) {
196: $role = 'cr';
197: }
1.221 raeburn 198: my ($end,$start) = split(/:/,$roleshash{$rolekey});
1.101 raeburn 199: my $now = time;
200: my $status = 'Active';
201: if (($now < $start) || ($end > 0 && $now > $end)) {
202: $status = 'Expired';
203: }
1.144 raeburn 204: if ($uname && $udom) {
1.221 raeburn 205: push(@{$roleinfo{$uname.':'.$udom}}, $role.':'.$sec.':'.$status);
1.144 raeburn 206: }
1.101 raeburn 207: }
1.208 raeburn 208: my ($classlist,$keylist) =
209: &Apache::loncoursedata::get_classlist($cdom,$cnum);
1.101 raeburn 210: my $sec_index = &Apache::loncoursedata::CL_SECTION();
211: my $status_index = &Apache::loncoursedata::CL_STATUS();
212: while (my ($student,$data) = each %$classlist) {
213: my ($section,$status) = ($data->[$sec_index],
214: $data->[$status_index]);
1.221 raeburn 215: push(@{$roleinfo{$student}}, 'st:'.$section.':'.$status);
1.101 raeburn 216: }
1.208 raeburn 217: ($classgroups,$studentgroups) =
1.214 albertel 218: &Apache::loncoursedata::get_group_memberships($classlist,$keylist,
219: $cdom,$cnum);
1.101 raeburn 220: }
221:
1.84 raeburn 222: # Get discussion display default settings for user
1.157 albertel 223: if ($env{'environment.discdisplay'} eq 'unread') {
1.83 raeburn 224: $showonlyunread = 1;
225: }
1.157 albertel 226: if ($env{'environment.discmarkread'} eq 'ondisp') {
1.84 raeburn 227: $markondisp = 1;
228: }
229:
230: # Override user's default if user specified display setting for this discussion
231: if (defined($dischash{$ondispkey})) {
1.123 raeburn 232: unless ($dischash{$ondispkey} eq '') {
233: $markondisp = $dischash{$ondispkey};
234: }
1.84 raeburn 235: }
236: if ($markondisp) {
237: $discinfo{$lastkey} = time;
238: }
1.83 raeburn 239:
1.80 raeburn 240: if (defined($dischash{$showkey})) {
1.123 raeburn 241: unless ($dischash{$showkey} eq '') {
242: $showonlyunread = $dischash{$showkey};
243: }
1.80 raeburn 244: }
245:
1.111 raeburn 246: if (defined($dischash{$markkey})) {
1.123 raeburn 247: unless ($dischash{$markkey} eq '') {
248: $showunmark = $dischash{$markkey};
249: }
1.111 raeburn 250: }
251:
1.80 raeburn 252: if (defined($dischash{$visitkey})) {
1.123 raeburn 253: unless ($dischash{$visitkey} eq '') {
254: $visit = $dischash{$visitkey};
255: }
1.78 raeburn 256: }
1.80 raeburn 257: $visit ++;
1.78 raeburn 258:
1.208 raeburn 259: my $seeid;
260: if (($group ne '') && ($mode eq 'board') &&
261: ($ressymb =~ m|^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$|)) {
262: if (&check_group_priv($group,'dgp') eq 'ok') {
263: $seeid = 1;
264: }
265: } else {
266: $seeid=&Apache::lonnet::allowed('rin',$crs);
267: }
1.68 www 268: my @discussionitems=();
1.101 raeburn 269: my %shown = ();
270: my @posteridentity=();
1.116 raeburn 271:
272: my $current=0;
1.67 www 273: my $visible=0;
1.68 www 274: my @depth=();
1.116 raeburn 275: my @replies = ();
1.68 www 276: my %alldiscussion=();
1.116 raeburn 277: my %imsitems=();
278: my %imsfiles=();
1.80 raeburn 279: my %notshown = ();
1.84 raeburn 280: my %newitem = ();
1.68 www 281: my $maxdepth=0;
1.173 www 282: my %anonhash=();
283: my $anoncnt=0;
1.111 raeburn 284:
1.79 raeburn 285: my $now = time;
1.80 raeburn 286: $discinfo{$visitkey} = $visit;
287:
1.169 albertel 288: &Apache::lonnet::put('nohist_'.$cid.'_discuss',\%discinfo,$env{'user.domain'},$env{'user.name'});
1.306 www 289: &build_posting_display(\%usernamesort,\%subjectsort,\%namesort,\%notshown,\%newitem,\%dischash,\%shown,\%alldiscussion,\%imsitems,\%imsfiles,\%roleinfo,\@discussionitems,\@replies,\@depth,\@posters,\$maxdepth,\$visible,\$newpostsflag,\$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$encsymb,$readkey,$showunmark,$showonlyunread,$totposters,\@rolefilter,\@sectionpick,\@grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,\%anonhash,$anoncnt,$group);
1.80 raeburn 290:
1.67 www 291: my $discussion='';
1.116 raeburn 292: my $manifestfile;
293: my $manifestok=0;
294: my $tempexport;
295: my $imsresources;
296: my $copyresult;
1.84 raeburn 297:
298: my $function = &Apache::loncommon::get_users_function();
299: my $color = &Apache::loncommon::designparm($function.'.tabbg',
1.157 albertel 300: $env{'user.domain'});
1.84 raeburn 301: my %lt = &Apache::lonlocal::texthash(
1.97 raeburn 302: 'cuse' => 'Current discussion settings',
1.84 raeburn 303: 'allposts' => 'All posts',
304: 'unread' => 'New posts only',
1.111 raeburn 305: 'unmark' => 'Unread only',
1.84 raeburn 306: 'ondisp' => 'Once displayed',
1.111 raeburn 307: 'onmark' => 'Once marked not NEW',
308: 'toggoff' => 'Off',
309: 'toggon' => 'On',
1.84 raeburn 310: 'disa' => 'Posts to be displayed',
311: 'npce' => 'Posts cease to be marked "NEW"',
1.111 raeburn 312: 'epcb' => 'Each post can be toggled read/unread',
1.97 raeburn 313: 'chgt' => 'Change',
314: 'disp' => 'Display',
315: 'nolo' => 'Not new',
1.111 raeburn 316: 'togg' => 'Toggle read/unread',
1.220 raeburn 317: 'aner' => 'An error occurred opening the manifest file.',
318: 'difo' => 'Discussion for',
319: 'aerr' => 'An error occurred opening the export file for posting',
320: 'aysu' => 'Are you sure you want to delete this post?',
321: 'dpwn' => 'Deleted posts will no longer be visible to you and other students',
322: 'bwco' => 'but will continue to be visible to your instructor',
323: 'depo' => 'Deleted posts will no longer be visible to you or anyone else.',
1.295 www 324: 'discussions' => 'DISCUSSIONS'
1.84 raeburn 325: );
326:
327: my $currdisp = $lt{'allposts'};
328: my $currmark = $lt{'onmark'};
1.111 raeburn 329: my $currtogg = $lt{'toggoff'};
1.84 raeburn 330: my $dispchange = $lt{'unread'};
331: my $markchange = $lt{'ondisp'};
1.111 raeburn 332: my $toggchange = $lt{'toggon'};
1.97 raeburn 333: my $chglink = '/adm/feedback?modifydisp='.$ressymb;
1.111 raeburn 334: my $displinkA = 'onlyunread';
335: my $displinkB = 'onlyunmark';
1.97 raeburn 336: my $marklink = 'markondisp';
1.111 raeburn 337: my $togglink = 'toggon';
1.84 raeburn 338:
339: if ($markondisp) {
340: $currmark = $lt{'ondisp'};
341: $markchange = $lt{'onmark'};
1.97 raeburn 342: $marklink = 'markonread';
1.84 raeburn 343: }
344:
345: if ($showonlyunread) {
346: $currdisp = $lt{'unread'};
347: $dispchange = $lt{'allposts'};
1.111 raeburn 348: $displinkA = 'allposts';
1.84 raeburn 349: }
1.111 raeburn 350:
351: if ($showunmark) {
352: $currdisp = $lt{'unmark'};
353: $dispchange = $lt{'unmark'};
354: $displinkA='allposts';
355: $displinkB='onlyunread';
356: $showonlyunread = 0;
357: }
358:
359: if ($dischash{$toggkey}) {
360: $currtogg = $lt{'toggon'};
361: $toggchange = $lt{'toggoff'};
362: $togglink = 'toggoff';
363: }
1.97 raeburn 364:
1.282 wenzelju 365: $chglink .= '&changes='.$displinkA.'_'.$displinkB.'_'.$marklink.'_'.$togglink;
1.84 raeburn 366:
367: if ($newpostsflag) {
1.282 wenzelju 368: $chglink .= '&previous='.$prevread;
1.84 raeburn 369: }
1.211 albertel 370: $chglink.=&group_args($group);
1.84 raeburn 371:
1.67 www 372: if ($visible) {
1.80 raeburn 373: # Print the discusssion
1.116 raeburn 374: if ($outputtarget eq 'tex') {
1.156 albertel 375: $discussion.='<tex>{\tiny \vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}'.
1.295 www 376: '\textbf{'.$lt{'discussions'}.'}\makebox[2 cm][b]{\hrulefill}\vskip 0 mm'.
1.116 raeburn 377: '\noindent\textbf{'.$lt{'disa'}.'}: \textit{'.$currdisp.'}\vskip 0 mm'.
1.156 albertel 378: '\noindent\textbf{'.$lt{'npce'}.'}: \textit{'.$currmark.'}}</tex>';
1.116 raeburn 379: } elsif ($outputtarget eq 'export') {
380: # Create temporary directory if this is an export
381: my $now = time;
1.147 raeburn 382: if ((defined($imsextras)) && ($$imsextras{'caller'} eq 'imsexport')) {
383: $tempexport = $$imsextras{'tempexport'};
384: if (!-e $tempexport) {
385: mkdir($tempexport,0700);
386: }
387: $tempexport .= '/'.$$imsextras{'count'};
388: if (!-e $tempexport) {
389: mkdir($tempexport,0700);
390: }
391: } else {
392: $tempexport = $Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/ims_exports';
393: if (!-e $tempexport) {
394: mkdir($tempexport,0700);
395: }
396: $tempexport .= '/'.$now;
397: if (!-e $tempexport) {
398: mkdir($tempexport,0700);
399: }
1.157 albertel 400: $tempexport .= '/'.$env{'user.domain'}.'_'.$env{'user.name'};
1.116 raeburn 401: }
402: if (!-e $tempexport) {
403: mkdir($tempexport,0700);
404: }
405: # open manifest file
406: my $manifest = '/imsmanifest.xml';
407: my $manifestfilename = $tempexport.$manifest;
408: if ($manifestfile = Apache::File->new('>'.$manifestfilename)) {
409: $manifestok=1;
1.284 raeburn 410: print $manifestfile qq|<?xml version="1.0" encoding="UTF-8"?>
1.116 raeburn 411: <manifest xmlns="http://www.imsglobal.org/xsd/imscp_v1p1" xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2"
412: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
413: identifier="MANIFEST-$ressymb" xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1
414: imscp_v1p1.xsd http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">
415: <organizations default="$ressymb">
416: <organization identifier="$ressymb">
1.220 raeburn 417: <title>$lt{'difo'} $ressymb</title>\n|;
1.116 raeburn 418: } else {
1.220 raeburn 419: $discussion .= $lt{'aner'}.'<br />';
1.116 raeburn 420: }
421: } else {
1.97 raeburn 422: my $colspan=$maxdepth+1;
1.282 wenzelju 423: $discussion.= &Apache::lonhtmlcommon::scripttag(qq|
1.219 raeburn 424: function verifydelete (caller,symb,idx,newflag,previous,groupparm) {
1.102 raeburn 425: var symbparm = symb+':::'+idx
426: var prevparm = ""
427: if (newflag == 1) {
1.282 wenzelju 428: prevparm = "&previous="+previous
1.102 raeburn 429: }
1.219 raeburn 430: if (caller == 'studentdelete') {
1.220 raeburn 431: if (confirm("$lt{'aysu'}\\n$lt{'dpwn'},\\n$lt{'bwco'}")) {
1.219 raeburn 432: document.location.href = "/adm/feedback?hide="+symbparm+prevparm+groupparm
433: }
434: } else {
435: if (caller == 'seeiddelete') {
1.220 raeburn 436: if (confirm("$lt{'aysu'}\\n$lt{'depo'}")) {
1.219 raeburn 437: document.location.href = "/adm/feedback?deldisc="+symbparm+prevparm+groupparm
438: }
439: }
440: }
1.102 raeburn 441: }
1.282 wenzelju 442: |);
1.270 www 443: $discussion.='<form name="readchoices" method="post" action="/adm/feedback?chgreads='.$ressymb.'" >'.
444: "\n".'<table class="LC_discussion">';
1.222 raeburn 445: $discussion .= &action_links_bar($colspan,$ressymb,$visible,
446: $newpostsflag,$group,
447: $prevread,$markondisp);
448: my $escsymb=&escape($ressymb);
1.220 raeburn 449: my $numhidden = keys(%notshown);
1.116 raeburn 450: if ($numhidden > 0) {
451: my $colspan = $maxdepth+1;
452: $discussion.="\n".'<tr><td bgcolor="#CCCCCC" colspan="'.$colspan.'">'.
1.173 www 453: '<a href="/adm/feedback?allposts=1&symb='.$escsymb;
1.116 raeburn 454: if ($newpostsflag) {
1.282 wenzelju 455: $discussion .= '&previous='.$prevread;
1.116 raeburn 456: }
1.211 albertel 457: $discussion .= &group_args($group);
1.116 raeburn 458: $discussion .= '">'.&mt('Show all posts').'</a> '.&mt('to display').' '.
1.111 raeburn 459: $numhidden.' ';
1.116 raeburn 460: if ($showunmark) {
461: $discussion .= &mt('posts previously marked read');
462: } else {
463: $discussion .= &mt('previously viewed posts');
464: }
465: $discussion .= '<br/></td></tr>';
1.111 raeburn 466: }
1.80 raeburn 467: }
1.100 raeburn 468:
469: # Choose sort mechanism
470: my @showposts = ();
471: if ($sortposts eq 'descdate') {
1.221 raeburn 472: @showposts = (sort { $b <=> $a } keys(%alldiscussion));
1.100 raeburn 473: } elsif ($sortposts eq 'thread') {
1.221 raeburn 474: @showposts = (sort { $a <=> $b } keys(%alldiscussion));
1.100 raeburn 475: } elsif ($sortposts eq 'subject') {
1.221 raeburn 476: foreach my $key (sort(keys(%subjectsort))) {
477: push(@showposts, @{$subjectsort{$key}});
1.100 raeburn 478: }
479: } elsif ($sortposts eq 'username') {
1.221 raeburn 480: foreach my $domain (sort(keys(%usernamesort))) {
481: foreach my $key (sort(keys(%{$usernamesort{$domain}}))) {
482: push(@showposts, @{$usernamesort{$domain}{$key}});
1.100 raeburn 483: }
484: }
485: } elsif ($sortposts eq 'lastfirst') {
1.221 raeburn 486: foreach my $last (sort(keys(%namesort))) {
487: foreach my $key (sort(keys(%{$namesort{$last}}))) {
488: push(@showposts, @{$namesort{$last}{$key}});
1.100 raeburn 489: }
490: }
491: } else {
1.221 raeburn 492: @showposts = (sort { $a <=> $b } keys(%alldiscussion));
1.100 raeburn 493: }
1.116 raeburn 494: my $currdepth = 0;
495: my $firstidx = $alldiscussion{$showposts[0]};
1.221 raeburn 496: foreach my $post (@showposts) {
1.157 albertel 497: unless (($sortposts eq 'thread') || (($sortposts eq '') && ($env{'environment.threadeddiscussion'})) || ($outputtarget eq 'export')) {
1.221 raeburn 498: $alldiscussion{$post} = $post;
1.100 raeburn 499: }
1.221 raeburn 500: unless ( ($notshown{$alldiscussion{$post}} eq '1') || ($shown{$alldiscussion{$post}} == 0) ) {
1.117 albertel 501: if ($outputtarget ne 'tex' && $outputtarget ne 'export') {
1.95 sakharuk 502: $discussion.="\n<tr>";
503: }
1.221 raeburn 504: my $thisdepth=$depth[$alldiscussion{$post}];
1.117 albertel 505: if ($outputtarget ne 'tex' && $outputtarget ne 'export') {
1.95 sakharuk 506: for (1..$thisdepth) {
507: $discussion.='<td> </td>';
508: }
509: }
1.80 raeburn 510: my $colspan=$maxdepth-$thisdepth+1;
1.116 raeburn 511: if ($outputtarget eq 'tex') {
1.95 sakharuk 512: #cleanup block
1.221 raeburn 513: $discussionitems[$alldiscussion{$post}]=~s/<table([^>]*)>/<table TeXwidth="90 mm">/;
514: $discussionitems[$alldiscussion{$post}]=~s/<tr([^>]*)><td([^>]*)>/<tr><td TeXwidth="20 mm" align="left">/;
1.95 sakharuk 515: my $threadinsert='';
516: if ($thisdepth > 0) {
517: $threadinsert='<br /><strong>Reply: '.$thisdepth.'</strong>';
518: }
1.221 raeburn 519: $discussionitems[$alldiscussion{$post}]=~s/<\/td><td([^>]*)>/$threadinsert<\/td><td TeXwidth="65 mm" align="left">/;
520: $discussionitems[$alldiscussion{$post}]=~s/(<b>|<\/b>|<\/a>|<a([^>]+)>)//g;
1.114 sakharuk 521:
1.221 raeburn 522: $discussionitems[$alldiscussion{$post}]='<tex>\vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}</tex>'.$discussionitems[$alldiscussion{$post}];
523: $discussion.=$discussionitems[$alldiscussion{$post}];
1.116 raeburn 524: } elsif ($outputtarget eq 'export') {
1.221 raeburn 525: my $postfilename = $alldiscussion{$post}.'-'.$imsitems{$alldiscussion{$post}}{'timestamp'}.'.html';
1.116 raeburn 526: if ($manifestok) {
1.221 raeburn 527: if (($depth[$alldiscussion{$post}] <= $currdepth) && ($alldiscussion{$post} != $firstidx)) {
1.116 raeburn 528: print $manifestfile ' </item>'."\n";
529: }
1.221 raeburn 530: $currdepth = $depth[$alldiscussion{$post}];
1.116 raeburn 531: print $manifestfile "\n".
1.221 raeburn 532: '<item identifier="ITEM-'.$ressymb.'-'.$alldiscussion{$post}.'" isvisible="'.
533: $imsitems{$alldiscussion{$post}}{'isvisible'}.'" identifieref="RES-'.$ressymb.'-'.$alldiscussion{$post}.'">'.
1.284 raeburn 534: '<title>'.$imsitems{$alldiscussion{$post}}{'title'}.'</title></item>';
1.116 raeburn 535: $imsresources .= "\n".
1.221 raeburn 536: '<resource identifier="RES-'.$ressymb.'-'.$alldiscussion{$post}.'" type="webcontent" href="'.$postfilename.'">'."\n".
1.146 raeburn 537: '<file href="'.$postfilename.'">'."\n".
1.284 raeburn 538: $imsfiles{$alldiscussion{$post}}{$imsitems{$alldiscussion{$post}}{'currversion'}}.'</file>'."\n".
1.116 raeburn 539: '</resource>';
540: }
541: my $postingfile;
542: my $postingfilename = $tempexport.'/'.$postfilename;
543: if ($postingfile = Apache::File->new('>'.$postingfilename)) {
544: print $postingfile '<html><head><title>Discussion Post</title></head><body>'.
1.221 raeburn 545: $imsitems{$alldiscussion{$post}}{'title'}.' '.
546: $imsitems{$alldiscussion{$post}}{'sender'}.
547: $imsitems{$alldiscussion{$post}}{'timestamp'}.'<br /><br />'.
548: $imsitems{$alldiscussion{$post}}{'message'}.'<br />'.
549: $imsitems{$alldiscussion{$post}}{'attach'}.'</body></html>'."\n";
1.116 raeburn 550: close($postingfile);
551: } else {
1.221 raeburn 552: $discussion .= $lt{'aerr'}.' '.$alldiscussion{$post}.'<br />';
1.116 raeburn 553: }
1.221 raeburn 554: $copyresult.=&replicate_attachments($imsitems{$alldiscussion{$post}}{'allattachments'},$tempexport);
1.116 raeburn 555: } else {
1.270 www 556: $discussion.='<td class="'.$bgcols[$newitem{$alldiscussion{$post}}].
1.221 raeburn 557: '" colspan="'.$colspan.'">'. $discussionitems[$alldiscussion{$post}].
1.116 raeburn 558: '</td></tr>';
559: }
1.69 www 560: }
1.80 raeburn 561: }
1.116 raeburn 562: unless ($outputtarget eq 'tex' || $outputtarget eq 'export') {
1.97 raeburn 563: my $colspan=$maxdepth+1;
1.111 raeburn 564: $discussion .= <<END;
1.97 raeburn 565: <tr bgcolor="#FFFFFF">
1.270 www 566: <td colspan="$colspan" class="LC_disc_action_links_bar">
567: <table class="LC_disc_action_table">
1.97 raeburn 568: <tr>
569: <td align="left">
570: <table border="0" cellpadding="0" cellspacing="4">
571: <tr>
572: <td>
1.281 bisitz 573: <font size="-1"><b>$lt{'cuse'}</b>:</font></td>
1.97 raeburn 574: <td> </td>
1.111 raeburn 575: <td><font size="-1">
1.97 raeburn 576: END
577: if ($newpostsflag) {
578: $discussion .=
1.111 raeburn 579: '1. '.$lt{'disp'}.' - <i>'.$currdisp.'</i> 2. '.$lt{'nolo'}.' - <i>'.$currmark.'</i>';
580: if ($dischash{$toggkey}) {
581: $discussion .= ' 3. '.$lt{'togg'}.' - <i>'.$currtogg.'</i>';
582: }
1.97 raeburn 583: } else {
1.111 raeburn 584: if ($dischash{$toggkey}) {
585: $discussion .= '1. '.$lt{'disp'}.' - <i>'.$currdisp.'</i> 2. '.$lt{'togg'}.' - <i>'.$currtogg.'</i>';
586: } else {
587: $discussion .=
588: $lt{'disp'}.' - <i>'.$currdisp.'</i>';
589: }
1.97 raeburn 590: }
591: $discussion .= <<END;
1.111 raeburn 592: </font></td>
1.97 raeburn 593: <td> </td>
1.144 raeburn 594: <td align="left">
1.281 bisitz 595: <font size="-1"><b><a href="$chglink">$lt{'chgt'}</a>?</b></font>
1.111 raeburn 596: </td>
1.97 raeburn 597: </tr>
598: </table>
599: </td>
1.111 raeburn 600: END
1.143 raeburn 601: if ($sortposts) {
602: my %sort_types = ();
603: my %role_types = ();
604: my %status_types = ();
1.278 raeburn 605: &sort_filter_names(\%sort_types,\%role_types,\%status_types,$crstype);
1.143 raeburn 606:
607: $discussion .= '<td><font size="-1"><b>'.&mt('Sorted by').'</b>: '.$sort_types{$sortposts}.'<br />';
1.157 albertel 608: if (defined($env{'form.totposters'})) {
1.144 raeburn 609: $discussion .= &mt('Posts by').':';
1.143 raeburn 610: if ($totposters > 0) {
611: foreach my $poster (@posters) {
1.144 raeburn 612: $discussion .= ' '.$poster.',';
1.143 raeburn 613: }
1.144 raeburn 614: $discussion =~ s/,$//;
1.143 raeburn 615: } else {
616: $discussion .= &mt('None selected');
617: }
618: } else {
619: my $filterchoice ='';
620: if (@sectionpick > 0) {
1.157 albertel 621: $filterchoice = '<i>'.&mt('sections').'</i>- '.$env{'form.sectionpick'};
1.143 raeburn 622: $filterchoice .= ' ';
623: }
1.208 raeburn 624: if (@grouppick > 0) {
625: $filterchoice = '<i>'.&mt('groups').'</i>- '.$env{'form.grouppick'};
626: $filterchoice .= ' ';
627: }
1.143 raeburn 628: if (@rolefilter > 0) {
1.144 raeburn 629: $filterchoice .= '<i>'.&mt('roles').'</i>-';
1.221 raeburn 630: foreach my $role (@rolefilter) {
631: $filterchoice .= ' '.$role_types{$role}.',';
1.143 raeburn 632: }
1.144 raeburn 633: $filterchoice =~ s/,$//;
1.259 raeburn 634: $filterchoice .= '<br />'.(' ' x8);
1.143 raeburn 635: }
636: if ($statusfilter) {
637: $filterchoice .= '<i>'.&mt('status').'</i>- '.$status_types{$statusfilter};
638: }
639: if ($filterchoice) {
640: $discussion .= '<b>'.&mt('Filters').'</b>: '.$filterchoice;
641: }
642: $discussion .= '</font></td>';
643: }
644: }
1.111 raeburn 645: if ($dischash{$toggkey}) {
1.247 albertel 646: my $storebutton = &mt('Save read/unread changes');
1.111 raeburn 647: $discussion.='<td align="right">'.
1.269 bisitz 648: '<input type="hidden" name="discsymb" value="'.$ressymb.'" />'."\n".
1.111 raeburn 649: '<input type="button" name="readoptions" value="'.$storebutton.'"'.
1.282 wenzelju 650: ' onclick="this.form.submit();" />'."\n".
1.111 raeburn 651: '</td>';
652: }
653: $discussion .= (<<END);
1.97 raeburn 654: </tr>
655: </table>
656: </td>
657: </tr>
1.222 raeburn 658: END
659: $discussion .= &action_links_bar($colspan,$ressymb,$visible,
660: $newpostsflag,$group,
661: $prevread,$markondisp);
662: $discussion .= "
1.97 raeburn 663: </table>
1.222 raeburn 664: <br /><br /></form>\n";
1.114 sakharuk 665: }
1.116 raeburn 666: if ($outputtarget eq 'export') {
667: if ($manifestok) {
668: while ($currdepth > 0) {
669: print $manifestfile " </item>\n";
670: $currdepth --;
671: }
672: print $manifestfile qq|
673: </organization>
674: </organizations>
675: <resources>
676: $imsresources
677: </resources>
678: </manifest>
679: |;
680: close($manifestfile);
1.147 raeburn 681: if ((defined($imsextras)) && ($$imsextras{'caller'} eq 'imsexport')) {
682: $discussion = $copyresult;
683: } else {
1.116 raeburn 684:
685: #Create zip file in prtspool
686:
1.147 raeburn 687: my $imszipfile = '/prtspool/'.
1.157 albertel 688: $env{'user.name'}.'_'.$env{'user.domain'}.'_'.
1.147 raeburn 689: time.'_'.rand(1000000000).'.zip';
690: my $cwd = &getcwd();
691: my $imszip = '/home/httpd/'.$imszipfile;
692: chdir $tempexport;
693: open(OUTPUT, "zip -r $imszip * 2> /dev/null |");
694: close(OUTPUT);
695: chdir $cwd;
1.220 raeburn 696: $discussion .= &mt('Download the zip file from [_1]Discussion Posting Archive','<a href="'.$imszipfile.'">').'</a><br />';
1.147 raeburn 697: if ($copyresult) {
1.220 raeburn 698: $discussion .= &mt('The following errors occurred during export').' - <br />'.$copyresult;
1.147 raeburn 699: }
1.116 raeburn 700: }
701: } else {
1.220 raeburn 702: $discussion .= '<br />'.&mt('Unfortunately you will not be able to retrieve an archive of the discussion posts at this time, because there was a problem creating a manifest file.').'<br />';
1.116 raeburn 703: }
704: return $discussion;
705: }
1.54 www 706: }
707: if ($discussiononly) {
1.108 raeburn 708: my $now = time;
709: my $attachnum = 0;
1.213 raeburn 710: my $currnewattach = [];
711: my $currdelold = [];
1.108 raeburn 712: my $comment = '';
713: my $subject = '';
1.157 albertel 714: if ($env{'form.origpage'}) {
1.108 raeburn 715: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['addnewattach','deloldattach','delnewattach','timestamp','idx','subject','comment']);
1.204 www 716: $subject = &unescape($env{'form.subject'});
717: $comment = &unescape($env{'form.comment'});
1.108 raeburn 718: my @keepold = ();
1.208 raeburn 719: &process_attachments($currnewattach,$currdelold,\@keepold);
720: if (@{$currnewattach} > 0) {
721: $attachnum += @{$currnewattach};
1.108 raeburn 722: }
723: }
1.299 raeburn 724: if ((&discussion_open($status)) && ($outputtarget ne 'tex')) {
1.208 raeburn 725: if (($group ne '') && ($mode eq 'board')) {
1.304 raeburn 726: if ((&check_group_priv($group,'pgd') eq 'ok') &&
727: ($ressymb =~ m{^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$})) {
1.208 raeburn 728: $discussion .=
1.210 albertel 729: &postingform_display($mode,$ressymb,$now,$subject,
730: $comment,$outputtarget,$attachnum,
731: $currnewattach,$currdelold,
1.278 raeburn 732: $group,$crstype);
1.108 raeburn 733: }
1.208 raeburn 734: } else {
1.303 raeburn 735: if (&Apache::lonnet::allowed('pch',$env{'request.course.id'}.
736: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
737:
738: $discussion.=
739: &postingform_display($mode,$ressymb,$now,$subject,
740: $comment,$outputtarget,$attachnum,
741: $currnewattach,$currdelold,'',$crstype);
742: } else {
743: $discussion.= '<span class="LC_feedback_link">'.
744: &mt('This discussion is closed.').'</span>';
745: }
1.208 raeburn 746: }
1.95 sakharuk 747: }
1.303 raeburn 748: if (!(&discussion_open($status)) && ($outputtarget ne 'tex')) {
749: $discussion.= '<span class="LC_feedback_link">'.
750: &mt('This discussion is closed.').'</span>';
751: }
1.299 raeburn 752: } elsif ($outputtarget ne 'tex') {
1.251 albertel 753: $discussion.='<div class="LC_feedback_link">';
1.140 raeburn 754: if (&discussion_open($status) &&
755: &Apache::lonnet::allowed('pch',
1.157 albertel 756: $env{'request.course.id'}.
757: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
1.306 www 758: $discussion.= &send_feedback_link($ressymb);
1.299 raeburn 759: if ($env{'request.role.adv'}) {
760: my $close = &Apache::lonnet::EXT('resource.0.discussend',$ressymb);
761: if (defined($close) && $close ne '' && $close < time) {
762: $discussion .= ' '.&mt('(Closed for [_1] roles)',
763: &Apache::lonnet::plaintext('st',$crstype));
1.298 raeburn 764: }
1.190 www 765: }
1.294 www 766: } else {
1.299 raeburn 767: $discussion.= '<span class="LC_feedback_link">'.&mt('This discussion is closed.').'</span>';
1.232 raeburn 768: }
1.299 raeburn 769: $discussion.= &send_message_link($ressymb).'</div>';
1.74 www 770: }
1.114 sakharuk 771: return $discussion;
1.54 www 772: }
1.1 www 773:
1.307 www 774:
775: sub discussion_link {
776: my ($ressymb,$linktext,$cmd,$item,$flag,$prev,$adds)=@_;
777: my $link='/adm/feedback?inhibitmenu=yes&modal=yes&'.$cmd.'='.&escape($ressymb).':::'.$item;
778: if ($flag) { $link .= '&previous='.$prev; }
779: if ($adds) { $link .= $adds; }
1.310 www 780: return &Apache::loncommon::modal_link($link,$linktext,600,600);
1.307 www 781: }
782:
783:
1.232 raeburn 784: sub send_feedback_link {
1.306 www 785: my ($ressymb) = @_;
1.307 www 786: return '<span class="LC_feedback_link">'.
787: &discussion_link($ressymb,
1.306 www 788: '<img alt="" class="LC_noBorder" src="'.
789: &Apache::loncommon::lonhttpdurl('/adm/lonMisc/chat.gif').
790: '" border="0" /><span class="LC_menubuttons_inline_text">'.&mt('Post Discussion').'</span>',
1.307 www 791: 'replydisc').
792: '</span>';
1.232 raeburn 793: }
794:
795: sub send_message_link {
796: my ($ressymb) = @_;
1.251 albertel 797: my $output = '<span class="LC_message_link">'.
1.232 raeburn 798: ' <a href="/adm/feedback?sendmessageonly=1&symb='.
1.274 kalberla 799: &escape($ressymb).'"><img alt="" class="LC_noBorder" src="'.
1.292 wenzelju 800: &Apache::loncommon::lonhttpdurl('/res/adm/pages/feedback.png').
1.274 kalberla 801: '" border="0" /><span class="LC_menubuttons_inline_text">'.&mt('Send Feedback').'</span></a></span>';
1.232 raeburn 802: return $output;
803: }
804:
1.222 raeburn 805: sub action_links_bar {
806: my ($colspan,$ressymb,$visible,$newpostsflag,$group,$prevread,$markondisp) = @_;
1.270 www 807: my $discussion = '<tr><td class="LC_disc_action_links_bar" colspan="'.$colspan.'">'.
1.277 raeburn 808: '<table width="100%" class="LC_disc_action_table"><tr>'.
809: '<td class="LC_disc_action_left">';
1.222 raeburn 810: my $escsymb=&escape($ressymb);
1.300 raeburn 811: if ($visible) {
1.277 raeburn 812: $discussion .= '<a href="/adm/feedback?cmd=threadedon&symb='.$escsymb;
1.222 raeburn 813: if ($newpostsflag) {
1.282 wenzelju 814: $discussion .= '&previous='.$prevread;
1.222 raeburn 815: }
816: $discussion .= &group_args($group);
817: $discussion .='">'.&mt('Threaded View').'</a> '.
818: '<a href="/adm/feedback?cmd=threadedoff&symb='.$escsymb;
819: if ($newpostsflag) {
1.282 wenzelju 820: $discussion .= '&previous='.$prevread;
1.222 raeburn 821: }
822: $discussion .= &group_args($group);
823: $discussion .='">'.&mt('Chronological View').'</a>
1.271 bisitz 824: <a href="/adm/feedback?cmd=sortfilter&symb='.$escsymb;
1.222 raeburn 825: if ($newpostsflag) {
1.282 wenzelju 826: $discussion .= '&previous='.$prevread;
1.222 raeburn 827: }
828: $discussion .= &group_args($group);
1.259 raeburn 829: $discussion .='">'.&mt('Sorting/Filtering options').'</a>'.(' ' x2);
1.222 raeburn 830: }
1.271 bisitz 831: $discussion .='<a href="/adm/feedback?export='.$escsymb;
1.222 raeburn 832: if ($newpostsflag) {
1.282 wenzelju 833: $discussion .= '&previous='.$prevread;
1.222 raeburn 834: }
835: $discussion .= &group_args($group);
836: $discussion .= '">'.&mt('Export').'?</a> </td>';
837: if ($newpostsflag) {
838: if (!$markondisp) {
1.270 www 839: $discussion .='<td class="LC_disc_action_right"><a href="/adm/preferences?action=changediscussions';
1.222 raeburn 840: $discussion .= &group_args($group);
841: $discussion .= '">'.
842: &mt('Preferences on what is marked as NEW').
843: '</a><br /><a href="/adm/feedback?markread=1&symb='.$escsymb;
844: $discussion .= &group_args($group);
1.281 bisitz 845: $discussion .= '">'.&mt('Mark NEW posts no longer new').'</a></td>';
1.222 raeburn 846: } else {
847: $discussion .= '<td> </td>';
848: }
849: } else {
850: $discussion .= '<td> </td>';
851: }
852: $discussion .= '</tr></table></td></tr>';
853: return $discussion;
854: }
855:
1.208 raeburn 856: sub postingform_display {
857: my ($mode,$ressymb,$now,$subject,$comment,$outputtarget,$attachnum,
1.278 raeburn 858: $currnewattach,$currdelold,$group,$crstype) = @_;
1.208 raeburn 859: my $newattachmsg;
1.220 raeburn 860: my %lt = &Apache::lonlocal::texthash(
861: 'note' => 'Note: in anonymous discussion, your name is visible only to course faculty',
862: 'title' => 'Title',
863: 'podi' => 'Post Discussion',
864: 'poan' => 'Post Anonymous Discussion',
865: 'newa' => 'New attachments',
866: );
1.278 raeburn 867: if ($crstype eq 'Community') {
868: $lt{'note'} = &mt('Note: in anonymous discussion, your name is visible only to community facilitators');
869: }
1.297 raeburn 870: my ($postingform,$textareaclass);
871: if (&Apache::lonhtmlcommon::htmlareabrowser()) {
872: $postingform = &Apache::lonhtmlcommon::htmlareaselectactive();
873: $textareaclass = 'class="LC_richDefaultOff"';
1.301 raeburn 874: if ($env{'request.course.id'}) {
875: unless (($env{'course.'.$env{'request.course.id'}.'.allow_limited_html_in_feedback'} =~ /^\s*yes\s*$/i) || ($env{'form.sendmessageonly'})) {
876: undef($textareaclass);
877: }
878: }
1.297 raeburn 879: }
880: $postingform .= (<<ENDDISCUSS);
1.220 raeburn 881: <form action="/adm/feedback" method="post" name="mailform" enctype="multipart/form-data"> <input type="submit" name="discuss" value="$lt{'podi'}" />
882: <input type="submit" name="anondiscuss" value="$lt{'poan'}" /> <input type="hidden" name="symb" value="$ressymb" />
1.208 raeburn 883: <input type="hidden" name="sendit" value="true" />
884: <input type="hidden" name="timestamp" value="$now" />
885: <br /><a name="newpost"></a>
1.220 raeburn 886: <font size="1">$lt{'note'}</font><br />
887: <b>$lt{'title'}:</b> <input type="text" name="subject" value="$subject" size="30" /><br /><br />
1.297 raeburn 888: <textarea name="comment" cols="80" rows="14" id="comment" $textareaclass>$comment</textarea>
1.208 raeburn 889: ENDDISCUSS
890: if ($env{'form.origpage'}) {
891: $postingform .= '<input type="hidden" name="origpage" value="'.
892: $env{'form.origpage'}.'" />'."\n";
893: foreach my $att (@{$currnewattach}) {
894: $postingform .= '<input type="hidden" name="currnewattach" '.
895: 'value="'.$att.'" />'."\n";
896: }
897: }
898: if (exists($env{'form.ref'})) {
899: $postingform .= '<input type="hidden" name="ref" value="'.
900: $env{'form.ref'}.'" />';
901: }
902: if ($group ne '') {
903: $postingform .='<input type="hidden" name="group" value="'.$group.'" />';
904: }
1.235 raeburn 905: my $blockblog = &Apache::loncommon::blocking_status('blogs');
1.224 raeburn 906: if (!$blockblog) {
1.278 raeburn 907: $postingform .= &add_blog_checkbox($crstype);
1.224 raeburn 908: }
1.208 raeburn 909: $postingform .= "</form>\n";
1.295 www 910: $postingform .= &generate_attachments_button('',$attachnum,$ressymb,
1.208 raeburn 911: $now,$currnewattach,
1.224 raeburn 912: $currdelold,'',$mode,
913: $blockblog);
1.295 www 914: if ((ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)) {
915: $newattachmsg = '<br /><b>'.$lt{'newa'}.'</b><br />';
916: if (@{$currnewattach} > 1) {
917: $newattachmsg .= '<ol>';
918: foreach my $item (@{$currnewattach}) {
919: $item =~ m#.*/([^/]+)$#;
920: $newattachmsg .= '<li><a href="'.$item.'">'.$1.'</a></li>'."\n";
921: }
922: $newattachmsg .= '</ol>'."\n";
923: } else {
924: $$currnewattach[0] =~ m#.*/([^/]+)$#;
925: $newattachmsg .= '<a href="'.$$currnewattach[0].'">'.$1.'</a><br />'."\n";
926: }
1.208 raeburn 927: }
1.295 www 928: $postingform .= $newattachmsg;
929: $postingform .= &generate_preview_button();
1.208 raeburn 930: return $postingform;
931: }
932:
1.116 raeburn 933: sub build_posting_display {
1.306 www 934: my ($usernamesort,$subjectsort,$namesort,$notshown,$newitem,$dischash,$shown,$alldiscussion,$imsitems,$imsfiles,$roleinfo,$discussionitems,$replies,$depth,$posters,$maxdepth,$visible,$newpostsflag,$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$ressymb,$readkey,$showunmark,$showonlyunread,$totposters,$rolefilter,$sectionpick,$grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,$anonhash,$anoncnt,$group) = @_;
1.116 raeburn 935: my @original=();
936: my @index=();
1.210 albertel 937: my $skip_group_check = 0;
1.133 albertel 938: my $symb=&Apache::lonenc::check_decrypt($ressymb);
1.204 www 939: my $escsymb=&escape($ressymb);
1.157 albertel 940: my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
941: $env{'course.'.$env{'request.course.id'}.'.domain'},
942: $env{'course.'.$env{'request.course.id'}.'.num'});
1.116 raeburn 943:
1.248 albertel 944: my $see_anonymous =
945: &Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
946:
1.210 albertel 947: if ((@{$grouppick} == 0) || (grep(/^all$/,@{$grouppick}))) {
948: $skip_group_check = 1;
1.208 raeburn 949: }
1.300 raeburn 950: my (%deletions,%hiddens);
951: if ($contrib{'deleted'}) {
952: my $deleted = $contrib{'deleted'};
953: $deleted =~ s/^\.//;
954: $deleted =~ s/\.$//;
955: %deletions = map { $_ => 1 } (split(/\.\./,$deleted));
956: }
957: if ($contrib{'hidden'}) {
958: my $hidden = $contrib{'hidden'};
959: $hidden =~ s/^\.//;
960: $hidden =~ s/\.$//;
961: %hiddens = map { $_ => 1 } (split(/\.\./,$hidden));
962: }
1.116 raeburn 963: if ($contrib{'version'}) {
964: my $oldest = $contrib{'1:timestamp'};
965: if ($prevread eq '0') {
966: $prevread = $oldest-1;
967: }
1.143 raeburn 968: my ($skiptest,$rolematch,$roleregexp,$secregexp,$statusregexp);
969: if ($sortposts) {
1.208 raeburn 970: ($skiptest,$roleregexp,$secregexp,$statusregexp) =
971: &filter_regexp($rolefilter,$sectionpick,$statusfilter);
1.143 raeburn 972: $rolematch = $roleregexp.':'.$secregexp.':'.$statusregexp;
973: }
1.116 raeburn 974: for (my $id=1;$id<=$contrib{'version'};$id++) {
975: my $idx=$id;
1.300 raeburn 976: next if ($contrib{$idx.':deleted'});
977: next if ($contrib{$idx.':hidden'});
1.116 raeburn 978: my $posttime = $contrib{$idx.':timestamp'};
979: if ($prevread <= $posttime) {
980: $$newpostsflag = 1;
981: }
982: my $studenthidden=($contrib{'studenthidden'}=~/\.$idx\./);
983: my $origindex='0.';
984: my $numoldver=0;
985: if ($contrib{$idx.':replyto'}) {
1.157 albertel 986: if ( (($env{'environment.threadeddiscussion'}) && ($sortposts eq '')) || ($sortposts eq 'thread') || ($outputtarget eq 'export')) {
1.116 raeburn 987: # this is a follow-up message
988: $original[$idx]=$original[$contrib{$idx.':replyto'}];
989: $$depth[$idx]=$$depth[$contrib{$idx.':replyto'}]+1;
990: $origindex=$index[$contrib{$idx.':replyto'}];
991: if ($$depth[$idx]>$$maxdepth) { $$maxdepth=$$depth[$idx]; }
992: } else {
993: $original[$idx]=0;
994: $$depth[$idx]=0;
995: }
996: } else {
997: # this is an original message
998: $original[$idx]=0;
999: $$depth[$idx]=0;
1000: }
1001: if ($$replies[$$depth[$idx]]) {
1002: $$replies[$$depth[$idx]]++;
1003: } else {
1004: $$replies[$$depth[$idx]]=1;
1005: }
1.300 raeburn 1006: unless ((($hiddens{$idx}) && (!$seeid)) || ($deletions{$idx})) {
1.116 raeburn 1007: $$visible++;
1008: if ($contrib{$idx.':history'}) {
1009: if ($contrib{$idx.':history'} =~ /:/) {
1.221 raeburn 1010: my @oldversions = split(/:/,$contrib{$idx.':history'});
1.116 raeburn 1011: $numoldver = @oldversions;
1012: } else {
1013: $numoldver = 1;
1014: }
1015: }
1016: $$current = $numoldver;
1017: my %messages = ();
1018: my %subjects = ();
1019: my %attachtxt = ();
1020: my %allattachments = ();
1021: my ($screenname,$plainname);
1022: my $sender = &mt('Anonymous');
1.173 www 1023: # Anonymous users getting number within a discussion
1024: # Since idx is in static order, this should give the same sequence every time.
1025: my $key=$contrib{$idx.':sendername'}.'@'.$contrib{$idx.':senderdomain'};
1026: unless ($$anonhash{$key}) {
1027: $anoncnt++;
1028: $$anonhash{$key}=&mt('Anonymous').' '.$anoncnt;
1029: }
1.116 raeburn 1030: my ($message,$subject,$vgrlink,$ctlink);
1031: &get_post_contents(\%contrib,$idx,$seeid,$outputtarget,\%messages,\%subjects,\%allattachments,\%attachtxt,$imsfiles,\$screenname,\$plainname,$numoldver);
1032:
1033:
1034: # Set up for sorting by subject
1035: unless ($outputtarget eq 'export') {
1036: $message=$messages{$numoldver};
1037: $message.=$attachtxt{$numoldver};
1038: $subject=$subjects{$numoldver};
1039: if ($message) {
1.300 raeburn 1040: if ($hiddens{$idx}) {
1.116 raeburn 1041: $message='<font color="#888888">'.$message.'</font>';
1042: if ($studenthidden) {
1043: $message .='<br /><br />Deleted by poster (student).';
1044: }
1045: }
1046:
1047: if ($subject eq '') {
1048: if (defined($$subjectsort{'__No subject'})) {
1.221 raeburn 1049: push(@{$$subjectsort{'__No subject'}}, $idx);
1.116 raeburn 1050: } else {
1051: @{$$subjectsort{'__No subject'}} = ("$idx");
1052: }
1053: } else {
1054: if (defined($$subjectsort{$subject})) {
1.221 raeburn 1055: push(@{$$subjectsort{$subject}}, $idx);
1.116 raeburn 1056: } else {
1057: @{$$subjectsort{$subject}} = ("$idx");
1058: }
1059: }
1.248 albertel 1060: if (!$contrib{$idx.':anonymous'} || $see_anonymous) {
1.116 raeburn 1061: $sender=&Apache::loncommon::aboutmewrapper(
1062: $plainname,
1063: $contrib{$idx.':sendername'},
1064: $contrib{$idx.':senderdomain'}).' ('.
1.254 bisitz 1065: $contrib{$idx.':sendername'}.':'.
1.116 raeburn 1066: $contrib{$idx.':senderdomain'}.')';
1.287 raeburn 1067: $sender = '<b>'.$sender.'</b>';
1.116 raeburn 1068: if ($contrib{$idx.':anonymous'}) {
1.173 www 1069: $sender.=' <font color="red"><b>['.$$anonhash{$key}.']</b></font> '.
1.116 raeburn 1070: $screenname;
1071: }
1.248 albertel 1072: if ($see_anonymous) {
1073: $sender.=&Apache::loncommon::student_image_tag($contrib{$idx.':senderdomain'},$contrib{$idx.':sendername'});
1074: }
1.116 raeburn 1075: # Set up for sorting by domain, then username
1076: unless (defined($$usernamesort{$contrib{$idx.':senderdomain'}})) {
1077: %{$$usernamesort{$contrib{$idx.':senderdomain'}}} = ();
1078: }
1079: if (defined($$usernamesort{$contrib{$idx.':senderdomain'}}{$contrib{$idx.':sendername'}})) {
1.221 raeburn 1080: push(@{$$usernamesort{$contrib{$idx.':senderdomain'}}{$contrib{$idx.':sendername'}}}, $idx);
1.116 raeburn 1081: } else {
1082: @{$$usernamesort{$contrib{$idx.':senderdomain'}}{$contrib{$idx.':sendername'}}} = ("$idx");
1083: }
1084: # Set up for sorting by last name, then first name
1085: my %names = &Apache::lonnet::get('environment',
1086: ['firstname','lastname'],$contrib{$idx.':senderdomain'},
1087: ,$contrib{$idx.':sendername'});
1088: my $lastname = $names{'lastname'};
1089: my $firstname = $names{'firstname'};
1090: if ($lastname eq '') {
1091: $lastname = '_';
1092: }
1093: if ($firstname eq '') {
1094: $firstname = '_';
1095: }
1096: unless (defined($$namesort{$lastname})) {
1097: %{$$namesort{$lastname}} = ();
1098: }
1099: if (defined($$namesort{$lastname}{$firstname})) {
1.221 raeburn 1100: push(@{$$namesort{$lastname}{$firstname}}, $idx);
1.116 raeburn 1101: } else {
1102: @{$$namesort{$lastname}{$firstname}} = ("$idx");
1103: }
1.299 raeburn 1104: if ($outputtarget ne 'tex') {
1105: if (&editing_allowed($escsymb.':::'.$idx,$group)) {
1106: if (($env{'user.domain'} eq $contrib{$idx.':senderdomain'}) && ($env{'user.name'} eq $contrib{$idx.':sendername'})) {
1.308 www 1107: $sender.=' '.
1108: &discussion_link($symb,&mt('Edit'),'editdisc',$idx,$$newpostsflag,$prevread,&group_args($group));
1.299 raeburn 1109: unless ($seeid) {
1110: my $grpargs = &group_args($group);
1111: $sender.=" <a href=\"javascript:verifydelete('studentdelete','$escsymb','$idx','$$newpostsflag','$prevread','$grpargs')";
1112: $sender .= '">'.&mt('Delete').'</a>';
1113: }
1.116 raeburn 1114: }
1115: }
1.299 raeburn 1116: if ($seeid) {
1.300 raeburn 1117: if ($hiddens{$idx}) {
1.299 raeburn 1118: unless ($studenthidden) {
1.308 www 1119: $sender.=' '.
1120: &discussion_link($symb,&mt('Make Visible'),'unhide',$idx,$$newpostsflag,$prevread,&group_args($group));
1.299 raeburn 1121: }
1122: } else {
1.308 www 1123: $sender.=' '.
1124: &discussion_link($symb,&mt('Hide'),'hide',$idx,$$newpostsflag,$prevread,&group_args($group));
1.299 raeburn 1125: }
1126: my $grpargs = &group_args($group);
1127: $sender.=
1128: " <a href=\"javascript:verifydelete('seeiddelete','$escsymb','$idx','$$newpostsflag','$prevread','$grpargs')\">";
1129: $sender .= &mt('Delete').'</a>';
1130: }
1.116 raeburn 1131: }
1.299 raeburn 1132: } else {
1.116 raeburn 1133: if ($screenname) {
1134: $sender='<i>'.$screenname.'</i>';
1.173 www 1135: } else {
1136: $sender='<i>'.$$anonhash{$key}.'</i>';
1.116 raeburn 1137: }
1.287 raeburn 1138: $sender = '<b>'.$sender.'</b>';
1.116 raeburn 1139: # Set up for sorting by domain, then username for anonymous
1140: unless (defined($$usernamesort{'__anon'})) {
1141: %{$$usernamesort{'__anon'}} = ();
1142: }
1143: if (defined($$usernamesort{'__anon'}{'__anon'})) {
1.221 raeburn 1144: push(@{$$usernamesort{'__anon'}{'__anon'}}, $idx);
1.116 raeburn 1145: } else {
1146: @{$$usernamesort{'__anon'}{'__anon'}} = ("$idx");
1147: }
1148: # Set up for sorting by last name, then first name for anonymous
1149: unless (defined($$namesort{'__anon'})) {
1150: %{$$namesort{'__anon'}} = ();
1151: }
1152: if (defined($$namesort{'__anon'}{'__anon'})) {
1.221 raeburn 1153: push(@{$$namesort{'__anon'}{'__anon'}}, $idx);
1.116 raeburn 1154: } else {
1155: @{$$namesort{'__anon'}{'__anon'}} = ("$idx");
1156: }
1157: }
1.299 raeburn 1158: if ($outputtarget ne 'tex') {
1159: if (&discussion_open($status)) {
1160: if (($group ne '') &&
1161: (&check_group_priv($group,'pgd') eq 'ok')) {
1.307 www 1162: $sender.=' '.
1163: &discussion_link($symb,&mt('Reply'),'replydisc',$idx,$$newpostsflag,$prevread,&group_args($group));
1.299 raeburn 1164: } elsif (&Apache::lonnet::allowed('pch',
1165: $env{'request.course.id'}.
1166: ($env{'request.course.sec'}?'/'.
1167: $env{'request.course.sec'}:''))) {
1.307 www 1168: $sender.=' '.
1169: &discussion_link($symb,&mt('Reply'),'replydisc',$idx,$$newpostsflag,$prevread);
1.208 raeburn 1170: }
1.116 raeburn 1171: }
1.299 raeburn 1172: if ($viewgrades) {
1.290 bisitz 1173: $vgrlink=&Apache::loncommon::submlink(&mt('Submissions'),
1.299 raeburn 1174: $contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$ressymb);
1175: }
1176: if ($$dischash{$readkey}=~/\.$idx\./) {
1177: $ctlink = '<label><b>'.&mt('Mark unread').'?</b> <input type="checkbox" name="postunread_'.$idx.'" /></label>';
1178: } else {
1179: $ctlink = '<label><b>'.&mt('Mark read').'?</b> <input type="checkbox" name="postread_'.$idx.'" /></label>';
1180: }
1.116 raeburn 1181: }
1182: }
1183: #figure out at what position this needs to print
1184: }
1185: if ($outputtarget eq 'export' || $message) {
1186: my $thisindex=$idx;
1.157 albertel 1187: if ( (($env{'environment.threadeddiscussion'}) && ($sortposts eq '')) || ($sortposts eq 'thread') || ($outputtarget eq 'export')) {
1.116 raeburn 1188: $thisindex=$origindex.substr('00'.$$replies[$$depth[$idx]],-2,2);
1189: }
1190: $$alldiscussion{$thisindex}=$idx;
1191: $$shown{$idx} = 0;
1192: $index[$idx]=$thisindex;
1193: }
1194: if ($outputtarget eq 'export') {
1195: %{$$imsitems{$idx}} = ();
1196: $$imsitems{$idx}{'isvisible'}='true';
1.300 raeburn 1197: if ($hiddens{$idx}) {
1.116 raeburn 1198: $$imsitems{$idx}{'isvisible'}='false';
1199: }
1200: $$imsitems{$idx}{'title'}=$subjects{$numoldver};
1201: $$imsitems{$idx}{'message'}=$messages{$numoldver};
1202: $$imsitems{$idx}{'attach'}=$attachtxt{$numoldver};
1203: $$imsitems{$idx}{'timestamp'}=$contrib{$idx.':timestamp'};
1204: $$imsitems{$idx}{'sender'}=$plainname.' ('.
1.276 bisitz 1205: $contrib{$idx.':sendername'}.':'.
1.116 raeburn 1206: $contrib{$idx.':senderdomain'}.')';
1207: $$imsitems{$idx}{'isanonymous'}='false';
1208: if ($contrib{$idx.':anonymous'}) {
1209: $$imsitems{$idx}{'isanonymous'}='true';
1210: }
1211: $$imsitems{$idx}{'currversion'}=$numoldver;
1212: %{$$imsitems{$idx}{'allattachments'}}=%allattachments;
1213: unless ($messages{$numoldver} eq '' && $attachtxt{$numoldver} eq '') {
1214: $$shown{$idx} = 1;
1215: }
1216: } else {
1217: if ($message) {
1218: my $spansize = 2;
1219: if ($showonlyunread && $prevread > $posttime) {
1220: $$notshown{$idx} = 1;
1221: } elsif ($showunmark && $$dischash{$readkey}=~/\.$idx\./) {
1222: $$notshown{$idx} = 1;
1223: } else {
1224: # apply filters
1225: my $uname = $contrib{$idx.':sendername'};
1226: my $udom = $contrib{$idx.':senderdomain'};
1227: my $poster = $uname.':'.$udom;
1.208 raeburn 1228: if ($env{'form.totposters'} ne '') {
1.143 raeburn 1229: if ($totposters == 0) {
1230: $$shown{$idx} = 0;
1231: } elsif ($totposters > 0) {
1232: if (grep/^$poster$/,@{$posters}) {
1233: $$shown{$idx} = 1;
1.116 raeburn 1234: }
1235: }
1.143 raeburn 1236: } elsif ($sortposts) {
1.116 raeburn 1237: if ($skiptest) {
1238: $$shown{$idx} = 1;
1239: } else {
1240: foreach my $role (@{$$roleinfo{$poster}}) {
1.143 raeburn 1241: if ($role =~ /^cc:/) {
1242: my $cc_regexp = $roleregexp.':[^:]*:'.$statusregexp;
1243: if ($role =~ /$cc_regexp/) {
1244: $$shown{$idx} = 1;
1.144 raeburn 1245: last;
1.143 raeburn 1246: }
1247: } elsif ($role =~ /^$rolematch$/) {
1.116 raeburn 1248: $$shown{$idx} = 1;
1249: last;
1250: }
1251: }
1252: }
1.210 albertel 1253: if ($$shown{$idx} && !$skip_group_check) {
1.208 raeburn 1254: my $showflag = 0;
1255: if (ref($$classgroups{$poster}{active}) eq 'HASH') {
1256: foreach my $grp (@{$grouppick}) {
1257: if (grep/^\Q$grp\E$/,
1258: keys(%{$$classgroups{$poster}{active}})) {
1259: $showflag = 1;
1260: last;
1261: }
1262: }
1263: }
1264: if ($showflag) {
1265: $$shown{$idx} = 1;
1266: } else {
1267: $$shown{$idx} = 0;
1268: }
1269: }
1.143 raeburn 1270: } else {
1271: $$shown{$idx} = 1;
1.116 raeburn 1272: }
1273: }
1274: unless ($$notshown{$idx} == 1) {
1275: if ($prevread > 0 && $prevread <= $posttime) {
1276: $$newitem{$idx} = 1;
1277: $$discussionitems[$idx] .= '
1.282 wenzelju 1278: <table border="0" width="100%">
1.295 www 1279: <tr><td align="left"><font color="#FF0000"><b>'.&mt('NEW').' </b></font></td>';
1.116 raeburn 1280: } else {
1281: $$newitem{$idx} = 0;
1282: $$discussionitems[$idx] .= '
1.282 wenzelju 1283: <table border="0" width="100%">
1.116 raeburn 1284: <tr><td align="left"> </td>';
1285: }
1.271 bisitz 1286: $$discussionitems[$idx] .= '<td align="left"> '.
1.116 raeburn 1287: '<b>'.$subject.'</b> '.
1.288 raeburn 1288: $sender.' '.$vgrlink.' ('.
1.116 raeburn 1289: &Apache::lonlocal::locallocaltime($posttime).')</td>';
1290: if ($$dischash{$toggkey}) {
1291: $$discussionitems[$idx].='<td align="right"> '.
1292: $ctlink.'</td>';
1293: }
1294: $$discussionitems[$idx].= '</tr></table><blockquote>'.
1.282 wenzelju 1295: $message.'</blockquote>';
1.116 raeburn 1296: if ($contrib{$idx.':history'}) {
1297: my @postversions = ();
1298: $$discussionitems[$idx] .= &mt('This post has been edited by the author.');
1299: if ($seeid) {
1.308 www 1300: $$discussionitems[$idx] .= ' '.
1301: &discussion_link($symb,&mt('Display all versions'),'allversions',$idx,$$newpostsflag,$prevread,&group_args($group));
1.116 raeburn 1302: }
1303: $$discussionitems[$idx].='<br/>'.&mt('Earlier version(s) were posted on: ');
1304: if ($contrib{$idx.':history'} =~ m/:/) {
1.221 raeburn 1305: @postversions = split(/:/,$contrib{$idx.':history'});
1.116 raeburn 1306: } else {
1307: @postversions = ("$contrib{$idx.':history'}");
1308: }
1309: for (my $i=0; $i<@postversions; $i++) {
1310: my $version = $i+1;
1311: $$discussionitems[$idx] .= '<b>'.$version.'.</b> - '.&Apache::lonlocal::locallocaltime($postversions[$i]).' ';
1312: }
1313: }
1314: }
1315: }
1316: }
1317: }
1318: }
1319: }
1320: }
1321:
1.143 raeburn 1322: sub filter_regexp {
1323: my ($rolefilter,$sectionpick,$statusfilter) = @_;
1324: my ($roleregexp,$secregexp,$statusregexp);
1325: my $skiptest = 1;
1326: if (@{$rolefilter} > 0) {
1327: my @okrolefilter = ();
1.221 raeburn 1328: foreach my $role (@{$rolefilter}) {
1329: unless ($role eq '') {
1330: push(@okrolefilter, $role);
1.143 raeburn 1331: }
1332: }
1333: if (@okrolefilter > 0) {
1334: if (grep/^all$/,@okrolefilter) {
1335: $roleregexp='[^:]+';
1336: } else {
1337: if (@okrolefilter == 1) {
1338: $roleregexp=$okrolefilter[0];
1339: } else {
1340: $roleregexp='('.join('|',@okrolefilter).')';
1341: }
1342: $skiptest = 0;
1343: }
1344: }
1345: }
1346: if (@{$sectionpick} > 0) {
1347: my @oksectionpick = ();
1.221 raeburn 1348: foreach my $sec (@{$sectionpick}) {
1349: unless ($sec eq '') {
1350: push(@oksectionpick, $sec);
1.143 raeburn 1351: }
1352: }
1353: if ((@oksectionpick > 0) && (!grep/^all$/,@oksectionpick)) {
1354: if (@oksectionpick == 1) {
1355: $secregexp = $oksectionpick[0];
1356: } else {
1357: $secregexp .= '('.join('|',@oksectionpick).')';
1358: }
1359: $skiptest = 0;
1360: } else {
1361: $secregexp .= '[^:]*';
1362: }
1363: }
1.208 raeburn 1364:
1.143 raeburn 1365: if (defined($statusfilter) && $statusfilter ne '') {
1366: if ($statusfilter eq 'all') {
1367: $statusregexp = '[^:]+';
1368: } else {
1369: $statusregexp = $statusfilter;
1370: $skiptest = 0;
1371: }
1372: }
1373: return ($skiptest,$roleregexp,$secregexp,$statusregexp);
1374: }
1375:
1376:
1.116 raeburn 1377: sub get_post_contents {
1378: my ($contrib,$idx,$seeid,$type,$messages,$subjects,$allattachments,$attachtxt,$imsfiles,$screenname,$plainname,$numver) = @_;
1379: my $discussion = '';
1380: my $start=$numver;
1381: my $end=$numver + 1;
1382: %{$$imsfiles{$idx}}=();
1383: if ($type eq 'allversions') {
1384: unless($seeid) {
1.208 raeburn 1385: $discussion=&mt('You do not have privileges to view all versions of posts.').' '.&mt('Please select a different role.');
1.116 raeburn 1386: return $discussion;
1387: }
1388: }
1.126 albertel 1389: # $$screenname=&Apache::loncommon::screenname(
1390: # $$contrib{$idx.':sendername'},
1391: # $$contrib{$idx.':senderdomain'});
1.172 www 1392: $$plainname=&Apache::loncommon::nickname(
1393: $$contrib{$idx.':sendername'},
1394: $$contrib{$idx.':senderdomain'});
1395: $$screenname=$$contrib{$idx.':screenname'};
1396:
1.116 raeburn 1397: my $sender=&Apache::loncommon::aboutmewrapper(
1398: $$plainname,
1399: $$contrib{$idx.':sendername'},
1400: $$contrib{$idx.':senderdomain'}).' ('.
1.276 bisitz 1401: $$contrib{$idx.':sendername'}.':'.
1.116 raeburn 1402: $$contrib{$idx.':senderdomain'}.')';
1403: my $attachmenturls = $$contrib{$idx.':attachmenturl'};
1404: my @postversions = ();
1405: if ($type eq 'allversions' || $type eq 'export') {
1406: $start = 0;
1407: if ($$contrib{$idx.':history'}) {
1.174 albertel 1408: @postversions = split(/:/,$$contrib{$idx.':history'});
1.116 raeburn 1409: }
1410: &get_post_versions($messages,$$contrib{$idx.':message'},1);
1411: &get_post_versions($subjects,$$contrib{$idx.':subject'},1);
1.221 raeburn 1412: push(@postversions,$$contrib{$idx.':timestamp'});
1.116 raeburn 1413: $end = @postversions;
1414: } else {
1415: &get_post_versions($messages,$$contrib{$idx.':message'},1,$numver);
1416: &get_post_versions($subjects,$$contrib{$idx.':subject'},1,$numver);
1417: }
1418:
1419: if ($$contrib{$idx.':anonymous'}) {
1420: $sender.=' ['.&mt('anonymous').'] '.$$screenname;
1421: }
1422: if ($type eq 'allversions') {
1423: $discussion=('<b>'.$sender.'</b><br /><ul>');
1424: }
1425: for (my $i=$start; $i<$end; $i++) {
1426: my ($timesent,$attachmsg);
1427: my %currattach = ();
1428: $timesent = &Apache::lonlocal::locallocaltime($postversions[$i]);
1.286 raeburn 1429: unless (&contains_block_html($messages->{$i})) {
1430: &newline_to_br(\$messages->{$i});
1431: }
1.116 raeburn 1432: $$messages{$i}=&Apache::lontexconvert::msgtexconverted($$messages{$i});
1433: $$subjects{$i}=~s/\n/\<br \/\>/g;
1434: $$subjects{$i}=&Apache::lontexconvert::msgtexconverted($$subjects{$i});
1435: if ($attachmenturls) {
1436: &extract_attachments($attachmenturls,$idx,$i,\$attachmsg,$allattachments,\%currattach);
1437: }
1438: if ($type eq 'export') {
1439: $$imsfiles{$idx}{$i} = '';
1440: if ($attachmsg) {
1.220 raeburn 1441: $$attachtxt{$i} = '<br />'.&mt('Attachments').':<br />';
1.221 raeburn 1442: foreach my $key (sort(keys(%currattach))) {
1443: if ($$allattachments{$key}{'filename'} =~ m-^/uploaded/([^/]+/[^/]+)(/feedback)?(/?\d*)/([^/]+)$-) {
1.116 raeburn 1444: my $fname = $1.$3.'/'.$4;
1.284 raeburn 1445: $$imsfiles{$idx}{$i} .= '<file href="'.$fname.'" />'."\n";
1.116 raeburn 1446: $$attachtxt{$i}.= '<a href="'.$fname.'">'.$4.'</a><br />';
1447: }
1448: }
1449: }
1450: } else {
1451: if ($attachmsg) {
1.220 raeburn 1452: $$attachtxt{$i} = '<br />'.&mt('Attachments').':'.$attachmsg.'<br />';
1.116 raeburn 1453: } else {
1454: $$attachtxt{$i} = '';
1455: }
1456: }
1457: if ($type eq 'allversions') {
1458: $discussion.= <<"END";
1459: <li><b>$$subjects{$i}</b>, $timesent<br />
1460: $$messages{$i}<br />
1461: $$attachtxt{$i}</li>
1462: END
1463: }
1464: }
1465: if ($type eq 'allversions') {
1.187 albertel 1466: $discussion.='</ul>';
1.116 raeburn 1467: return $discussion;
1468: } else {
1469: return;
1470: }
1471: }
1472:
1473: sub replicate_attachments {
1474: my ($attachrefs,$tempexport) = @_;
1475: my $response;
1.221 raeburn 1476: foreach my $id (keys(%{$attachrefs})) {
1.116 raeburn 1477: if ($$attachrefs{$id}{'filename'} =~ m-^/uploaded/([^/]+)/([^/]+)(/feedback)?(/?\d*)/([^/]+)$-) {
1478: my $path = $tempexport;
1479: my $tail = $1.'/'.$2.$4;
1.221 raeburn 1480: my @extras = split(/\//,$tail);
1.116 raeburn 1481: my $destination = $tempexport.'/'.$1.'/'.$2.$4.'/'.$5;
1482: if (!-e $destination) {
1483: my $i= 0;
1484: while ($i<@extras) {
1485: $path .= '/'.$extras[$i];
1486: if (!-e $path) {
1487: mkdir($path,0700);
1488: }
1489: $i ++;
1490: }
1491: my ($content,$rtncode);
1492: my $uploadreply = &Apache::lonnet::getuploaded('GET',$$attachrefs{$id}{'filename'},$1,$2,$content,$rtncode);
1493: if ($uploadreply eq 'ok') {
1.125 raeburn 1494: my $attachcopy;
1495: if ($attachcopy = Apache::File->new('>'.$destination)) {
1496: print $attachcopy $content;
1497: close($attachcopy);
1498: } else {
1.220 raeburn 1499: $response .= &mt('Error copying file attachment - [_1] to IMS package',$5).': '.$!.'<br />'."\n";
1.125 raeburn 1500: }
1.116 raeburn 1501: } else {
1.125 raeburn 1502: &Apache::lonnet::logthis("Replication of attachment failed when building IMS export of discussion posts - domain: $1, course: $2, file: $$attachrefs{$id}{'filename'} -error: $rtncode");
1.220 raeburn 1503: $response .= &mt('Error copying file attachment - [_1] to IMS package: ',$5).$rtncode.'<br />'."\n";
1.116 raeburn 1504: }
1505: }
1506: }
1507: }
1.125 raeburn 1508: return $response;
1.116 raeburn 1509: }
1510:
1.6 albertel 1511: sub mail_screen {
1.255 raeburn 1512: my ($r,$feedurl,$options,$caller_symb,$attachmaxtext) = @_;
1.157 albertel 1513: if (exists($env{'form.origpage'})) {
1.208 raeburn 1514: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','currnewattach','addnewattach','deloldattach','delnewattach','timestamp','idx','anondiscuss','discuss','blog','group','ref']);
1.108 raeburn 1515: }
1.186 albertel 1516:
1.220 raeburn 1517: my %lt = &Apache::lonlocal::texthash(
1518: 'myqu' => 'My question/comment/feedback:',
1519: 'title' => 'Title',
1520: 'reta' => 'Retained attachments',
1.255 raeburn 1521: 'atta' => 'Attachment',
1.237 raeburn 1522: );
1.239 albertel 1523: my $restitle = &get_resource_title($caller_symb,$feedurl);
1.69 www 1524: my $quote='';
1.78 raeburn 1525: my $subject = '';
1.108 raeburn 1526: my $comment = '';
1.80 raeburn 1527: my $prevtag = '';
1.102 raeburn 1528: my $parentmsg = '';
1.108 raeburn 1529: my ($symb,$idx,$attachmenturls);
1530: my $numoldver = 0;
1531: my $attachmsg = '';
1532: my $newattachmsg = '';
1533: my @currnewattach = ();
1534: my @currdelold = ();
1535: my @keepold = ();
1.113 raeburn 1536: my %attachments = ();
1.108 raeburn 1537: my %currattach = ();
1538: my $attachnum = 0;
1539: my $anonchk = (<<END);
1540: function anonchk() {
1.199 albertel 1541: for (var i=0; i < document.mailform.discuss.length; i++) {
1542: if (document.mailform.discuss[i].checked) {
1543: document.attachment.discuss.value =
1544: document.mailform.discuss[i].value;
1545: }
1.198 albertel 1546: }
1547: if (document.mailform.blog.checked) {
1548: document.attachment.blog.value = 1;
1549: }
1.108 raeburn 1550: return
1551: }
1552: END
1553: my $anonscript;
1.157 albertel 1554: if (exists($env{'form.origpage'})) {
1.108 raeburn 1555: $anonscript = (<<END);
1.102 raeburn 1556: function setposttype() {
1.198 albertel 1557: var disc = "$env{'form.discuss'}";
1.199 albertel 1558: for (var i=0; i < document.mailform.discuss.length; i++) {
1559: if (disc == document.mailform.discuss[i].value) {
1560: document.mailform.discuss[i].checked = 1;
1561: }
1.198 albertel 1562: }
1563: var blog = "$env{'form.blog'}";
1564: if (blog == 1) {
1565: document.mailform.blog.checked=1;
1.108 raeburn 1566: }
1.102 raeburn 1567: return
1568: }
1569: END
1.108 raeburn 1570: } else {
1571: $anonscript = (<<END);
1572: function setposttype() {
1573: return
1574: }
1575: END
1576: }
1.157 albertel 1577: if (($env{'form.replydisc'}) || ($env{'form.editdisc'})) {
1578: if ($env{'form.replydisc'}) {
1579: ($symb,$idx)=split(/\:\:\:/,$env{'form.replydisc'});
1.102 raeburn 1580: } else {
1.157 albertel 1581: ($symb,$idx)=split(/\:\:\:/,$env{'form.editdisc'});
1.102 raeburn 1582: }
1.157 albertel 1583: my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
1584: $env{'course.'.$env{'request.course.id'}.'.domain'},
1585: $env{'course.'.$env{'request.course.id'}.'.num'});
1.80 raeburn 1586: unless (($contrib{'hidden'}=~/\.$idx\./) || ($contrib{'deleted'}=~/\.$idx\./)) {
1.112 raeburn 1587: if ($contrib{$idx.':history'}) {
1588: if ($contrib{$idx.':history'} =~ /:/) {
1.221 raeburn 1589: my @oldversions = split(/:/,$contrib{$idx.':history'});
1.112 raeburn 1590: $numoldver = @oldversions;
1591: } else {
1592: $numoldver = 1;
1593: }
1594: }
1.157 albertel 1595: if ($env{'form.replydisc'}) {
1.102 raeburn 1596: if ($contrib{$idx.':history'}) {
1597: if ($contrib{$idx.':history'} =~ /:/) {
1.221 raeburn 1598: my @oldversions = split(/:/,$contrib{$idx.':history'});
1.102 raeburn 1599: $numoldver = @oldversions;
1600: } else {
1601: $numoldver = 1;
1602: }
1603: }
1.108 raeburn 1604: if ($idx > 0) {
1.116 raeburn 1605: my %msgversions = ();
1606: &get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver);
1.218 albertel 1607: $quote = $msgversions{$numoldver};
1.108 raeburn 1608: }
1.102 raeburn 1609: if ($idx > 0) {
1.116 raeburn 1610: my %subversions = ();
1611: &get_post_versions(\%subversions,$contrib{$idx.':subject'},1,$numoldver);
1.224 raeburn 1612: $subject = &mt('Re: ').$subversions{$numoldver};
1.102 raeburn 1613: }
1.108 raeburn 1614: $subject = &HTML::Entities::encode($subject,'<>&"');
1.102 raeburn 1615: } else {
1.108 raeburn 1616: $attachmenturls = $contrib{$idx.':attachmenturl'};
1.116 raeburn 1617: if ($idx > 0) {
1618: my %msgversions = ();
1619: &get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver);
1620: $comment = $msgversions{$numoldver};
1621: my %subversions = ();
1622: &get_post_versions(\%subversions,$contrib{$idx.':subject'},0,$numoldver);
1623: $subject = $subversions{$numoldver};
1.102 raeburn 1624: }
1625: if (defined($contrib{$idx.':replyto'})) {
1626: $parentmsg = $contrib{$idx.':replyto'};
1627: }
1.157 albertel 1628: unless (exists($env{'form.origpage'})) {
1.203 albertel 1629: my $anonflag = 'nonanon';
1.108 raeburn 1630: if ($contrib{$idx.':anonymous'}) {
1.203 albertel 1631: $anonflag = 'anon';
1.108 raeburn 1632: }
1633: $anonscript = (<<END);
1.102 raeburn 1634: function setposttype () {
1.203 albertel 1635: var currtype = "$anonflag";
1636: for (var i=0; i<document.mailform.discuss.length; i++) {
1637: if (document.mailform.elements.discuss[i].value == currtype ) {
1638: document.mailform.elements.discuss[i].checked=1;
1639: }
1.102 raeburn 1640: }
1641: return
1642: }
1643: END
1.108 raeburn 1644: }
1.79 raeburn 1645: }
1.69 www 1646: }
1.157 albertel 1647: if ($env{'form.previous'}) {
1648: $prevtag = '<input type="hidden" name="previous" value="'.$env{'form.previous'}.'" />';
1.80 raeburn 1649: }
1.69 www 1650: }
1.108 raeburn 1651:
1.157 albertel 1652: if ($env{'form.origpage'}) {
1.204 www 1653: $subject = &unescape($env{'form.subject'});
1654: $comment = &unescape($env{'form.comment'});
1.108 raeburn 1655: &process_attachments(\@currnewattach,\@currdelold,\@keepold);
1656: }
1.311 ! www 1657: my $latexHelp=&Apache::loncommon::helpLatexCheatsheet(undef,undef,1,'popup');
1.74 www 1658: my $send=&mt('Send');
1.220 raeburn 1659: my $alert = &mt('Please select a feedback type.');
1.186 albertel 1660: my $js= <<END;
1.63 albertel 1661: <script type="text/javascript">
1662: //<!--
1.5 www 1663: function gosubmit() {
1664: var rec=0;
1.12 albertel 1665: if (typeof(document.mailform.elements.discuss)!="undefined") {
1.203 albertel 1666: if (typeof(document.mailform.elements.discuss.length) == "undefined") {
1667: if (document.mailform.elements.discuss.checked ) {
1.202 albertel 1668: rec=1;
1669: }
1670: } else {
1.203 albertel 1671: for (var i=0; i<document.mailform.elements.discuss.length; i++) {
1672: if (document.mailform.elements.discuss[i].checked ) {
1.202 albertel 1673: rec=1;
1674: }
1675: }
1676: }
1677: }
1.175 www 1678: if (typeof(document.mailform.elements.blog)!="undefined") {
1.203 albertel 1679: if (document.mailform.elements.blog.checked) {
1.175 www 1680: rec=1;
1681: }
1682: }
1.5 www 1683:
1684: if (rec) {
1.118 albertel 1685: if (typeof(document.mailform.onsubmit)=='function') {
1.105 www 1686: document.mailform.onsubmit();
1687: }
1.5 www 1688: document.mailform.submit();
1689: } else {
1.220 raeburn 1690: alert('$alert');
1.5 www 1691: }
1692: }
1.108 raeburn 1693: $anonchk
1.102 raeburn 1694: $anonscript
1.63 albertel 1695: //-->
1.5 www 1696: </script>
1.186 albertel 1697: END
1698:
1.297 raeburn 1699: my ($textareaheader,$textareaclass);
1700: if (&Apache::lonhtmlcommon::htmlareabrowser()) {
1701: $textareaheader = &Apache::lonhtmlcommon::htmlareaselectactive();
1702: $textareaclass = 'class="LC_richDefaultOff"';
1.301 raeburn 1703: if ($env{'request.course.id'}) {
1704: unless (($env{'course.'.$env{'request.course.id'}.'.allow_limited_html_in_feedback'} =~ /^\s*yes\s*$/i) || ($env{'form.sendmessageonly'})) {
1705: undef($textareaclass);
1706: }
1707: }
1.297 raeburn 1708: }
1709:
1.276 bisitz 1710: # Breadcrumbs
1711: my $brcrum = [{'href' => '',
1712: 'text' => 'Resource Feedback and Discussion'}];
1713:
1.189 albertel 1714: my %onload = ('onload' => 'window.focus();setposttype();');
1.306 www 1715: my %parms=('add_entries' => \%onload);
1716: if ($env{'form.modal'} ne 'yes') { 'bread_crumbs' => $brcrum }
1.186 albertel 1717: my $start_page=
1.306 www 1718: &Apache::loncommon::start_page('Resource Feedback and Discussion',$js,\%parms);
1.186 albertel 1719:
1.218 albertel 1720: if ($quote ne '') {
1.286 raeburn 1721: $quote = &HTML::Entities::decode($quote);
1722: unless (&contains_block_html($quote)) {
1723: &newline_to_br(\$quote);
1724: }
1.218 albertel 1725: $quote='<blockquote>'.&Apache::lontexconvert::msgtexconverted($quote).'</blockquote>';
1726: }
1.309 www 1727: my $header='';
1728: unless ($env{'form.modal'}) {
1729: $header="<h2><tt>$restitle</tt></h2>";
1730: }
1.186 albertel 1731: $r->print(<<END);
1732: $start_page
1.309 www 1733: $header
1.43 www 1734: <form action="/adm/feedback" method="post" name="mailform"
1735: enctype="multipart/form-data">
1.80 raeburn 1736: $prevtag
1.63 albertel 1737: <input type="hidden" name="postdata" value="$feedurl" />
1.306 www 1738: <input type="hidden" name="modal" value="$env{'form.modal'}" />
1.102 raeburn 1739: END
1.157 albertel 1740: if ($env{'form.replydisc'}) {
1.102 raeburn 1741: $r->print(<<END);
1.157 albertel 1742: <input type="hidden" name="replydisc" value="$env{'form.replydisc'}" />
1.102 raeburn 1743: END
1.157 albertel 1744: } elsif ($env{'form.editdisc'}) {
1.102 raeburn 1745: $r->print(<<END);
1.271 bisitz 1746: <input type="hidden" name="editdisc" value="$env{'form.editdisc'}" />
1747: <input type="hidden" name="parentmsg" value="$parentmsg" />
1.102 raeburn 1748: END
1749: }
1.108 raeburn 1750: $r->print(<<END);
1.309 www 1751: $options
1.69 www 1752: $quote
1.297 raeburn 1753: <p>$lt{'myqu'}
1754: $textareaheader
1755: </p>
1.63 albertel 1756: <p>
1.47 bowersj2 1757: $latexHelp
1.267 bisitz 1758: </p>
1759: <p>
1.220 raeburn 1760: $lt{'title'}: <input type="text" name="subject" size="30" value="$subject" /></p>
1.78 raeburn 1761: <p>
1.297 raeburn 1762: <textarea name="comment" id="comment" cols="60" rows="10" $textareaclass>$comment
1.63 albertel 1763: </textarea></p>
1.108 raeburn 1764: END
1.157 albertel 1765: if ( ($env{'form.editdisc'}) || ($env{'form.replydisc'}) ) {
1766: if ($env{'form.origpage'}) {
1.221 raeburn 1767: foreach my $attach (@currnewattach) {
1768: $r->print('<input type="hidden" name="currnewattach" value="'.$attach.'" />'."\n");
1.108 raeburn 1769: }
1.221 raeburn 1770: foreach my $oldatt (@currdelold) {
1771: $r->print('<input type="hidden" name="deloldattach" value="'.$oldatt.'" />'."\n");
1.108 raeburn 1772: }
1773: }
1.157 albertel 1774: if ($env{'form.editdisc'}) {
1.108 raeburn 1775: if ($attachmenturls) {
1.113 raeburn 1776: &extract_attachments($attachmenturls,$idx,$numoldver,\$attachmsg,\%attachments,\%currattach,\@currdelold);
1.221 raeburn 1777: $attachnum = scalar(keys(%currattach));
1778: foreach my $key (keys(%currattach)) {
1779: $r->print('<input type="hidden" name="keepold" value="'.$key.'" />'."\n");
1.108 raeburn 1780: }
1781: }
1782: }
1783: } else {
1784: $r->print(<<END);
1.285 raeburn 1785: <p>
1.255 raeburn 1786: $lt{'atta'} $attachmaxtext: <input type="file" name="attachment" />
1.42 www 1787: </p>
1.108 raeburn 1788: END
1789: }
1.208 raeburn 1790: if (exists($env{'form.group'})) {
1791: $r->print('<input type="hidden" name="group" value="'.$env{'form.group'}.'" />');
1792: }
1793: if (exists($env{'form.ref'})) {
1794: $r->print('<input type="hidden" name="ref" value="'.$env{'form.ref'}.'" />');
1795: }
1.108 raeburn 1796: $r->print(<<END);
1.42 www 1797: <p>
1798: <input type="hidden" name="sendit" value="1" />
1.282 wenzelju 1799: <input type="button" value="$send" onclick='gosubmit();' />
1.42 www 1800: </p>
1.2 www 1801: </form>
1.108 raeburn 1802: END
1.157 albertel 1803: if ($env{'form.editdisc'} || $env{'form.replydisc'}) {
1.108 raeburn 1804: my $now = time;
1805: my $ressymb = $symb;
1.233 raeburn 1806: &Apache::lonenc::check_encrypt(\$ressymb);
1.108 raeburn 1807: my $postidx = '';
1.157 albertel 1808: if ($env{'form.editdisc'}) {
1.108 raeburn 1809: $postidx = $idx;
1810: }
1811: if (@currnewattach > 0) {
1812: $attachnum += @currnewattach;
1813: }
1.235 raeburn 1814: my $blockblog = &Apache::loncommon::blocking_status('blogs');
1.224 raeburn 1815: $r->print(&generate_attachments_button($postidx,$attachnum,$ressymb,$now,\@currnewattach,\@currdelold,$numoldver,'',$blockblog));
1.108 raeburn 1816: if ($attachnum > 0) {
1817: if (@currnewattach > 0) {
1.220 raeburn 1818: $newattachmsg .= '<br /><b>'.&mt('New attachments').'</b><br />';
1.108 raeburn 1819: if (@currnewattach > 1) {
1820: $newattachmsg .= '<ol>';
1821: foreach my $item (@currnewattach) {
1822: $item =~ m#.*/([^/]+)$#;
1823: $newattachmsg .= '<li><a href="'.$item.'">'.$1.'</a></li>'."\n";
1824: }
1825: $newattachmsg .= '</ol>'."\n";
1826: } else {
1827: $currnewattach[0] =~ m#.*/([^/]+)$#;
1828: $newattachmsg .= '<a href="'.$currnewattach[0].'">'.$1.'</a><br />'."\n";
1829: }
1830: }
1831: if ($attachmsg) {
1.220 raeburn 1832: $r->print("<br /><b>$lt{'reta'}</b>:$attachmsg<br />\n");
1.108 raeburn 1833: }
1834: if ($newattachmsg) {
1835: $r->print("$newattachmsg<br />");
1836: }
1837: }
1838: }
1839: $r->print(&generate_preview_button().
1.186 albertel 1840: &Apache::loncommon::end_page());
1841:
1.6 albertel 1842: }
1843:
1.97 raeburn 1844: sub print_display_options {
1.111 raeburn 1845: my ($r,$symb,$previous,$dispchgA,$dispchgB,$markchg,$toggchg,$feedurl) = @_;
1.135 albertel 1846: &Apache::loncommon::content_type($r,'text/html');
1847: $r->send_http_header;
1.98 raeburn 1848:
1.97 raeburn 1849: my $function = &Apache::loncommon::get_users_function();
1850: my $tabcolor = &Apache::loncommon::designparm($function.'.tabbg',
1.157 albertel 1851: $env{'user.domain'});
1.97 raeburn 1852:
1853: my %lt = &Apache::lonlocal::texthash(
1854: 'pref' => 'Display Preference',
1855: 'curr' => 'Current setting ',
1856: 'actn' => 'Action',
1857: 'deff' => 'Default for all discussions',
1858: 'prca' => 'Preferences can be set for this discussion that determine ....',
1.264 schafran 1859: 'whpo' => 'Which posts are displayed when you display this discussion board or resource, and',
1.111 raeburn 1860: 'unwh' => 'Under what circumstances posts are identified as "NEW", and',
1861: 'wipa' => 'Whether individual posts can be marked as read/unread',
1.97 raeburn 1862: 'allposts' => 'All posts',
1863: 'unread' => 'New posts only',
1.111 raeburn 1864: 'unmark' => 'Posts not marked read',
1.97 raeburn 1865: 'ondisp' => 'Once displayed',
1.254 bisitz 1866: 'onmark' => 'Once marked not NEW',
1.111 raeburn 1867: 'toggon' => 'Shown',
1868: 'toggoff' => 'Not shown',
1.97 raeburn 1869: 'disa' => 'Posts displayed?',
1.111 raeburn 1870: 'npmr' => 'New posts cease to be identified as "NEW"?',
1871: 'dotm' => 'Option to mark each post as read/unread?',
1.97 raeburn 1872: 'chgt' => 'Change to ',
1873: 'mkdf' => 'Set to ',
1.111 raeburn 1874: 'yhni' => 'You have not indicated that you wish to change any of the discussion settings',
1.97 raeburn 1875: 'ywbr' => 'You will be returned to the previous page if you click OK.'
1876: );
1877:
1.111 raeburn 1878: my $dispchangeA = $lt{'unread'};
1879: my $dispchangeB = $lt{'unmark'};
1.97 raeburn 1880: my $markchange = $lt{'ondisp'};
1.111 raeburn 1881: my $toggchange = $lt{'toggon'};
1.97 raeburn 1882: my $currdisp = $lt{'allposts'};
1883: my $currmark = $lt{'onmark'};
1884: my $discdisp = 'allposts';
1885: my $discmark = 'onmark';
1.111 raeburn 1886: my $currtogg = $lt{'toggoff'};
1887: my $disctogg = 'toggoff';
1.97 raeburn 1888:
1.111 raeburn 1889: if ($dispchgA eq 'allposts') {
1890: $dispchangeA = $lt{'allposts'};
1.97 raeburn 1891: $currdisp = $lt{'unread'};
1892: $discdisp = 'unread';
1893: }
1.111 raeburn 1894:
1.97 raeburn 1895: if ($markchg eq 'markonread') {
1896: $markchange = $lt{'onmark'};
1897: $currmark = $lt{'ondisp'};
1898: $discmark = 'ondisp';
1899: }
1.111 raeburn 1900:
1901: if ($dispchgB eq 'onlyunread') {
1902: $dispchangeB = $lt{'unread'};
1903: $currdisp = $lt{'unmark'};
1904: $discdisp = 'unmark';
1905: }
1906: if ($toggchg eq 'toggoff') {
1907: $toggchange = $lt{'toggoff'};
1908: $currtogg = $lt{'toggon'};
1909: $disctogg = 'toggon';
1910: }
1.187 albertel 1911:
1912: my $js = <<END;
1913: <script type="text/javascript">
1.111 raeburn 1914: function discdispChk(caller) {
1915: var disctogg = '$toggchg'
1916: if (caller == 0) {
1917: if (document.modifydisp.discdisp[0].checked == true) {
1918: if (document.modifydisp.discdisp[1].checked == true) {
1919: document.modifydisp.discdisp[1].checked = false
1920: }
1921: }
1922: }
1923: if (caller == 1) {
1924: if (document.modifydisp.discdisp[1].checked == true) {
1925: if (document.modifydisp.discdisp[0].checked == true) {
1926: document.modifydisp.discdisp[0].checked = false
1927: }
1928: if (disctogg == 'toggon') {
1929: document.modifydisp.disctogg.checked = true
1930: }
1931: if (disctogg == 'toggoff') {
1932: document.modifydisp.disctogg.checked = false
1933: }
1934: }
1935: }
1936: if (caller == 2) {
1937: var dispchgB = '$dispchgB'
1938: if (disctogg == 'toggoff') {
1939: if (document.modifydisp.disctogg.checked == true) {
1940: if (dispchgB == 'onlyunmark') {
1941: document.modifydisp.discdisp[1].checked = false
1942: }
1943: }
1944: }
1945: }
1946: }
1947:
1.97 raeburn 1948: function setDisp() {
1949: var prev = "$previous"
1950: var chktotal = 0
1.111 raeburn 1951: if (document.modifydisp.discdisp[0].checked == true) {
1952: document.modifydisp.$dispchgA.value = "$symb"
1953: chktotal ++
1954: }
1955: if (document.modifydisp.discdisp[1].checked == true) {
1956: document.modifydisp.$dispchgB.value = "$symb"
1.97 raeburn 1957: chktotal ++
1958: }
1959: if (document.modifydisp.discmark.checked == true) {
1960: document.modifydisp.$markchg.value = "$symb"
1961: chktotal ++
1962: }
1.111 raeburn 1963: if (document.modifydisp.disctogg.checked == true) {
1964: document.modifydisp.$toggchg.value = "$symb"
1965: chktotal ++
1966: }
1.97 raeburn 1967: if (chktotal > 0) {
1968: document.modifydisp.submit()
1969: } else {
1970: if(confirm("$lt{'yhni'}. \\n$lt{'ywbr'}")) {
1971: if (prev > 0) {
1972: location.href = "$feedurl?previous=$previous"
1973: } else {
1974: location.href = "$feedurl"
1975: }
1976: }
1977: }
1978: }
1979: </script>
1.187 albertel 1980: END
1981:
1982:
1983: my $start_page =
1984: &Apache::loncommon::start_page('Discussion display options',$js);
1985: my $end_page =
1986: &Apache::loncommon::end_page();
1987: $r->print(<<END);
1.192 albertel 1988: $start_page
1.273 bisitz 1989: <form name="modifydisp" method="post" action="/adm/feedback">
1.111 raeburn 1990: $lt{'sdpf'}<br/> $lt{'prca'} <ol><li>$lt{'whpo'}</li><li>$lt{'unwh'}</li><li>$lt{'wipa'}</li></ol>
1.97 raeburn 1991: <br />
1.195 albertel 1992: END
1993: $r->print(&Apache::loncommon::start_data_table());
1994: $r->print(<<END);
1995: <tr>
1996: <th>$lt{'pref'}</td>
1997: <th>$lt{'curr'}</td>
1998: <th>$lt{'actn'}?</td>
1.97 raeburn 1999: </tr>
1.195 albertel 2000: END
2001: $r->print(&Apache::loncommon::start_data_table_row());
2002: $r->print(<<END);
1.97 raeburn 2003: <td>$lt{'disa'}</td>
2004: <td>$lt{$discdisp}</td>
1.282 wenzelju 2005: <td><label><input type="checkbox" name="discdisp" onclick="discdispChk('0')" /> $lt{'chgt'} "$dispchangeA"</label>
1.111 raeburn 2006: <br />
1.282 wenzelju 2007: <label><input type="checkbox" name="discdisp" onclick="discdispChk('1')" /> $lt{'chgt'} "$dispchangeB"</label>
1.111 raeburn 2008: </td>
1.195 albertel 2009: END
2010: $r->print(&Apache::loncommon::end_data_table_row());
2011: $r->print(&Apache::loncommon::start_data_table_row());
2012: $r->print(<<END);
1.97 raeburn 2013: <td>$lt{'npmr'}</td>
2014: <td>$lt{$discmark}</td>
1.151 albertel 2015: <td><label><input type="checkbox" name="discmark" />$lt{'chgt'} "$markchange"</label></td>
1.195 albertel 2016: END
2017: $r->print(&Apache::loncommon::end_data_table_row());
2018: $r->print(&Apache::loncommon::start_data_table_row());
2019: $r->print(<<END);
1.111 raeburn 2020: <td>$lt{'dotm'}</td>
2021: <td>$lt{$disctogg}</td>
1.282 wenzelju 2022: <td><label><input type="checkbox" name="disctogg" onclick="discdispChk('2')" />$lt{'chgt'} "$toggchange"</label></td>
1.195 albertel 2023: END
1.264 schafran 2024: my $save = &mt('Save');
1.195 albertel 2025: $r->print(&Apache::loncommon::end_data_table_row());
2026: $r->print(&Apache::loncommon::end_data_table());
2027: $r->print(<<END);
1.97 raeburn 2028: <br />
2029: <br />
1.137 albertel 2030: <input type="hidden" name="symb" value="$symb" />
1.97 raeburn 2031: <input type="hidden" name="previous" value="$previous" />
1.269 bisitz 2032: <input type="hidden" name="$dispchgA" value="" />
2033: <input type="hidden" name="$dispchgB" value="" />
2034: <input type="hidden" name="$markchg" value="" />
1.111 raeburn 2035: <input type="hidden" name="$toggchg" value="" />
1.282 wenzelju 2036: <input type="button" name="sub" value="$save" onclick="javascript:setDisp()" />
1.208 raeburn 2037: END
2038: if (exists($env{'form.group'})) {
2039: $r->print('<input type="hidden" name="group" value="'.$env{'form.group'}.'" />');
2040: }
2041: if (exists($env{'form.ref'})) {
2042: $r->print('<input type="hidden" name="ref" value="'.$env{'form.ref'}.'" />');
2043: }
2044: $r->print("
1.97 raeburn 2045: <br />
2046: <br />
2047: </form>
1.187 albertel 2048: $end_page
1.208 raeburn 2049: ");
1.97 raeburn 2050: return;
2051: }
2052:
1.100 raeburn 2053: sub print_sortfilter_options {
2054: my ($r,$symb,$previous,$feedurl) = @_;
1.133 albertel 2055:
1.135 albertel 2056: &Apache::loncommon::content_type($r,'text/html');
2057: $r->send_http_header;
2058:
1.139 albertel 2059: &Apache::lonenc::check_encrypt(\$symb);
1.197 albertel 2060: my @sections;
1.100 raeburn 2061: my $section_sel = '';
2062: my $numvisible = 5;
1.208 raeburn 2063: my @groups;
2064: my $group_sel = '';
2065: my $numgroupvis = 5;
1.197 albertel 2066: my %sectioncount = &Apache::loncommon::get_sections();
1.278 raeburn 2067: my @courseroles = qw(st ad ep ta in);
2068: my $crstype = &Apache::loncommon::course_type();
2069: my $ccrole = 'cc';
2070: if ($crstype eq 'Community') {
2071: $ccrole = 'co';
2072: }
2073: push(@courseroles,$ccrole);
2074:
1.157 albertel 2075: if ($env{'request.course.sec'} !~ /^\s*$/) { #Restrict section choice to current section
2076: @sections = ('all',$env{'request.course.sec'});
1.144 raeburn 2077: $numvisible = 2;
1.100 raeburn 2078: } else {
2079: @sections = sort {$a cmp $b} keys(%sectioncount);
1.197 albertel 2080: if (scalar(@sections) < 4) {
2081: $numvisible = scalar(@sections) + 1;
2082: }
1.100 raeburn 2083: unshift(@sections,'all'); # Put 'all' at the front of the list
1.197 albertel 2084:
1.100 raeburn 2085: }
1.212 albertel 2086: foreach my $sec (@sections) {
2087: $section_sel .= " <option value=\"$sec\">$sec</option>\n";
1.100 raeburn 2088: }
1.208 raeburn 2089:
2090: if (&check_group_priv() eq 'ok') {
2091: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2092: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2093: my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
2094: @groups = sort {$a cmp $b} keys(%curr_groups);
2095: if (scalar(@groups) < 4) {
2096: $numgroupvis = scalar(@groups) + 1;
2097: }
2098: unshift(@groups,'all'); # Put 'all' at the front of the list
2099: } else {
2100: my @coursegroups = split(/:/,$env{'request.course.groups'});
2101: if (@coursegroups > 0) {
2102: @coursegroups = sort {$a cmp $b} @coursegroups;
2103: @groups = ('all',@coursegroups);
2104: if (scalar(@groups) < 4) {
2105: $numgroupvis = scalar(@groups) + 1;
2106: }
2107: } else {
2108: @groups = ('all');
2109: $numgroupvis = 1;
2110: }
2111: }
1.212 albertel 2112: foreach my $group (@groups) {
2113: $group_sel .= " <option value=\"$group\">$group</option>\n";
1.208 raeburn 2114: }
2115:
1.100 raeburn 2116: my $function = &Apache::loncommon::get_users_function();
2117: my $tabcolor = &Apache::loncommon::designparm($function.'.tabbg',
1.157 albertel 2118: $env{'user.domain'});
1.100 raeburn 2119: my %lt = &Apache::lonlocal::texthash(
2120: 'diop' => 'Display Options',
2121: 'curr' => 'Current setting ',
2122: 'actn' => 'Action',
1.143 raeburn 2123: 'prca' => 'Set options that control the sort order of posts, and/or which posts are displayed.',
1.100 raeburn 2124: 'soor' => 'Sort order',
1.143 raeburn 2125: 'spur' => 'Specific user roles',
2126: 'sprs' => 'Specific role status',
1.100 raeburn 2127: 'spse' => 'Specific sections',
1.208 raeburn 2128: 'spgr' => 'Specific groups',
1.100 raeburn 2129: 'psub' => 'Pick specific users (by name)',
1.220 raeburn 2130: 'shal' => 'Show a list of current posters',
1.247 albertel 2131: 'stor' => 'Save changes',
1.100 raeburn 2132: );
1.143 raeburn 2133:
2134: my %sort_types = ();
2135: my %role_types = ();
2136: my %status_types = ();
1.278 raeburn 2137: &sort_filter_names(\%sort_types,\%role_types,\%status_types,$crstype);
1.187 albertel 2138:
2139: my $js = <<END;
1.144 raeburn 2140: <script type="text/javascript">
2141: function verifyFilter() {
2142: var rolenum = 0
2143: for (var i=0; i<document.modifyshown.rolefilter.length; i++) {
2144: if (document.modifyshown.rolefilter.options[i].selected == true) {
2145: rolenum ++
2146: }
2147: }
2148: if (rolenum == 0) {
2149: document.modifyshown.rolefilter.options[0].selected = true
2150: }
2151:
2152: var secnum = 0
2153: for (var i=0; i<document.modifyshown.sectionpick.length; i++) {
2154: if (document.modifyshown.sectionpick.options[i].selected == true) {
2155: secnum ++
2156: }
2157: }
2158: if (secnum == 0) {
2159: document.modifyshown.sectionpick.options[0].selected = true
2160: }
1.208 raeburn 2161:
2162: var grpnum = 0
2163: for (var i=0; i<document.modifyshown.grouppick.length; i++) {
2164: if (document.modifyshown.grouppick.options[i].selected == true) {
2165: grpnum ++
2166: }
2167: }
2168: if (grpnum == 0) {
2169: document.modifyshown.grouppick.options[0].selected = true
2170: }
2171:
1.144 raeburn 2172: document.modifyshown.submit();
2173: }
2174: </script>
1.187 albertel 2175: END
2176:
2177: my $start_page=
2178: &Apache::loncommon::start_page('Discussion options',$js);
2179: my $end_page=
2180: &Apache::loncommon::end_page();
2181:
2182: $r->print(<<END);
2183: $start_page
1.273 bisitz 2184: <form name="modifyshown" method="post" action="/adm/feedback">
1.100 raeburn 2185: <b>$lt{'diso'}</b><br/> $lt{'prca'}
2186: <br /><br />
2187: <table border="0">
2188: <tr>
1.281 bisitz 2189: <th>$lt{'soor'}</th>
2190: <th> </th>
2191: <th>$lt{'sprs'}</th>
2192: <th> </th>
2193: <th>$lt{'spur'}</th>
2194: <th> </th>
2195: <th>$lt{'spse'}</th>
2196: <th> </th>
2197: <th>$lt{'spgr'}</th>
2198: <th> </th>
2199: <th>$lt{'psub'}</th>
1.100 raeburn 2200: </tr>
2201: <tr>
1.208 raeburn 2202: <td align="center" valign="top">
1.100 raeburn 2203: <select name="sortposts">
1.212 albertel 2204: <option value="ascdate" selected="selected">$sort_types{'ascdate'}</option>
2205: <option value="descdate">$sort_types{'descdate'}</option>
2206: <option value="thread">$sort_types{'thread'}</option>
2207: <option value="subject">$sort_types{'subject'}</option>
2208: <option value="username">$sort_types{'username'}</option>
2209: <option value="lastfirst">$sort_types{'lastfirst'}</option>
1.100 raeburn 2210: </select>
2211: </td>
2212: <td> </td>
1.208 raeburn 2213: <td align="center" valign="top">
1.143 raeburn 2214: <select name="statusfilter">
1.215 albertel 2215: <option value="all" selected="selected">$status_types{'all'}</option>
2216: <option value="Active">$status_types{'Active'}</option>
2217: <option value="Expired">$status_types{'Expired'}</option>
2218: <option value="Future">$status_types{'Future'}</option>
1.100 raeburn 2219: </select>
2220: </td>
2221: <td> </td>
1.208 raeburn 2222: <td align="center" valign="top">
1.262 bisitz 2223: <select name="rolefilter" multiple="multiple" size="5">
1.212 albertel 2224: <option value="all">$role_types{'all'}</option>
2225: <option value="st">$role_types{'st'}</option>
1.278 raeburn 2226: <option value="$ccrole">$role_types{$ccrole}</option>
1.212 albertel 2227: <option value="in">$role_types{'in'}</option>
2228: <option value="ta">$role_types{'ta'}</option>
2229: <option value="ep">$role_types{'ep'}</option>
1.278 raeburn 2230: <option value="ad">$role_types{'ad'}</option>
1.212 albertel 2231: <option value="cr">$role_types{'cr'}</option>
1.100 raeburn 2232: </select>
2233: </td>
2234: <td> </td>
1.208 raeburn 2235: <td align="center" valign="top">
1.262 bisitz 2236: <select name="sectionpick" multiple="multiple" size="$numvisible">
1.100 raeburn 2237: $section_sel
2238: </select>
2239: </td>
2240: <td> </td>
1.208 raeburn 2241: <td align="center" valign="top">
1.262 bisitz 2242: <select name="grouppick" multiple="multiple" size="$numvisible">
1.208 raeburn 2243: $group_sel
2244: </select>
2245: </td>
2246: <td> </td>
2247: <td valign="top"><label><input type="checkbox" name="posterlist" value="$symb" />$lt{'shal'}</label></td>
1.100 raeburn 2248: </tr>
2249: </table>
2250: <br />
2251: <br />
2252: <input type="hidden" name="previous" value="$previous" />
2253: <input type="hidden" name="applysort" value="$symb" />
1.282 wenzelju 2254: <input type="button" name="sub" value="$lt{'stor'}" onclick="verifyFilter()" />
1.208 raeburn 2255: END
2256: if (exists($env{'form.group'})) {
2257: $r->print('<input type="hidden" name="group" value="'.$env{'form.group'}.'" />');
2258: }
2259: if (exists($env{'form.ref'})) {
2260: $r->print('<input type="hidden" name="ref" value="'.$env{'form.ref'}.'" />');
2261: }
2262: $r->print("
1.100 raeburn 2263: <br />
2264: <br />
2265: </form>
1.187 albertel 2266: $end_page
1.208 raeburn 2267: ");
1.100 raeburn 2268: }
2269:
1.101 raeburn 2270: sub print_showposters {
2271: my ($r,$symb,$previous,$feedurl,$sortposts) = @_;
1.133 albertel 2272:
1.154 albertel 2273: &Apache::loncommon::content_type($r,'text/html');
2274: $r->send_http_header;
2275:
1.139 albertel 2276: &Apache::lonenc::check_encrypt(\$symb);
1.157 albertel 2277: my $crs='/'.$env{'request.course.id'};
2278: if ($env{'request.course.sec'}) {
2279: $crs.='_'.$env{'request.course.sec'};
1.102 raeburn 2280: }
1.101 raeburn 2281: $crs=~s/\_/\//g;
1.208 raeburn 2282: my $seeid;
2283: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2284: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2285: my $group = $env{'form.group'};
2286: my $ressymb = &wrap_symb($symb);
2287: if (($group ne '') &&
1.304 raeburn 2288: ($ressymb =~ m|^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$|)) {
1.208 raeburn 2289: if (&check_group_priv($group,'dgp') eq 'ok') {
2290: $seeid = 1;
2291: }
2292: } else {
2293: $seeid=&Apache::lonnet::allowed('rin',$crs);
2294: }
1.157 albertel 2295: my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
1.208 raeburn 2296: $cdom,$cnum);
1.101 raeburn 2297: my %namesort = ();
2298: my %postcounts = ();
1.186 albertel 2299:
1.208 raeburn 2300: my %lt = &Apache::lonlocal::texthash(
2301: sele => 'Select',
2302: full => 'Fullname',
1.220 raeburn 2303: usdo => 'Username:domain',
1.208 raeburn 2304: post => 'Posts',
2305: );
1.101 raeburn 2306: if ($contrib{'version'}) {
2307: for (my $idx=1;$idx<=$contrib{'version'};$idx++) {
2308: my $hidden=($contrib{'hidden'}=~/\.$idx\./);
2309: my $deleted=($contrib{'deleted'}=~/\.$idx\./);
2310: unless ((($hidden) && (!$seeid)) || ($deleted)) {
1.208 raeburn 2311: if ((!$contrib{$idx.':anonymous'}) || (&Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')))) {
1.101 raeburn 2312: my %names = &Apache::lonnet::get('environment',['firstname','lastname'],$contrib{$idx.':senderdomain'},$contrib{$idx.':sendername'});
2313: my $lastname = $names{'lastname'};
2314: my $firstname = $names{'firstname'};
2315: if ($lastname eq '') {
2316: $lastname = '_';
2317: }
2318: if ($firstname eq '') {
2319: $firstname = '_';
2320: }
2321: unless (defined($namesort{$lastname})) {
2322: %{$namesort{$lastname}} = ();
2323: }
2324: my $poster = $contrib{$idx.':sendername'}.':'.$contrib{$idx.':senderdomain'};
2325: $postcounts{$poster} ++;
2326: if (defined($namesort{$lastname}{$firstname})) {
2327: if (!grep/^$poster$/,@{$namesort{$lastname}{$firstname}}) {
1.221 raeburn 2328: push(@{$namesort{$lastname}{$firstname}}, $poster);
1.101 raeburn 2329: }
2330: } else {
2331: @{$namesort{$lastname}{$firstname}} = ("$poster");
2332: }
2333: }
2334: }
2335: }
2336: }
1.186 albertel 2337:
2338: my $start_page = &Apache::loncommon::start_page('Discussion options');
1.196 albertel 2339: my $table_start =&Apache::loncommon::start_data_table();
1.101 raeburn 2340: $r->print(<<END);
1.186 albertel 2341: $start_page
1.101 raeburn 2342: <form name="pickpostersform" method="post">
1.196 albertel 2343: <br />
2344: $table_start
2345: <tr>
1.208 raeburn 2346: <th>#</th>
2347: <th>$lt{'sele'}</th>
2348: <th>$lt{'full'} <font color="#999999">($lt{'usdo'})</font></th>
2349: <th>$lt{'post'}</th>
1.101 raeburn 2350: </tr>
2351: END
2352: my $count = 0;
1.221 raeburn 2353: foreach my $last (sort(keys(%namesort))) {
2354: foreach my $first (sort(keys(%{$namesort{$last}}))) {
2355: foreach my $user (sort(@{$namesort{$last}{$first}})) {
2356: my ($uname,$udom) = split(/:/,$user);
1.101 raeburn 2357: if (!$uname || !$udom) {
2358: next;
2359: } else {
2360: $count ++;
1.196 albertel 2361: $r->print(&Apache::loncommon::start_data_table_row().
2362: '<td align="right">'.$count.'</td>
1.221 raeburn 2363: <td align="center"><label><input name="stuinfo" type="checkbox" value="'.$user.'" /></td>
1.220 raeburn 2364: <td>'.$last.', '.$first.' ('.$uname.':'.$udom.')</label></td>
1.221 raeburn 2365: <td>'.$postcounts{$user}.'</td>'.
1.196 albertel 2366: &Apache::loncommon::end_data_table_row());
1.101 raeburn 2367: }
2368: }
2369: }
2370: }
1.196 albertel 2371: $r->print(&Apache::loncommon::end_data_table());
1.186 albertel 2372: my $end_page = &Apache::loncommon::end_page();
1.101 raeburn 2373: $r->print(<<END);
2374: <br />
2375: <input type="hidden" name="sortposts" value="$sortposts" />
2376: <input type="hidden" name="userpick" value="$symb" />
1.282 wenzelju 2377: <input type="button" name="store" value="Display posts" onclick="javascript:document.pickpostersform.submit()" />
1.101 raeburn 2378: </form>
1.186 albertel 2379: $end_page
1.101 raeburn 2380: END
2381: }
2382:
1.112 raeburn 2383: sub get_post_versions {
1.116 raeburn 2384: my ($versions,$incoming,$htmldecode,$numver) = @_;
2385: if ($incoming =~ /^<version num="0">/) {
2386: my $p = HTML::LCParser->new(\$incoming);
1.186 albertel 2387: my $done = 0;
2388:
1.116 raeburn 2389: while ( (my $token = $p->get_tag("version")) && (!$done)) {
2390: my $num = $token->[1]{num};
2391: my $text = $p->get_text("/version");
2392: if (defined($numver)) {
2393: if ($num == $numver) {
2394: if ($htmldecode) {
2395: $text = &HTML::Entities::decode($text);
2396: }
2397: $$versions{$numver}=$text;
2398: $done = 1;
2399: }
2400: } else {
2401: if ($htmldecode) {
2402: $text = &HTML::Entities::decode($text);
2403: }
2404: $$versions{$num}=$text;
1.112 raeburn 2405: }
1.116 raeburn 2406: }
2407: } else {
2408: if (!defined($numver)) {
2409: $numver = 0;
2410: }
2411: if ($htmldecode) {
2412: $$versions{$numver} = $incoming;
1.112 raeburn 2413: } else {
1.116 raeburn 2414: $$versions{$numver} = &HTML::Entities::encode($incoming,'<>&"');
1.112 raeburn 2415: }
2416: }
2417: return;
2418: }
2419:
1.113 raeburn 2420: sub get_post_attachments {
2421: my ($attachments,$attachmenturls) = @_;
2422: my $num;
1.116 raeburn 2423: if ($attachmenturls =~ m/^<attachment id="0">/) {
2424: my $p = HTML::LCParser->new(\$attachmenturls);
2425: while (my $token = $p->get_tag("attachment","filename","post")) {
2426: if ($token->[0] eq "attachment") {
2427: $num = $token->[1]{id};
2428: %{$$attachments{$num}} =();
2429: } elsif ($token->[0] eq "filename") {
2430: $$attachments{$num}{'filename'} = $p->get_text("/filename");
2431: } elsif ($token->[0] eq "post") {
2432: my $id = $token->[1]{id};
2433: $$attachments{$num}{$id} = $p->get_text("/post");
2434: }
1.113 raeburn 2435: }
1.116 raeburn 2436: } else {
2437: %{$$attachments{'0'}} = ();
2438: $$attachments{'0'}{'filename'} = $attachmenturls;
2439: $$attachments{'0'}{'0'} = 'n';
1.113 raeburn 2440: }
1.116 raeburn 2441:
1.113 raeburn 2442: return;
2443: }
2444:
1.150 albertel 2445: sub fail_redirect {
1.6 albertel 2446: my ($r,$feedurl) = @_;
1.70 www 2447: if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' };
1.220 raeburn 2448: my %lt = &Apache::lonlocal::texthash(
1.289 bisitz 2449: 'sorr' => 'Sorry, no recipients ...',
1.220 raeburn 2450: );
1.150 albertel 2451: my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif');
1.186 albertel 2452: $r->print(&Apache::loncommon::start_page('Feedback not sent',undef,
2453: {'redirect' => [2,$feedurl],
2454: 'only_body' => 1,}));
2455: $r->print(<<ENDFAILREDIR);
1.150 albertel 2456: <img align="right" src="$logo" />
1.220 raeburn 2457: <b>$lt{'sorr'}</b>
1.5 www 2458: ENDFAILREDIR
1.186 albertel 2459: $r->print(&Apache::loncommon::end_page());
1.5 www 2460: }
1.4 www 2461:
1.6 albertel 2462: sub redirect_back {
1.255 raeburn 2463: my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$blog,$status,$previous,$sort,$rolefilter,$statusfilter,$sectionpick,$grouppick,$numpicks,$group,$toolarge) = @_;
1.100 raeburn 2464: my $sorttag = '';
1.101 raeburn 2465: my $roletag = '';
2466: my $statustag = '';
2467: my $sectag = '';
1.208 raeburn 2468: my $grptag = '';
1.101 raeburn 2469: my $userpicktag = '';
2470: my $qrystr = '';
1.80 raeburn 2471: my $prevtag = '';
1.133 albertel 2472:
1.135 albertel 2473: &Apache::loncommon::content_type($r,'text/html');
2474: $r->send_http_header;
1.133 albertel 2475: &dewrapper(\$feedurl);
1.70 www 2476: if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' };
1.80 raeburn 2477: if ($previous > 0) {
2478: $qrystr = 'previous='.$previous;
2479: if ($feedurl =~ /\?register=1/) {
1.282 wenzelju 2480: $feedurl .= '&'.$qrystr;
1.80 raeburn 2481: } else {
2482: $feedurl .= '?'.$qrystr;
2483: }
2484: $prevtag = '<input type="hidden" name="previous" value="'.$previous.'" />';
2485: }
1.100 raeburn 2486: if (defined($sort)) {
2487: my $sortqry = 'sortposts='.$sort;
2488: if (($feedurl =~ /\?register=1/) || ($feedurl =~ /\?previous=/)) {
1.282 wenzelju 2489: $feedurl .= '&'.$sortqry;
1.100 raeburn 2490: } else {
2491: $feedurl .= '?'.$sortqry;
2492: }
2493: $sorttag = '<input type="hidden" name="sortposts" value="'.$sort.'" />';
1.143 raeburn 2494: if (defined($numpicks)) {
1.101 raeburn 2495: my $userpickqry = 'totposters='.$numpicks;
1.282 wenzelju 2496: $feedurl .= '&'.$userpickqry;
1.101 raeburn 2497: $userpicktag = '<input type="hidden" name="totposters" value="'.$numpicks.'" />';
2498: } else {
1.143 raeburn 2499: if (ref($sectionpick) eq 'ARRAY') {
1.282 wenzelju 2500: $feedurl .= '&sectionpick=';
1.143 raeburn 2501: $sectag .= '<input type="hidden" name="sectionpick" value="';
1.221 raeburn 2502: foreach my $sec (@{$sectionpick}) {
2503: $feedurl .= $sec.',';
2504: $sectag .= $sec.',';
1.143 raeburn 2505: }
2506: $feedurl =~ s/,$//;
2507: $sectag =~ s/,$//;
2508: $sectag .= '" />';
2509: } else {
1.282 wenzelju 2510: $feedurl .= '&sectionpick='.$sectionpick;
1.143 raeburn 2511: $sectag = '<input type="hidden" name="sectionpick" value="'.$sectionpick.'" />';
2512: }
1.208 raeburn 2513: if (ref($grouppick) eq 'ARRAY') {
1.282 wenzelju 2514: $feedurl .= '&grouppick=';
1.208 raeburn 2515: $sectag .= '<input type="hidden" name="grouppick" value="';
2516: foreach my $grp (@{$grouppick}) {
2517: $feedurl .= $grp.',';
2518: $grptag .= $grp.',';
2519: }
2520: $feedurl =~ s/,$//;
2521: $grptag =~ s/,$//;
2522: $grptag .= '" />';
2523: } else {
1.282 wenzelju 2524: $feedurl .= '&grouppick='.$grouppick;
1.208 raeburn 2525: $grptag = '<input type="hidden" name="grouppick" value="'.$grouppick.'" />';
2526: }
1.143 raeburn 2527: if (ref($rolefilter) eq 'ARRAY') {
1.282 wenzelju 2528: $feedurl .= '&rolefilter=';
1.143 raeburn 2529: $roletag .= '<input type="hidden" name="rolefilter" value="';
1.221 raeburn 2530: foreach my $role (@{$rolefilter}) {
2531: $feedurl .= $role.',';
2532: $roletag .= $role.',';
1.143 raeburn 2533: }
2534: $feedurl =~ s/,$//;
2535: $roletag =~ s/,$//;
2536: $roletag .= '" />';
2537: } else {
1.282 wenzelju 2538: $feedurl .= '&rolefilter='.$rolefilter;
1.143 raeburn 2539: $roletag = '<input type="hidden" name="rolefilter" value="'.$rolefilter.'" />';
2540: }
1.282 wenzelju 2541: $feedurl .= '&statusfilter='.$statusfilter;
1.101 raeburn 2542: $statustag ='<input type="hidden" name="statusfilter" value="'.$statusfilter.'" />';
2543: }
1.100 raeburn 2544: }
1.208 raeburn 2545: my $grouptag;
2546: if ($group ne '') {
1.269 bisitz 2547: $grouptag = '<input type="hidden" name="group" value="'.$group.'" />';
2548: my $refarg;
1.208 raeburn 2549: if (exists($env{'form.ref'})) {
2550: $refarg = '&ref='.$env{'form.ref'};
2551: $grouptag .= '<input type="hidden" name="ref" value="'.$env{'form.ref'}.'" />';
2552: }
2553: if ($feedurl =~ /\?/) {
2554: $feedurl .= '&group='.$group.$refarg;
2555: } else {
2556: $feedurl .= '?group='.$group.$refarg;
2557: }
2558: }
1.233 raeburn 2559: &Apache::lonenc::check_encrypt(\$feedurl);
1.150 albertel 2560: my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif');
1.306 www 2561: my %parms=('only_body' => 1);
2562: if ($env{'form.modal'}) {
2563: $parms{'add_entries'}={'onLoad' => 'document.forms.reldt.submit()'};
2564: } else {
2565: $parms{'redirect'}=[0,$feedurl];
2566: }
1.186 albertel 2567: my $start_page=
1.306 www 2568: &Apache::loncommon::start_page('Feedback sent',undef,\%parms);
1.186 albertel 2569: my $end_page = &Apache::loncommon::end_page();
2570: $r->print(<<ENDREDIR);
2571: $start_page
1.150 albertel 2572: <img align="right" src="$logo" />
1.5 www 2573: $typestyle
1.32 albertel 2574: <b>Sent $sendsomething message(s), and $sendposts post(s).</b>
1.175 www 2575: $blog
1.255 raeburn 2576: $toolarge
1.63 albertel 2577: <font color="red">$status</font>
1.49 www 2578: <form name="reldt" action="$feedurl" target="loncapaclient">
1.80 raeburn 2579: $prevtag
1.100 raeburn 2580: $sorttag
1.101 raeburn 2581: $statustag
2582: $roletag
2583: $sectag
1.208 raeburn 2584: $grptag
1.101 raeburn 2585: $userpicktag
1.208 raeburn 2586: $grouptag
1.49 www 2587: </form>
1.186 albertel 2588: $end_page
1.2 www 2589: ENDREDIR
2590: }
1.6 albertel 2591:
2592: sub no_redirect_back {
2593: my ($r,$feedurl) = @_;
1.289 bisitz 2594: my $nofeed=&mt('Sorry, no feedback possible on this resource ...');
1.187 albertel 2595:
1.200 albertel 2596: my %onload;
2597:
1.187 albertel 2598: my %body_options = ('only_body' => 1,
1.191 albertel 2599: 'bgcolor' => '#FFFFFF',
1.200 albertel 2600: 'add_entries' => \%onload,);
1.187 albertel 2601:
2602: if ($feedurl !~ m{^/adm/feedback}) {
2603: $body_options{'rediect'} = [2,$feedurl];
1.7 albertel 2604: }
1.187 albertel 2605: my $start_page=
2606: &Apache::loncommon::start_page('Feedback not sent',undef,
2607: \%body_options);
2608:
2609: my $end_page = &Apache::loncommon::end_page();
2610:
1.233 raeburn 2611: &Apache::lonenc::check_encrypt(\$feedurl);
1.150 albertel 2612: my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif');
1.8 www 2613: $r->print (<<ENDNOREDIRTWO);
1.191 albertel 2614: $start_page
1.150 albertel 2615: <img align="right" src="$logo" />
1.107 www 2616: <b>$nofeed</b>
1.187 albertel 2617: <br />
2618: $end_page
1.8 www 2619: ENDNOREDIRTWO
1.2 www 2620: }
1.6 albertel 2621:
2622: sub screen_header {
1.303 raeburn 2623: my ($feedurl,$symb,$group) = @_;
1.278 raeburn 2624: my $crscontent = &mt('Question/Comment/Feedback about course content');
2625: my $crspolicy = &mt('Question/Comment/Feedback about course policy');
2626: my $contribdisc = &mt('Contribution to course discussion of resource');
2627: my $anoncontrib = &mt('Anonymous contribution to course discussion of resource');
2628: my $namevis = &mt('name only visible to course faculty');
2629: my $crstype;
2630: if ($env{'request.course.id'}) {
2631: $crstype = &Apache::loncommon::course_type();
2632: if ($crstype eq 'Community') {
2633: $crscontent = &mt('Question/Comment/Feedback about community content');
2634: $crspolicy = &mt('Question/Comment/Feedback about community policy');
2635: $contribdisc = &mt('Contribution to community discussion of resource');
2636: $anoncontrib = &mt('Anonymous contribution to community discussion of resource');
2637: $namevis = &mt('name only visible to community facilitators');
2638: }
2639: }
1.65 www 2640: my $msgoptions='';
2641: my $discussoptions='';
1.157 albertel 2642: unless (($env{'form.replydisc'}) || ($env{'form.editdisc'})) {
1.167 www 2643: if (($feedurl=~/^\/res\//) && ($feedurl!~/^\/res\/adm/) && ($env{'user.adv'})) {
1.65 www 2644: $msgoptions=
1.202 albertel 2645: '<p><label><input type="radio" name="discuss" value="author" /> '.
1.151 albertel 2646: &mt('Feedback to resource author').'</label></p>';
1.65 www 2647: }
1.243 www 2648: my %optionhash=();
2649: foreach my $type ('question','comment','policy') {
2650: $optionhash{$type}=$env{'course.'.$env{'request.course.id'}.'.'.$type.'.email.text'};
2651: }
1.65 www 2652: if (&feedback_available(1)) {
2653: $msgoptions.=
1.202 albertel 2654: '<p><label><input type="radio" name="discuss" value="question" /> '.
1.243 www 2655: ($optionhash{'question'}?$optionhash{'question'}:&mt('Question about resource content')).'</label></p>';
1.65 www 2656: }
2657: if (&feedback_available(0,1)) {
2658: $msgoptions.=
1.202 albertel 2659: '<p><label><input type="radio" name="discuss" value="course" /> '.
1.278 raeburn 2660: ($optionhash{'comment'}?$optionhash{'comment'}:$crscontent).
1.151 albertel 2661: '</label></p>';
1.65 www 2662: }
2663: if (&feedback_available(0,0,1)) {
2664: $msgoptions.=
1.202 albertel 2665: '<p><label><input type="radio" name="discuss" value="policy" /> '.
1.278 raeburn 2666: ($optionhash{'policy'}?$optionhash{'policy'}:$crspolicy).
1.151 albertel 2667: '</label></p>';
1.65 www 2668: }
2669: }
1.190 www 2670: if (($env{'request.course.id'}) && (!$env{'form.sendmessageonly'})) {
1.241 raeburn 2671: my ($blocked,$blocktext) = &Apache::loncommon::blocking_status('boards');
1.304 raeburn 2672: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2673: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1.302 raeburn 2674: my $realsymb = $symb;
2675: if ($symb=~/^bulletin___/) {
2676: my $filename=(&Apache::lonnet::decode_symb($symb))[2];
2677: $filename=~s|^adm/wrapper/||;
2678: $realsymb=&Apache::lonnet::symbread($filename);
2679: }
2680: if (!$blocked && &discussion_open(undef,$realsymb) &&
1.303 raeburn 2681: (&Apache::lonnet::allowed('pch',
2682: $env{'request.course.id'}.
1.304 raeburn 2683: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) ||
2684: (($group ne '') && ($symb =~ m{^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$}) && (&check_group_priv($group,'pgd') eq 'ok')))) {
1.234 raeburn 2685: $discussoptions='<label><input type="radio" name="discuss" value="nonanon" checked="checked" /> '.
1.278 raeburn 2686: $contribdisc.
2687: '</label><br /><label><input type="radio" name="discuss" value="anon" /> '.
2688: $anoncontrib.
2689: ' <i>('.$namevis.')</i></label> '.
1.234 raeburn 2690: '<a href="/adm/preferences?action=changescreenname">'.&mt('Change Screenname').'</a>';
1.241 raeburn 2691: my $blockblog = &Apache::loncommon::blocking_status('blogs');
2692: if (!$blockblog) {
1.278 raeburn 2693: $discussoptions.= &add_blog_checkbox($crstype);
1.241 raeburn 2694: }
1.141 raeburn 2695: }
1.65 www 2696: }
1.272 bisitz 2697: if ($msgoptions) {
1.309 www 2698: $msgoptions='<tr><th><img src="'.&Apache::loncommon::lonhttpdurl('/res/adm/pages/feedback.png').'" />'
2699: .'<br />'.&mt('Send Feedback').'<br />'.&Apache::lonhtmlcommon::coursepreflink(&mt('Feedback Settings'),'feedback').'</th>'.
2700: '<td>'.$msgoptions.'</td></tr>';
1.272 bisitz 2701: }
1.65 www 2702: if ($discussoptions) {
1.309 www 2703: $discussoptions='<tr><th><img src="'.&Apache::loncommon::lonhttpdurl('/adm/lonMisc/chat.gif').'" alt="" />'
2704: .'<br />'.&mt('Discussion Contributions').'<br />'.&Apache::lonhtmlcommon::coursepreflink(&mt('Discussion Settings'),'discussion').'</th>'.
2705: '<td>'.$discussoptions.'</td></tr>';
1.272 bisitz 2706: }
1.309 www 2707: return &Apache::loncommon::start_data_table().$msgoptions.$discussoptions.&Apache::loncommon::end_data_table();
1.6 albertel 2708: }
2709:
2710: sub resource_output {
2711: my ($feedurl) = @_;
1.46 albertel 2712: my $usersaw=&Apache::lonnet::ssi_body($feedurl);
1.6 albertel 2713: $usersaw=~s/\<body[^\>]*\>//gi;
2714: $usersaw=~s/\<\/body\>//gi;
2715: $usersaw=~s/\<html\>//gi;
2716: $usersaw=~s/\<\/html\>//gi;
2717: $usersaw=~s/\<head\>//gi;
2718: $usersaw=~s/\<\/head\>//gi;
2719: $usersaw=~s/action\s*\=/would_be_action\=/gi;
2720: return $usersaw;
2721: }
2722:
2723: sub clear_out_html {
1.297 raeburn 2724: my ($message,$override)=@_;
1.107 www 2725: # Always allow the <m>-tag
2726: my %html=(M=>1);
2727: # Check if more is allowed
1.157 albertel 2728: my $cid=$env{'request.course.id'};
2729: if (($env{"course.$cid.allow_limited_html_in_feedback"} =~ m/yes/i) ||
1.39 www 2730: ($override)) {
1.37 albertel 2731: # allows <B> <I> <P> <A> <LI> <OL> <UL> <EM> <BR> <TT> <STRONG>
1.88 www 2732: # <BLOCKQUOTE> <DIV .*> <DIV> <IMG> <M> <SPAN> <H1> <H2> <H3> <H4> <SUB>
1.283 faziophi 2733: # <SUP> <TABLE> <TR> <TD> <TH> <TBODY>
1.107 www 2734: %html=(B=>1, I=>1, P=>1, A=>1, LI=>1, OL=>1, UL=>1, EM=>1,
1.297 raeburn 2735: BR=>1, TT=>1, STRONG=>1, BLOCKQUOTE=>1, PRE=>1, DIV=>1, IMG=>1,
2736: M=>1, CHEM=>1, ALGEBRA=>1, SUB=>1, SUP=>1, SPAN=>1,
1.283 faziophi 2737: H1=>1, H2=>1, H3=>1, H4=>1, H5=>1, H6=>1,
2738: TABLE=>1, TR=>1, TD=>1, TH=>1, TBODY=>1);
1.107 www 2739: }
2740: # Do the substitution of everything that is not explicitly allowed
1.216 albertel 2741: $message =~ s/\<(\/?\s*(\w+)[^\>\<]*)/
1.48 albertel 2742: {($html{uc($2)}&&(length($1)<1000))?"\<$1":"\<$1"}/ge;
1.216 albertel 2743: $message =~ s/(\<?\s*(\w+)[^\<\>]*)\>/
1.48 albertel 2744: {($html{uc($2)}&&(length($1)<1000))?"$1\>":"$1\>"}/ge;
1.6 albertel 2745: return $message;
2746: }
2747:
2748: sub assemble_email {
1.237 raeburn 2749: my ($message,$prevattempts,$usersaw,$useranswer)=@_;
1.220 raeburn 2750: my %lt = &Apache::lonlocal::texthash(
2751: 'prev' => 'Previous attempts of student (if applicable)',
2752: 'orig' => 'Original screen output (if applicable)',
2753: 'corr' => 'Correct Answer(s) (if applicable)',
2754: );
1.278 raeburn 2755: if (&Apache::loncommon::course_type() eq 'Community') {
2756: $lt{'prev'} = &mt('Previous attempts of member (if applicable)');
2757: }
1.6 albertel 2758: my $email=<<"ENDEMAIL";
2759: $message
2760: ENDEMAIL
2761: my $citations=<<"ENDCITE";
1.220 raeburn 2762: <h2>$lt{'prev'}</h2>
1.6 albertel 2763: $prevattempts
1.63 albertel 2764: <br /><hr />
1.220 raeburn 2765: <h2>$lt{'orig'}</h2>
1.6 albertel 2766: $usersaw
1.220 raeburn 2767: <h2>$lt{'corr'}</h2>
1.40 albertel 2768: $useranswer
1.6 albertel 2769: ENDCITE
2770: return ($email,$citations);
2771: }
2772:
1.36 www 2773:
2774: sub feedback_available {
2775: my ($question,$course,$policy)=@_;
1.242 albertel 2776: my ($typestyle,%to)=&Apache::lonmsg::decide_receiver('',0,$question,
2777: $course,$policy);
1.36 www 2778: return scalar(%to);
1.6 albertel 2779: }
2780:
2781: sub send_msg {
1.246 albertel 2782: my ($title,$feedurl,$email,$citations,$attachmenturl,$symb,%to)=@_;
2783: my $status='';
2784: my $sendsomething=0;
2785: my $restitle = &get_resource_title($symb,$feedurl);
2786: if ($title=~/^Error/) { $title=&mt('Feedback').': '.$title; }
2787: unless ($title=~/\w/) { $title=&mt('Feedback'); }
2788: foreach my $key (keys(%to)) {
2789: if ($key) {
2790: my ($user,$domain) = split(/\:/,$key,2);
2791: if (!defined($user)) {
2792: $status.='<br />'.&mt('Error sending message to [_1], no user specified.',$key);
2793: } elsif (!defined($domain)) {
2794: $status.='<br />'.&mt('Error sending message to [_1], no domain specified.',$key);
2795: } else {
2796: unless (&Apache::lonmsg::user_normal_msg($user,$domain,
2797: $title.' ['.$restitle.']',$email,$citations,$feedurl,
2798: $attachmenturl,undef,undef,$symb,$restitle)=~/ok/) {
2799: $status.='<br />'.&mt('Error sending message to').' '.$key.'<br />';
2800: } else {
2801: $sendsomething++;
2802: }
2803: }
2804: }
1.6 albertel 2805: }
1.246 albertel 2806:
1.18 www 2807:
2808: my %record=&Apache::lonnet::restore('_feedback');
1.221 raeburn 2809: my ($temp)=keys(%record);
1.18 www 2810: unless ($temp=~/^error\:/) {
1.246 albertel 2811: my %newrecord=();
2812: $newrecord{'resource'}=$feedurl;
2813: $newrecord{'subnumber'}=$record{'subnumber'}+1;
2814: unless (&Apache::lonnet::cstore(\%newrecord,'_feedback') eq 'ok') {
2815: $status.='<br />'.&mt('Not registered').'<br />';
2816: }
1.18 www 2817: }
1.246 albertel 2818:
2819: return ($status,$sendsomething);
1.6 albertel 2820: }
2821:
1.13 www 2822: sub adddiscuss {
1.303 raeburn 2823: my ($symb,$email,$anon,$attachmenturl,$subject,$group)=@_;
1.13 www 2824: my $status='';
1.122 raeburn 2825: my $realsymb;
2826: if ($symb=~/^bulletin___/) {
2827: my $filename=(&Apache::lonnet::decode_symb($symb))[2];
2828: $filename=~s|^adm/wrapper/||;
2829: $realsymb=&Apache::lonnet::symbread($filename);
2830: }
1.304 raeburn 2831: my ($cnum,$cdom);
2832: if ($env{'request.course.id'}) {
2833: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2834: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2835: }
1.122 raeburn 2836: if (&discussion_open(undef,$realsymb) &&
1.303 raeburn 2837: (&Apache::lonnet::allowed('pch',$env{'request.course.id'}.
2838: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) ||
1.304 raeburn 2839: (($group ne '') && (&check_group_priv($group,'pgd') eq 'ok') &&
2840: ($symb =~ m{^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$})))) {
1.20 www 2841:
1.13 www 2842: my %contrib=('message' => $email,
1.157 albertel 2843: 'sendername' => $env{'user.name'},
2844: 'senderdomain' => $env{'user.domain'},
2845: 'screenname' => $env{'environment.screenname'},
2846: 'plainname' => $env{'environment.firstname'}.' '.
2847: $env{'environment.middlename'}.' '.
2848: $env{'environment.lastname'}.' '.
2849: $env{'enrironment.generation'},
1.78 raeburn 2850: 'attachmenturl'=> $attachmenturl,
2851: 'subject' => $subject);
1.157 albertel 2852: if ($env{'form.replydisc'}) {
2853: $contrib{'replyto'}=(split(/\:\:\:/,$env{'form.replydisc'}))[1];
1.65 www 2854: }
1.14 www 2855: if ($anon) {
2856: $contrib{'anonymous'}='true';
2857: }
1.13 www 2858: if (($symb) && ($email)) {
1.231 raeburn 2859: my $now = time;
1.157 albertel 2860: if ($env{'form.editdisc'}) {
1.102 raeburn 2861: $contrib{'ip'}=$ENV{'REMOTE_ADDR'};
2862: $contrib{'host'}=$Apache::lonnet::perlvar{'lonHostID'};
1.231 raeburn 2863: $contrib{'timestamp'} = $now;
1.102 raeburn 2864: $contrib{'history'} = '';
2865: my $numoldver = 0;
1.157 albertel 2866: my ($oldsymb,$oldidx)=split(/\:\:\:/,$env{'form.editdisc'});
1.132 albertel 2867: &Apache::lonenc::check_decrypt(\$oldsymb);
1.110 raeburn 2868: $oldsymb=~s|(bulletin___\d+___)adm/wrapper/|$1|;
1.102 raeburn 2869: # get timestamp for last post and history
1.157 albertel 2870: my %oldcontrib=&Apache::lonnet::restore($oldsymb,$env{'request.course.id'},
2871: $env{'course.'.$env{'request.course.id'}.'.domain'},
2872: $env{'course.'.$env{'request.course.id'}.'.num'});
1.102 raeburn 2873: if (defined($oldcontrib{$oldidx.':replyto'})) {
2874: $contrib{'replyto'} = $oldcontrib{$oldidx.':replyto'};
2875: }
2876: if (defined($oldcontrib{$oldidx.':history'})) {
2877: if ($oldcontrib{$oldidx.':history'} =~ /:/) {
1.221 raeburn 2878: my @oldversions = split(/:/,$oldcontrib{$oldidx.':history'});
1.102 raeburn 2879: $numoldver = @oldversions;
2880: } else {
2881: $numoldver = 1;
2882: }
2883: $contrib{'history'} = $oldcontrib{$oldidx.':history'}.':';
2884: }
1.108 raeburn 2885: my $numnewver = $numoldver + 1;
1.102 raeburn 2886: if (defined($oldcontrib{$oldidx.':subject'})) {
1.112 raeburn 2887: if ($oldcontrib{$oldidx.':subject'} =~ /^<version num="0">/) {
2888: $contrib{'subject'} = '<version num="'.$numnewver.'">'.&HTML::Entities::encode($contrib{'subject'},'<>&"').'</version>';
2889: $contrib{'subject'} = $oldcontrib{$oldidx.':subject'}.$contrib{'subject'};
1.108 raeburn 2890: } else {
1.112 raeburn 2891: $contrib{'subject'} = '<version num="0">'.&HTML::Entities::encode($oldcontrib{$oldidx.':subject'},'<>&"').'</version><version num="1">'.&HTML::Entities::encode($contrib{'subject'},'<>&"').'</version>';
1.108 raeburn 2892: }
1.102 raeburn 2893: }
2894: if (defined($oldcontrib{$oldidx.':message'})) {
1.112 raeburn 2895: if ($oldcontrib{$oldidx.':message'} =~ /^<version num="0">/) {
2896: $contrib{'message'} = '<version num="'.$numnewver.'">'.&HTML::Entities::encode($contrib{'message'},'<>&"').'</version>';
2897: $contrib{'message'} = $oldcontrib{$oldidx.':message'}.$contrib{'message'};
1.108 raeburn 2898: } else {
1.112 raeburn 2899: $contrib{'message'} = '<version num="0">'.&HTML::Entities::encode($oldcontrib{$oldidx.':message'},'<>&"').'</version><version num="1">'.&HTML::Entities::encode($contrib{'message'},'<>&"').'</version>';
1.108 raeburn 2900: }
1.102 raeburn 2901: }
2902: $contrib{'history'} .= $oldcontrib{$oldidx.':timestamp'};
1.157 albertel 2903: my $put_reply = &Apache::lonnet::putstore($env{'request.course.id'},
1.182 albertel 2904: $oldsymb,$oldidx,\%contrib,
1.157 albertel 2905: $env{'course.'.$env{'request.course.id'}.'.domain'},
2906: $env{'course.'.$env{'request.course.id'}.'.num'});
1.102 raeburn 2907: $status='Editing class discussion'.($anon?' (anonymous)':'');
2908: } else {
2909: $status='Adding to class discussion'.($anon?' (anonymous)':'').': '.
1.157 albertel 2910: &Apache::lonnet::store(\%contrib,$symb,$env{'request.course.id'},
2911: $env{'course.'.$env{'request.course.id'}.'.domain'},
2912: $env{'course.'.$env{'request.course.id'}.'.num'});
1.102 raeburn 2913: }
1.231 raeburn 2914: my %storenewentry=($symb => $now);
1.63 albertel 2915: $status.='<br />'.&mt('Updating discussion time').': '.
1.21 www 2916: &Apache::lonnet::put('discussiontimes',\%storenewentry,
1.157 albertel 2917: $env{'course.'.$env{'request.course.id'}.'.domain'},
2918: $env{'course.'.$env{'request.course.id'}.'.num'});
1.13 www 2919: }
1.17 www 2920: my %record=&Apache::lonnet::restore('_discussion');
1.221 raeburn 2921: my ($temp)=keys(%record);
1.17 www 2922: unless ($temp=~/^error\:/) {
2923: my %newrecord=();
2924: $newrecord{'resource'}=$symb;
2925: $newrecord{'subnumber'}=$record{'subnumber'}+1;
1.63 albertel 2926: $status.='<br />'.&mt('Registering').': '.
1.21 www 2927: &Apache::lonnet::cstore(\%newrecord,'_discussion');
1.20 www 2928: }
2929: } else {
2930: $status.='Failed.';
1.17 www 2931: }
1.63 albertel 2932: return $status.'<br />';
1.13 www 2933: }
2934:
1.231 raeburn 2935: sub get_discussion_info {
2936: my ($idx,%contrib) = @_;
2937: my $changelast = 0;
2938: my $count = 0;
2939: my $hiddenflag = 0;
2940: my $deletedflag = 0;
2941: my ($hidden,$deleted,%info,$newlastdisc);
2942: my $version = $contrib{'version'};
2943: if ($version) {
2944: for (my $id=$version; $id>0; $id--) {
2945: my $vkeys=$contrib{$id.':keys'};
2946: my @keys=split(/:/,$vkeys);
2947: if (grep(/^hidden$/,@keys)) {
2948: if (!$hiddenflag) {
2949: $hidden = $contrib{$id.':hidden'};
2950: $hiddenflag = 1;
2951: }
2952: } elsif (grep(/^deleted$/,@keys)) {
2953: if (!$deletedflag) {
2954: $deleted = $contrib{$id.':deleted'};
2955: $deletedflag = 1;
2956: }
2957: } else {
2958: if (($hidden !~/\.$id\./) && ($deleted !~/\.$id\./)) {
2959: $count++;
2960: $info{$count}{'id'} = $id;
2961: $info{$count}{'timestamp'}=$contrib{$id.':timestamp'};
2962: }
2963: }
2964: }
2965: if ($info{'1'}{'id'} == $idx) {
2966: $changelast = 1;
2967: if ($count > 1) {
2968: $newlastdisc = $info{'2'}{'timestamp'};
2969: } else {
2970: $newlastdisc = 0;
2971: }
2972: }
2973: }
2974: return ($changelast,$newlastdisc);
2975: }
2976:
1.33 www 2977: # ----------------------------------------------------------- Preview function
2978:
2979: sub show_preview {
1.187 albertel 2980: my ($r) = @_;
1.135 albertel 2981: &Apache::loncommon::content_type($r,'text/html');
2982: $r->send_http_header;
1.218 albertel 2983: my $start_page=
2984: &Apache::loncommon::start_page('Preview',undef,
2985: {'only_body' => 1,});
2986:
1.157 albertel 2987: my $message=&clear_out_html($env{'form.comment'});
1.165 albertel 2988: &newline_to_br(\$message);
1.106 www 2989: $message=&Apache::lonspeller::markeduptext($message);
1.33 www 2990: $message=&Apache::lontexconvert::msgtexconverted($message);
1.297 raeburn 2991: my $subject=&clear_out_html($env{'form.subject'});
1.78 raeburn 2992: $subject=~s/\n/\<br \/\>/g;
2993: $subject=&Apache::lontexconvert::msgtexconverted($subject);
1.187 albertel 2994:
2995: my $end_page = &Apache::loncommon::end_page();
2996:
1.263 bisitz 2997: $r->print($start_page
2998: .'<h1>'.&mt('Preview').'</h1>'
2999: .&Apache::lonhtmlcommon::start_pick_box()
3000: .&Apache::lonhtmlcommon::row_title(&mt('Subject'))
3001: .$subject
3002: .&Apache::lonhtmlcommon::row_closure()
3003: .&Apache::lonhtmlcommon::row_title(&mt('Message'))
3004: .$message
3005: .&Apache::lonhtmlcommon::row_closure(1)
3006: .&Apache::lonhtmlcommon::end_pick_box()
3007: .$end_page
3008: );
1.33 www 3009: }
3010:
1.280 faziophi 3011: sub contains_block_html {
1.286 raeburn 3012: my ($message)=@_;
3013: return ($message =~ m{
3014: <(br|h1|h2|h3|h4|h5|h6|p|ol|ul|table|pre|address|blockquote|center|div)
3015: \s*
3016: (\w+\=['"]\w+['"])*
3017: \s*
3018: (
3019: \s*/>|
3020: >.*</\1\s*>
3021: )}xs
3022: );
1.280 faziophi 3023: }
1.283 faziophi 3024:
3025: sub tidy_html {
3026: my ($message)=@_;
3027: # my $tidy = HTML::Tidy::libXML->new();
3028: # my $xhtml = $tidy->clean($message, 'utf-8', 1);
3029: # $xhtml =~ m/<body>(.*)<\/body>/is;
3030: # my $clean = $1;
3031: # # remove any empty block-level tags
3032: # $clean =~ s/<(table|p|div|tbody|blockquote|m|pre|algebra|center|ol|ul|span|h1|h2|h3|h4|h5|h6)\s*\/>//i;
3033: # $message=$clean;
3034: return $message;
3035: }
3036:
1.165 albertel 3037: sub newline_to_br {
3038: my ($message)=@_;
3039: my $newmessage;
3040: my $parser=HTML::LCParser->new($message);
3041: while (my $token=$parser->get_token()) {
3042: if ($token->[0] eq 'T') {
3043: my $text=$token->[1];
3044: $text=~s/\n/\<br \/\>/g;
3045: $newmessage.=$text;
3046: } elsif ($token->[0] eq 'D' || $token->[0] eq 'C') {
3047: $newmessage.=$token->[1];
3048: } elsif ($token->[0] eq 'PI' || $token->[0] eq 'E') {
3049: $newmessage.=$token->[2];
3050: } elsif ($token->[0] eq 'S') {
3051: $newmessage.=$token->[4];
3052: }
3053:
3054: }
3055: $$message=$newmessage;
3056: }
3057:
1.33 www 3058: sub generate_preview_button {
1.171 www 3059: my ($formname,$fieldname)=@_;
3060: unless ($formname) { $formname='mailform'; }
3061: unless ($fieldname) { $fieldname='comment'; }
1.107 www 3062: my $pre=&mt("Show Preview and Check Spelling");
1.33 www 3063: return(<<ENDPREVIEW);
1.205 raeburn 3064: <br />
1.33 www 3065: <form name="preview" action="/adm/feedback?preview=1" method="post" target="preview">
1.269 bisitz 3066: <input type="hidden" name="subject" />
1.33 www 3067: <input type="hidden" name="comment" />
1.65 www 3068: <input type="button" value="$pre"
1.282 wenzelju 3069: onclick="if (typeof(document.$formname.onsubmit)=='function') {document.$formname.onsubmit();};this.form.comment.value=document.$formname.$fieldname.value;this.form.subject.value=document.$formname.subject.value;this.form.submit();" />
1.33 www 3070: </form>
3071: ENDPREVIEW
3072: }
1.71 www 3073:
1.108 raeburn 3074: sub modify_attachments {
1.255 raeburn 3075: my ($r,$currnewattach,$currdelold,$symb,$idx,$attachmenturls,
3076: $attachmaxtext,$toolarge)=@_;
1.218 albertel 3077:
1.220 raeburn 3078: my %lt = &Apache::lonlocal::texthash(
3079: 'subj' => 'Subject',
3080: 'thfo' => 'The following attachments were part of the most recent saved version of this posting.',
3081: 'chth' => 'Check the checkboxes for any you wish to remove.',
3082: 'thef' => 'The following attachments have been uploaded for inclusion with this posting.',
3083: 'adda' => 'Add a new attachment to this post.',
1.247 albertel 3084: 'stch' => 'Save Changes',
1.220 raeburn 3085: );
1.218 albertel 3086: my $js = <<END;
3087: <script type="text/javascript">
3088: function setAction () {
3089: document.modattachments.action = document.modattachments.origpage.value;
3090: document.modattachments.submit();
3091: }
3092: </script>
3093: END
3094:
1.276 bisitz 3095: # Breadcrumbs
3096: my $brcrum = [{'href' => '',
3097: 'text' => 'Discussion Post Attachments'}];
1.306 www 3098: my %parms=();
3099: if ($env{'form.modal'} ne 'yes') { 'bread_crumbs' => $brcrum }
3100:
1.218 albertel 3101: my $start_page =
1.306 www 3102: &Apache::loncommon::start_page('Discussion Post Attachments',$js,\%parms);
1.218 albertel 3103:
1.204 www 3104: my $orig_subject = &unescape($env{'form.subject'});
1.297 raeburn 3105: my $subject=&clear_out_html($orig_subject);
1.108 raeburn 3106: $subject=~s/\n/\<br \/\>/g;
3107: $subject=&Apache::lontexconvert::msgtexconverted($subject);
1.157 albertel 3108: my $timestamp=$env{'form.timestamp'};
3109: my $numoldver=$env{'form.numoldver'};
1.187 albertel 3110:
1.108 raeburn 3111: my $msg = '';
1.113 raeburn 3112: my %attachments = ();
1.108 raeburn 3113: my %currattach = ();
3114: if ($idx) {
1.113 raeburn 3115: &extract_attachments($attachmenturls,$idx,$numoldver,\$msg,\%attachments,\%currattach,$currdelold);
1.108 raeburn 3116: }
1.139 albertel 3117: &Apache::lonenc::check_encrypt(\$symb);
1.187 albertel 3118:
3119: my $end_page =
3120: &Apache::loncommon::end_page();
3121:
3122: $r->print(<<END);
1.198 albertel 3123: $start_page
1.255 raeburn 3124: $toolarge
1.108 raeburn 3125: <form name="modattachments" method="post" enctype="multipart/form-data" action="/adm/feedback?attach=$symb">
1.255 raeburn 3126: <br />
3127: <table class="LC_data_table">
1.108 raeburn 3128: <tr>
1.255 raeburn 3129: <td colspan="2">
1.281 bisitz 3130: <b>Subject:</b> <b>$subject</b><br /><br />
1.108 raeburn 3131: END
3132: if ($idx) {
3133: if ($attachmenturls) {
1.221 raeburn 3134: my @currold = keys(%currattach);
1.108 raeburn 3135: if (@currold > 0) {
1.220 raeburn 3136: $r->print($lt{'thfo'}.'<br />'.$lt{'chth'}.'<br />'."\n");
1.113 raeburn 3137: foreach my $id (@currold) {
3138: my $attachurl = &HTML::Entities::decode($attachments{$id}{'filename'});
3139: $attachurl =~ m#/([^/]+)$#;
1.151 albertel 3140: $r->print('<label><input type="checkbox" name="deloldattach" value="'.$id.'" /> '.$1.'</label><br />'."\n");
1.108 raeburn 3141: }
3142: $r->print("<br />");
3143: }
3144: }
3145: }
1.213 raeburn 3146: if ((ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)) {
1.220 raeburn 3147: $r->print($lt{'thef'}.'<br />'.$lt{'chth'}.'<br />'."\n");
1.221 raeburn 3148: foreach my $attach (@{$currnewattach}) {
3149: $attach =~ m#/([^/]+)$#;
3150: $r->print('<label><input type="checkbox" name="delnewattach" value="'.$attach.'" /> '.$1.'</label><br />'."\n");
1.108 raeburn 3151: }
3152: $r->print("<br />");
3153: }
3154: $r->print(<<END);
1.255 raeburn 3155: </td></tr>
3156: <tr>
3157: <td>
1.282 wenzelju 3158: $lt{'adda'}</td><td><input type="file" name="addnewattach" /><input type="button" name="upload" value="Upload" onclick="this.form.submit()" />
1.108 raeburn 3159: </td>
3160: </tr>
1.255 raeburn 3161: <tr>
3162: <td colspan="2">$attachmaxtext</td>
3163: </tr>
1.108 raeburn 3164: </table>
1.157 albertel 3165: <input type="hidden" name="subject" value="$env{'form.subject'}" />
3166: <input type="hidden" name="comment" value="$env{'form.comment'}" />
3167: <input type="hidden" name="timestamp" value="$env{'form.timestamp'}" />
3168: <input type="hidden" name="idx" value="$env{'form.idx'}" />
3169: <input type="hidden" name="numoldver" value="$env{'form.numoldver'}" />
3170: <input type="hidden" name="origpage" value="$env{'form.origpage'}" />
1.175 www 3171: <input type="hidden" name="blog" value="$env{'form.blog'}" />
1.157 albertel 3172: <input type="hidden" name="discuss" value="$env{'form.discuss'}" />
1.108 raeburn 3173: END
1.220 raeburn 3174: foreach my $item (@{$currnewattach}) {
3175: $r->print('<input type="hidden" name="currnewattach" value="'.$item.'" />'."\n");
1.108 raeburn 3176: }
1.220 raeburn 3177: foreach my $item (@{$currdelold}) {
3178: $r->print('<input type="hidden" name="deloldattach" value="'.$item.'" />'."\n");
1.108 raeburn 3179: }
3180: $r->print(<<END);
1.282 wenzelju 3181: <input type="button" name="rtntoedit" value="$lt{'stch'}" onclick="setAction()" />
1.108 raeburn 3182: </form>
1.187 albertel 3183: $end_page
1.108 raeburn 3184: END
3185: return;
3186: }
3187:
3188: sub process_attachments {
3189: my ($currnewattach,$currdelold,$keepold) = @_;
1.158 albertel 3190:
3191: @{$currnewattach}=
3192: &Apache::loncommon::get_env_multiple('form.currnewattach');
3193: @{$currdelold}=
3194: &Apache::loncommon::get_env_multiple('form.deloldattach');
1.157 albertel 3195: if (exists($env{'form.delnewattach'})) {
1.158 albertel 3196: my @currdelnew =
3197: &Apache::loncommon::get_env_multiple('form.delnewattach');
1.108 raeburn 3198: my @currnew = ();
3199: foreach my $newone (@{$currnewattach}) {
3200: my $delflag = 0;
1.221 raeburn 3201: foreach my $item (@currdelnew) {
3202: if ($newone eq $item) {
1.108 raeburn 3203: $delflag = 1;
3204: last;
3205: }
3206: }
3207: unless ($delflag) {
1.221 raeburn 3208: push(@currnew, $newone);
1.108 raeburn 3209: }
3210: }
3211: @{$currnewattach} = @currnew;
3212: }
1.158 albertel 3213: @{$keepold} = &Apache::loncommon::get_env_multiple('form.keepold');
1.108 raeburn 3214: }
3215:
3216: sub generate_attachments_button {
1.224 raeburn 3217: my ($idx,$attachnum,$ressymb,$now,$currnewattach,$deloldattach,
3218: $numoldver,$mode,$blockblog) = @_;
1.108 raeburn 3219: my $origpage = $ENV{'REQUEST_URI'};
3220: my $att=$attachnum.' '.&mt("attachments");
1.220 raeburn 3221: my %lt = &Apache::lonlocal::texthash(
3222: 'clic' => 'Click to add/remove attachments',
3223: );
1.108 raeburn 3224: my $response = (<<END);
1.205 raeburn 3225: <br />
1.108 raeburn 3226: <form name="attachment" action="/adm/feedback?attach=$ressymb" method="post">
1.220 raeburn 3227: $lt{'clic'}: <input type="button" value="$att"
1.282 wenzelju 3228: onclick="if (typeof(document.mailform.onsubmit)=='function') {document.mailform.onsubmit();};this.form.comment.value=escape(document.mailform.comment.value);this.form.subject.value=escape(document.mailform.subject.value);
1.108 raeburn 3229: END
1.224 raeburn 3230: if (!$blockblog) {
3231: $response .= 'setblogvalue();';
3232: }
1.108 raeburn 3233: unless ($mode eq 'board') {
3234: $response .= 'javascript:anonchk();';
3235: }
3236: $response .= (<<ENDATTACH);
3237: this.form.submit();" />
3238: <input type="hidden" name="origpage" value="$origpage" />
3239: <input type="hidden" name="idx" value="$idx" />
3240: <input type="hidden" name="timestamp" value="$now" />
3241: <input type="hidden" name="subject" />
3242: <input type="hidden" name="comment" />
1.271 bisitz 3243: <input type="hidden" name="blog" value="0" />
3244: <input type="hidden" name="discuss" value="0" />
1.108 raeburn 3245: <input type="hidden" name="numoldver" value="$numoldver" />
3246: ENDATTACH
3247: if (defined($deloldattach)) {
3248: if (@{$deloldattach} > 0) {
1.221 raeburn 3249: foreach my $delatt (@{$deloldattach}) {
3250: $response .= '<input type="hidden" name="deloldattach" value="'.$delatt.'" />'."\n";
1.108 raeburn 3251: }
3252: }
3253: }
3254: if (defined($currnewattach)) {
3255: if (@{$currnewattach} > 0) {
1.221 raeburn 3256: foreach my $attach (@{$currnewattach}) {
3257: $response .= '<input type="hidden" name="currnewattach" value="'.$attach.'" />'."\n";
1.108 raeburn 3258: }
3259: }
3260: }
3261: $response .= '</form>';
3262: return $response;
3263: }
3264:
3265: sub extract_attachments {
3266: my ($attachmenturls,$idx,$numoldver,$message,$attachments,$currattach,$currdelold) = @_;
1.116 raeburn 3267: %{$attachments}=();
3268: &get_post_attachments($attachments,$attachmenturls);
1.221 raeburn 3269: foreach my $id (sort(keys(%{$attachments}))) {
1.116 raeburn 3270: if (exists($$attachments{$id}{$numoldver})) {
3271: if (defined($currdelold)) {
3272: if (@{$currdelold} > 0) {
3273: unless (grep/^$id$/,@{$currdelold}) {
3274: $$currattach{$id} = $$attachments{$id}{$numoldver};
1.108 raeburn 3275: }
1.113 raeburn 3276: } else {
3277: $$currattach{$id} = $$attachments{$id}{$numoldver};
1.108 raeburn 3278: }
1.116 raeburn 3279: } else {
3280: $$currattach{$id} = $$attachments{$id}{$numoldver};
1.108 raeburn 3281: }
3282: }
1.116 raeburn 3283: }
1.221 raeburn 3284: my @attached = (sort { $a <=> $b } keys(%{$currattach}));
1.116 raeburn 3285: if (@attached == 1) {
3286: my $id = $attached[0];
3287: my $attachurl;
3288: if ($attachmenturls =~ m/^<attachment id="0">/) {
3289: $attachurl = &HTML::Entities::decode($$attachments{$id}{'filename'});
3290: } else {
3291: $attachurl = $$attachments{$id}{'filename'};
3292: }
3293: $attachurl=~m|/([^/]+)$|;
3294: $$message.='<br /><a href="'.$attachurl.'"><tt>'.
3295: $1.'</tt></a><br />';
3296: &Apache::lonnet::allowuploaded('/adm/feedback',
3297: $attachurl);
3298: } elsif (@attached > 1) {
3299: $$message.='<ol>';
1.221 raeburn 3300: foreach my $attach (@attached) {
3301: my $id = $attach;
1.113 raeburn 3302: my $attachurl = &HTML::Entities::decode($$attachments{$id}{'filename'});
1.116 raeburn 3303: my ($fname)
3304: =($attachurl=~m|/([^/]+)$|);
3305: $$message .= '<li><a href="'.$attachurl.
3306: '"><tt>'.
3307: $fname.'</tt></a></li>';
1.108 raeburn 3308: &Apache::lonnet::allowuploaded('/adm/feedback',
1.116 raeburn 3309: $attachurl);
1.108 raeburn 3310: }
1.116 raeburn 3311: $$message .= '</ol>';
1.108 raeburn 3312: }
3313: }
3314:
3315: sub construct_attachmenturl {
3316: my ($currnewattach,$keepold,$symb,$idx)=@_;
3317: my $oldattachmenturl;
3318: my $newattachmenturl;
1.113 raeburn 3319: my $startnum = 0;
1.108 raeburn 3320: my $currver = 0;
1.157 albertel 3321: if (($env{'form.editdisc'}) && ($idx)) {
3322: my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
3323: $env{'course.'.$env{'request.course.id'}.'.domain'},
3324: $env{'course.'.$env{'request.course.id'}.'.num'});
1.108 raeburn 3325: $oldattachmenturl = $contrib{$idx.':attachmenturl'};
3326: if ($contrib{$idx.':history'}) {
3327: if ($contrib{$idx.':history'} =~ /:/) {
1.221 raeburn 3328: my @oldversions = split(/:/,$contrib{$idx.':history'});
1.108 raeburn 3329: $currver = 1 + scalar(@oldversions);
3330: } else {
3331: $currver = 2;
3332: }
3333: } else {
3334: $currver = 1;
3335: }
3336: if ($oldattachmenturl) {
1.113 raeburn 3337: if ($oldattachmenturl =~ m/^<attachment id="0">/) {
3338: my %attachments = ();
3339: my $prevver = $currver-1;
3340: &get_post_attachments(\%attachments,$oldattachmenturl);
1.221 raeburn 3341: my $numattach = scalar(keys(%attachments));
1.113 raeburn 3342: $startnum += $numattach;
1.221 raeburn 3343: foreach my $num (sort {$a <=> $b} keys(%attachments)) {
1.113 raeburn 3344: $newattachmenturl .= '<attachment id="'.$num.'"><filename>'.$attachments{$num}{'filename'}.'</filename>';
1.221 raeburn 3345: foreach my $item (sort {$a <=> $b} keys(%{$attachments{$num}})) {
3346: unless ($item eq 'filename') {
3347: $newattachmenturl .= '<post id="'.$item.'">'.$attachments{$num}{$item}.'</post>';
1.116 raeburn 3348: }
1.113 raeburn 3349: }
3350: if (grep/^$num$/,@{$keepold}) {
3351: $newattachmenturl .= '<post id="'.$currver.'">'.$attachments{$num}{$prevver}.'</post>';
1.108 raeburn 3352: }
1.113 raeburn 3353: $newattachmenturl .= '</attachment>';
1.108 raeburn 3354: }
3355: } else {
1.116 raeburn 3356: $newattachmenturl = '<attachment id="0"><filename>'.&HTML::Entities::encode($oldattachmenturl).'</filename><post id="0">n</post>';
1.108 raeburn 3357: unless (grep/^0$/,@{$keepold}) {
1.113 raeburn 3358: $newattachmenturl .= '<post id="1">n</post>';
1.108 raeburn 3359: }
1.113 raeburn 3360: $newattachmenturl .= '</attachment>';
1.108 raeburn 3361: $startnum ++;
3362: }
3363: }
3364: }
3365: for (my $i=0; $i<@{$currnewattach}; $i++) {
3366: my $attachnum = $startnum + $i;
1.113 raeburn 3367: $newattachmenturl .= '<attachment id="'.$attachnum.'"><filename>'.&HTML::Entities::encode($$currnewattach[$i]).'</filename><post id="'.$currver.'">n</post></attachment>';
1.108 raeburn 3368: }
3369: return $newattachmenturl;
3370: }
1.128 raeburn 3371:
1.224 raeburn 3372: sub add_blog_checkbox {
1.278 raeburn 3373: my ($crstype) = @_;
3374: my $checkstatus;
1.224 raeburn 3375: if ($env{'form.blog'}) {
3376: $checkstatus = 'checked="checked"';
3377: }
3378: my $output = '
3379: <script type="text/javascript">
3380: function setblogvalue() {
3381: if (document.mailform.blog.checked) {
3382: document.attachment.blog.value = 1;
3383: } else {
3384: document.attachment.blog.value = 0;
3385: }
3386: }
3387: </script><br />
1.278 raeburn 3388: <label><input type="checkbox" name="blog" '.$checkstatus.' /> ';
3389: if ($crstype eq 'Community') {
3390: $output .= &mt('Add to my public community blog');
3391: } else {
3392: $output .= &mt('Add to my public course blog');
3393: }
3394: $output .= '</label><br />'."\n";
1.224 raeburn 3395: return $output;
3396: }
3397:
1.128 raeburn 3398: sub has_discussion {
3399: my $resourcesref = shift;
3400: my $navmap = Apache::lonnavmaps::navmap->new();
1.260 raeburn 3401: if (defined($navmap)) {
3402: my @allres=$navmap->retrieveResources();
3403: foreach my $resource (@allres) {
3404: if ($resource->hasDiscussion()) {
3405: my $ressymb = $resource->wrap_symb();
3406: if (ref($resourcesref) eq 'ARRAY') {
3407: push(@{$resourcesref}, $ressymb);
3408: }
3409: }
1.128 raeburn 3410: }
1.260 raeburn 3411: } else {
3412: &Apache::lonnet::logthis('Has discussion check failed - could not create navmap object.');
1.128 raeburn 3413: }
3414: return;
1.143 raeburn 3415: }
3416:
3417: sub sort_filter_names {
1.278 raeburn 3418: my ($sort_types,$role_types,$status_types,$crstype) = @_;
3419: if (ref($sort_types) eq 'HASH') {
3420: %{$sort_types} = (
1.143 raeburn 3421: ascdate => 'Date order - oldest first',
3422: descdate => 'Date order - newest first',
3423: thread => 'Threaded',
3424: subject => 'By subject',
3425: username => 'By domain and username',
3426: lastfirst => 'By last name, first name'
3427: );
1.278 raeburn 3428: }
3429: my @courseroles = qw(st in ta ep ad);
3430: if ($crstype eq 'Community') {
3431: push(@courseroles,'co');
3432: } else {
3433: push(@courseroles,'cc');
3434: }
3435: if (ref($role_types) eq 'HASH') {
3436: foreach my $role (@courseroles) {
3437: $role_types->{$role} = &Apache::lonnet::plaintext($role,$crstype);
3438: }
3439: $role_types->{'all'} = 'All roles';
3440: $role_types->{'cr'} = 'Custom role';
3441: }
3442: if (ref($status_types) eq 'HASH') {
3443: %{$status_types} = (
1.143 raeburn 3444: all => 'Roles of any status',
1.214 albertel 3445: Active => 'Only active roles',
3446: Expired => 'Only past roles',
3447: Future => 'Only future roles',
1.143 raeburn 3448: );
1.278 raeburn 3449: }
1.143 raeburn 3450: }
1.108 raeburn 3451:
1.6 albertel 3452: sub handler {
3453: my $r = shift;
1.8 www 3454: if ($r->header_only) {
1.71 www 3455: &Apache::loncommon::content_type($r,'text/html');
1.8 www 3456: $r->send_http_header;
3457: return OK;
3458: }
1.15 www 3459:
3460: # --------------------------- Get query string for limited number of parameters
3461:
1.97 raeburn 3462: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.306 www 3463: ['modal','hide','unhide','deldisc','postdata','preview','replydisc','editdisc','cmd','symb','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navtime','navmaps','navurl','sortposts','applysort','rolefilter','statusfilter','sectionpick','groupick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export','sendmessageonly','group','ref']);
1.208 raeburn 3464: my $group = $env{'form.group'};
1.255 raeburn 3465: my %attachmax = (
1.268 bisitz 3466: text => &mt('(128 KB max size)'),
1.255 raeburn 3467: num => 131072,
3468: );
1.180 raeburn 3469: if ($env{'form.editdisc'}) {
1.208 raeburn 3470: if (!(&editing_allowed($env{'form.editdisc'},$env{'form.group'}))) {
1.180 raeburn 3471: my $symb=(split(/\:\:\:/,$env{'form.editdisc'}))[0];
3472: my ($map,$id,$url)=&Apache::lonnet::decode_symb($symb);
3473: my $feedurl=&Apache::lonnet::clutter($url);
1.208 raeburn 3474: &redirect_back($r,$feedurl,&mt('Editing not permitted').'<br />', '0','0','','',$env{'form.previous'},undef,undef,undef,
3475: undef,undef,undef,$group);
1.180 raeburn 3476: return OK;
3477: }
3478: }
1.157 albertel 3479: if ($env{'form.discsymb'}) {
3480: my ($symb,$feedurl) = &get_feedurl_and_clean_symb($env{'form.discsymb'});
1.111 raeburn 3481: my $readkey = $symb.'_read';
3482: my $chgcount = 0;
1.157 albertel 3483: my %readinghash = &Apache::lonnet::get('nohist_'.$env{'request.course.id'}.'_discuss',[$readkey],$env{'user.domain'},$env{'user.name'});
1.221 raeburn 3484: foreach my $key (keys(%env)) {
1.111 raeburn 3485: if ($key =~ m/^form\.postunread_(\d+)/) {
3486: if ($readinghash{$readkey} =~ /\.$1\./) {
3487: $readinghash{$readkey} =~ s/\.$1\.//;
3488: $chgcount ++;
3489: }
3490: } elsif ($key =~ m/^form\.postread_(\d+)/) {
3491: unless ($readinghash{$readkey} =~ /\.$1\./) {
3492: $readinghash{$readkey} .= '.'.$1.'.';
3493: $chgcount ++;
3494: }
3495: }
3496: }
3497: if ($chgcount > 0) {
1.157 albertel 3498: &Apache::lonnet::put('nohist_'.$env{'request.course.id'}.'_discuss',
3499: \%readinghash,$env{'user.domain'},$env{'user.name'});
1.111 raeburn 3500: }
1.133 albertel 3501: &redirect_back($r,$feedurl,&mt('Marked postings read/unread').'<br />',
1.208 raeburn 3502: '0','0','','',$env{'form.previous'},'','','',
3503: undef,undef,undef,$group);
1.111 raeburn 3504: return OK;
3505: }
1.157 albertel 3506: if ($env{'form.allversions'}) {
1.109 raeburn 3507: &Apache::loncommon::content_type($r,'text/html');
1.187 albertel 3508: &Apache::loncommon::no_cache($r);
1.109 raeburn 3509: $r->send_http_header;
1.187 albertel 3510:
1.276 bisitz 3511: # Breadcrumbs
3512: my $brcrum = [{'href' => '',
3513: 'text' => 'Discussion Post Versions'}];
1.306 www 3514:
3515: my %parms=();
3516: if ($env{'form.modal'} ne 'yes') { 'bread_crumbs' => $brcrum }
1.276 bisitz 3517:
1.306 www 3518: $r->print(&Apache::loncommon::start_page('Discussion Post Versions',undef,\%parms));
1.187 albertel 3519:
1.157 albertel 3520: my $crs='/'.$env{'request.course.id'};
3521: if ($env{'request.course.sec'}) {
3522: $crs.='_'.$env{'request.course.sec'};
1.109 raeburn 3523: }
1.133 albertel 3524: $crs=~s|_|/|g;
1.208 raeburn 3525: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3526: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1.157 albertel 3527: my ($symb,$idx)=split(/\:\:\:/,$env{'form.allversions'});
1.133 albertel 3528: ($symb)=&get_feedurl_and_clean_symb($symb);
1.208 raeburn 3529: my $ressymb = &wrap_symb($symb);
3530: my $group = $env{'form.group'};
3531: my $seeid;
3532: if (($group ne '') && (($ressymb =~ m|^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$|))) {
3533: if (&check_group_priv($group,'dgp') eq 'ok') {
3534: $seeid = 1;
3535: }
3536: } else {
3537: $seeid = &Apache::lonnet::allowed('rin',$crs);
3538: }
1.109 raeburn 3539: if ($idx > 0) {
1.116 raeburn 3540: my %messages = ();
3541: my %subjects = ();
3542: my %attachmsgs = ();
3543: my %allattachments = ();
3544: my %imsfiles = ();
3545: my ($screenname,$plainname);
1.157 albertel 3546: my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
3547: $env{'course.'.$env{'request.course.id'}.'.domain'},
3548: $env{'course.'.$env{'request.course.id'}.'.num'});
1.133 albertel 3549: $r->print(&get_post_contents(\%contrib,$idx,$seeid,'allversions',\%messages,\%subjects,\%allattachments,\%attachmsgs,\%imsfiles,\$screenname,\$plainname));
1.109 raeburn 3550: }
1.187 albertel 3551: $r->print(&Apache::loncommon::end_page());
1.109 raeburn 3552: return OK;
3553: }
1.157 albertel 3554: if ($env{'form.posterlist'}) {
3555: my ($symb,$feedurl)=&get_feedurl_and_clean_symb($env{'form.applysort'});
3556: &print_showposters($r,$symb,$env{'form.previous'},$feedurl,
3557: $env{'form.sortposts'});
1.101 raeburn 3558: return OK;
3559: }
1.157 albertel 3560: if ($env{'form.userpick'}) {
1.133 albertel 3561: my @posters = &Apache::loncommon::get_env_multiple('form.stuinfo');
1.157 albertel 3562: my ($symb,$feedurl)=&get_feedurl_and_clean_symb($env{'form.userpick'});
1.101 raeburn 3563: my $numpicks = @posters;
1.133 albertel 3564: my %discinfo;
3565: $discinfo{$symb.'_userpick'} = join('&',@posters);
1.157 albertel 3566: &Apache::lonnet::put('nohist_'.$env{'request.course.id'}.'_discuss',
3567: \%discinfo,$env{'user.domain'},$env{'user.name'});
1.175 www 3568: &redirect_back($r,$feedurl,&mt('Changed sort/filter').'<br />','0','0','',
1.157 albertel 3569: '',$env{'form.previous'},$env{'form.sortposts'},'','','',
1.208 raeburn 3570: '',$numpicks,$group);
1.101 raeburn 3571: return OK;
3572: }
1.157 albertel 3573: if ($env{'form.applysort'}) {
3574: my ($symb,$feedurl)=&get_feedurl_and_clean_symb($env{'form.applysort'});
1.175 www 3575: &redirect_back($r,$feedurl,&mt('Changed sort/filter').'<br />','0','0','',
1.157 albertel 3576: '',$env{'form.previous'},$env{'form.sortposts'},
3577: $env{'form.rolefilter'},$env{'form.statusfilter'},
1.208 raeburn 3578: $env{'form.sectionpick'},$env{'form.grouppick'},
3579: undef,$group);
1.100 raeburn 3580: return OK;
1.157 albertel 3581: } elsif ($env{'form.cmd'} eq 'sortfilter') {
3582: my ($symb,$feedurl)=&get_feedurl_and_clean_symb($env{'form.symb'});
3583: &print_sortfilter_options($r,$symb,$env{'form.previous'},$feedurl);
1.100 raeburn 3584: return OK;
1.157 albertel 3585: } elsif ($env{'form.navtime'}) {
1.99 raeburn 3586: my %discinfo = ();
3587: my @resources = ();
1.157 albertel 3588: if (defined($env{'form.navmaps'})) {
3589: if ($env{'form.navmaps'} =~ /:/) {
1.221 raeburn 3590: @resources = split(/:/,$env{'form.navmaps'});
1.128 raeburn 3591: } else {
1.157 albertel 3592: @resources = ("$env{'form.navmaps'}");
1.128 raeburn 3593: }
1.99 raeburn 3594: } else {
1.128 raeburn 3595: &has_discussion(\@resources);
1.99 raeburn 3596: }
3597: my $numitems = @resources;
3598: my $feedurl = '/adm/navmaps';
1.157 albertel 3599: if ($env{'form.navurl'}) { $feedurl .= '?'.$env{'form.navurl'}; }
1.99 raeburn 3600: my %lt = &Apache::lonlocal::texthash(
3601: 'mnpa' => 'Marked "New" posts as read in a total of',
1.128 raeburn 3602: 'robb' => 'resources/bulletin boards.',
1.264 schafran 3603: 'twnp' => 'There are currently no resources or discussion boards with unread discussion postings.'
1.99 raeburn 3604: );
1.221 raeburn 3605: foreach my $res (@resources) {
3606: my $ressymb=$res;
1.132 albertel 3607: &Apache::lonenc::check_decrypt(\$ressymb);
1.99 raeburn 3608: my $lastkey = $ressymb.'_lastread';
1.157 albertel 3609: $discinfo{$lastkey} = $env{'form.navtime'};
1.99 raeburn 3610: }
1.128 raeburn 3611: my $textline = "<b>$lt{'mnpa'} $numitems $lt{'robb'}</b>";
3612: if ($numitems > 0) {
1.157 albertel 3613: &Apache::lonnet::put('nohist_'.$env{'request.course.id'}.'_discuss',
3614: \%discinfo,$env{'user.domain'},$env{'user.name'});
1.128 raeburn 3615: } else {
3616: $textline = "<b>$lt{'twnp'}</b>";
3617: }
1.99 raeburn 3618: &Apache::loncommon::content_type($r,'text/html');
3619: $r->send_http_header;
1.150 albertel 3620: my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif');
1.200 albertel 3621: my %onload;
3622:
1.186 albertel 3623: my $start_page=
3624: &Apache::loncommon::start_page('New posts marked as read',undef,
3625: {'redirect' => [2,$feedurl],
3626: 'only_body' => 1,
1.189 albertel 3627: 'add_entries' => \%onload});
1.186 albertel 3628: my $end_page = &Apache::loncommon::end_page();
1.99 raeburn 3629: $r->print (<<ENDREDIR);
1.186 albertel 3630: $start_page
1.150 albertel 3631: <img align="right" src="$logo" />
1.128 raeburn 3632: $textline
1.99 raeburn 3633: <form name="reldt" action="$feedurl" target="loncapaclient">
3634: </form>
1.187 albertel 3635: <br />
1.186 albertel 3636: $end_page
1.99 raeburn 3637: ENDREDIR
3638: return OK;
1.157 albertel 3639: } elsif ($env{'form.modifydisp'}) {
3640: my ($symb,$feedurl)=&get_feedurl_and_clean_symb($env{'form.modifydisp'});
1.133 albertel 3641: my ($dispchgA,$dispchgB,$markchg,$toggchg) =
1.157 albertel 3642: split(/_/,$env{'form.changes'});
3643: &print_display_options($r,$symb,$env{'form.previous'},$dispchgA,
1.133 albertel 3644: $dispchgB,$markchg,$toggchg,$feedurl);
1.97 raeburn 3645: return OK;
1.157 albertel 3646: } elsif ($env{'form.markondisp'} || $env{'form.markonread'} ||
3647: $env{'form.allposts'} || $env{'form.onlyunread'} ||
3648: $env{'form.onlyunmark'} || $env{'form.toggoff'} ||
3649: $env{'form.toggon'} || $env{'form.markread'}) {
3650: my ($symb,$feedurl)=&get_feedurl_and_clean_symb($env{'form.symb'});
1.137 albertel 3651: my %discinfo;
1.133 albertel 3652: # ------------------------ Modify setting for read/unread toggle for each post
1.157 albertel 3653: if ($env{'form.toggoff'}) { $discinfo{$symb.'_readtoggle'}=0; }
3654: if ($env{'form.toggon'}) { $discinfo{$symb.'_readtoggle'}=1; }
1.133 albertel 3655: # --------- Modify setting for identification of 'NEW' posts in this discussion
1.157 albertel 3656: if ($env{'form.markondisp'}) {
1.137 albertel 3657: $discinfo{$symb.'_lastread'} = time;
3658: $discinfo{$symb.'_markondisp'} = 1;
3659: }
1.157 albertel 3660: if ($env{'form.markonread'}) {
3661: if ( $env{'form.previous'} > 0 ) {
3662: $discinfo{$symb.'_lastread'} = $env{'form.previous'};
1.137 albertel 3663: }
3664: $discinfo{$symb.'_markondisp'} = 0;
1.84 raeburn 3665: }
1.133 albertel 3666: # --------------------------------- Modify display setting for this discussion
1.157 albertel 3667: if ($env{'form.allposts'}) {
1.137 albertel 3668: $discinfo{$symb.'_showonlyunread'} = 0;
3669: $discinfo{$symb.'_showonlyunmark'} = 0;
1.84 raeburn 3670: }
1.157 albertel 3671: if ($env{'form.onlyunread'}) { $discinfo{$symb.'_showonlyunread'} = 1; }
3672: if ($env{'form.onlyunmark'}) { $discinfo{$symb.'_showonlyunmark'} = 1; }
1.137 albertel 3673: # ----------------------------------------------------- Mark new posts not NEW
1.157 albertel 3674: if ($env{'form.markread'}) { $discinfo{$symb.'_lastread'} = time; }
3675: &Apache::lonnet::put('nohist_'.$env{'request.course.id'}.'_discuss',
3676: \%discinfo,$env{'user.domain'},$env{'user.name'});
3677: my $previous=$env{'form.previous'};
3678: if ($env{'form.markondisp'}) { $previous=undef; }
1.133 albertel 3679: &redirect_back($r,$feedurl,&mt('Changed display status').'<br />',
1.208 raeburn 3680: '0','0','','',$previous,'','','','','','',$group);
1.84 raeburn 3681: return OK;
1.157 albertel 3682: } elsif (($env{'form.hide'}) || ($env{'form.unhide'})) {
1.15 www 3683: # ----------------------------------------------------------------- Hide/unhide
1.157 albertel 3684: my $entry=$env{'form.hide'}?$env{'form.hide'}:$env{'form.unhide'};
1.133 albertel 3685: my ($symb,$idx)=split(/\:\:\:/,$entry);
3686: ($symb,my $feedurl)=&get_feedurl_and_clean_symb($symb);
1.15 www 3687:
1.180 raeburn 3688: my $crs='/'.$env{'request.course.id'};
3689: if ($env{'request.course.sec'}) {
3690: $crs.='_'.$env{'request.course.sec'};
3691: }
3692: $crs=~s/\_/\//g;
3693: my $seeid=&Apache::lonnet::allowed('rin',$crs);
3694:
1.208 raeburn 3695: if ($env{'form.hide'} && !$seeid && !(&editing_allowed($env{'form.hide'},$env{'form.group'}))) {
3696: &redirect_back($r,$feedurl,&mt('Deletion not permitted').'<br />', '0','0','','',$env{'form.previous'},'','','','',
3697: undef,undef,$group,);
1.180 raeburn 3698: return OK;
3699: }
3700:
1.157 albertel 3701: my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
3702: $env{'course.'.$env{'request.course.id'}.'.domain'},
3703: $env{'course.'.$env{'request.course.id'}.'.num'});
1.15 www 3704:
1.133 albertel 3705: my $currenthidden=$contrib{'hidden'};
3706: my $currentstudenthidden=$contrib{'studenthidden'};
1.15 www 3707:
1.157 albertel 3708: if ($env{'form.hide'}) {
1.133 albertel 3709: $currenthidden.='.'.$idx.'.';
3710: unless ($seeid) {
3711: $currentstudenthidden.='.'.$idx.'.';
3712: }
3713: } else {
3714: $currenthidden=~s/\.$idx\.//g;
3715: }
3716: my %newhash=('hidden' => $currenthidden);
1.157 albertel 3717: if ( ($env{'form.hide'}) && (!$seeid) ) {
1.133 albertel 3718: $newhash{'studenthidden'} = $currentstudenthidden;
3719: }
1.231 raeburn 3720: if ($env{'form.hide'}) {
3721: my $changelast = 0;
3722: my $newlast;
3723: ($changelast,$newlast) = &get_discussion_info($idx,%contrib);
3724: if ($changelast) {
3725: &Apache::lonnet::put('discussiontimes',{$symb => $newlast},
3726: $env{'course.'.$env{'request.course.id'}.'.domain'},
3727: $env{'course.'.$env{'request.course.id'}.'.num'});
3728: }
3729: }
1.157 albertel 3730: &Apache::lonnet::store(\%newhash,$symb,$env{'request.course.id'},
3731: $env{'course.'.$env{'request.course.id'}.'.domain'},
3732: $env{'course.'.$env{'request.course.id'}.'.num'});
1.38 www 3733:
1.133 albertel 3734: &redirect_back($r,$feedurl,&mt('Changed discussion status').'<br />',
1.208 raeburn 3735: '0','0','','',$env{'form.previous'},undef,undef,undef,
3736: undef,undef,undef,$group);
1.135 albertel 3737: return OK;
1.157 albertel 3738: } elsif ($env{'form.cmd'}=~/^(threadedoff|threadedon)$/) {
3739: my ($symb,$feedurl)=&get_feedurl_and_clean_symb($env{'form.symb'});
3740: if ($env{'form.cmd'} eq 'threadedon') {
1.69 www 3741: &Apache::lonnet::put('environment',{'threadeddiscussion' => 'on'});
1.253 raeburn 3742: &Apache::lonnet::appenv({'environment.threadeddiscussion' => 'on'});
1.69 www 3743: } else {
3744: &Apache::lonnet::del('environment',['threadeddiscussion']);
1.265 raeburn 3745: &Apache::lonnet::delenv('environment.threadeddiscussion');
1.72 albertel 3746: }
1.133 albertel 3747: &redirect_back($r,$feedurl,&mt('Changed discussion view mode').'<br />',
1.208 raeburn 3748: '0','0','','',$env{'form.previous'},undef,undef,undef,
3749: undef,undef,undef,$group);
1.135 albertel 3750: return OK;
1.157 albertel 3751: } elsif ($env{'form.deldisc'}) {
1.38 www 3752: # --------------------------------------------------------------- Hide for good
1.157 albertel 3753: my ($symb,$idx)=split(/\:\:\:/,$env{'form.deldisc'});
1.133 albertel 3754: ($symb,my $feedurl)=&get_feedurl_and_clean_symb($symb);
1.157 albertel 3755: my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
3756: $env{'course.'.$env{'request.course.id'}.'.domain'},
3757: $env{'course.'.$env{'request.course.id'}.'.num'});
1.231 raeburn 3758: my ($changelast,$newlast) = &get_discussion_info($idx,%contrib);
3759: if ($changelast) {
3760: &Apache::lonnet::put('discussiontimes',{$symb => $newlast},
3761: $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'});
3762: }
1.135 albertel 3763: my %newhash=('deleted' => $contrib{'deleted'}.".$idx.");
1.157 albertel 3764: &Apache::lonnet::store(\%newhash,$symb,$env{'request.course.id'},
3765: $env{'course.'.$env{'request.course.id'}.'.domain'},
3766: $env{'course.'.$env{'request.course.id'}.'.num'});
1.135 albertel 3767: &redirect_back($r,$feedurl,&mt('Changed discussion status').'<br />',
1.208 raeburn 3768: '0','0','','',$env{'form.previous'},undef,undef,undef,
3769: undef,undef,undef,$group);
1.135 albertel 3770: return OK;
1.157 albertel 3771: } elsif ($env{'form.preview'}) {
1.33 www 3772: # -------------------------------------------------------- User wants a preview
3773: &show_preview($r);
1.135 albertel 3774: return OK;
1.157 albertel 3775: } elsif ($env{'form.attach'}) {
1.108 raeburn 3776: # -------------------------------------------------------- Work on attachments
3777: &Apache::loncommon::content_type($r,'text/html');
3778: $r->send_http_header;
1.198 albertel 3779: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','addnewattach','delnewattach','timestamp','numoldver','idx','discuss','blog']);
1.255 raeburn 3780: my (@currnewattach,@currdelold,@keepold,$toolarge);
1.108 raeburn 3781: &process_attachments(\@currnewattach,\@currdelold,\@keepold);
1.157 albertel 3782: if (exists($env{'form.addnewattach.filename'})) {
1.255 raeburn 3783: if (length($env{'form.addnewattach'})<=$attachmax{'num'}) {
1.157 albertel 3784: my $subdir = 'feedback/'.$env{'form.timestamp'};
1.108 raeburn 3785: my $newattachment=&Apache::lonnet::userfileupload('addnewattach',undef,$subdir);
1.221 raeburn 3786: push(@currnewattach, $newattachment);
1.255 raeburn 3787: } else {
3788: $toolarge = '<p><span class="LC_warning">'.&mt('Attachment not included - exceeded permitted length').'</span><br /></p>';
1.108 raeburn 3789: }
3790: }
1.133 albertel 3791: my $attachmenturls;
1.157 albertel 3792: my ($symb) = &get_feedurl_and_clean_symb($env{'form.attach'});
3793: my $idx = $env{'form.idx'};
1.108 raeburn 3794: if ($idx) {
1.157 albertel 3795: my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
3796: $env{'course.'.$env{'request.course.id'}.'.domain'},
3797: $env{'course.'.$env{'request.course.id'}.'.num'});
1.108 raeburn 3798: $attachmenturls = $contrib{$idx.':attachmenturl'};
3799: }
1.133 albertel 3800: &modify_attachments($r,\@currnewattach,\@currdelold,$symb,$idx,
1.255 raeburn 3801: $attachmenturls,$attachmax{'text'},$toolarge);
1.135 albertel 3802: return OK;
1.157 albertel 3803: } elsif ($env{'form.export'}) {
1.116 raeburn 3804: &Apache::loncommon::content_type($r,'text/html');
3805: $r->send_http_header;
1.157 albertel 3806: my ($symb,$feedurl) = &get_feedurl_and_clean_symb($env{'form.export'});
1.133 albertel 3807: my $mode='board';
1.116 raeburn 3808: my $status='OPEN';
1.157 albertel 3809: my $previous=$env{'form.previous'};
1.305 www 3810: if ($feedurl =~ /$LONCAPA::assess_re/) {
1.116 raeburn 3811: $mode='problem';
3812: $status=$Apache::inputtags::status[-1];
3813: }
3814: my $discussion = &list_discussion($mode,$status,$symb);
1.188 albertel 3815: my $start_page =
3816: &Apache::loncommon::start_page('Resource Feedback and Discussion');
3817: my $end_page =
3818: &Apache::loncommon::end_page();
3819: $r->print($start_page.$discussion.$end_page);
1.116 raeburn 3820: return OK;
1.15 www 3821: } else {
3822: # ------------------------------------------------------------- Normal feedback
1.157 albertel 3823: my $feedurl=$env{'form.postdata'};
1.260 raeburn 3824: $feedurl=~s/^https?\:\/\///;
1.133 albertel 3825: $feedurl=~s/^$ENV{'SERVER_NAME'}//;
3826: $feedurl=~s/^$ENV{'HTTP_HOST'}//;
3827: $feedurl=~s/\?.+$//;
1.8 www 3828:
1.133 albertel 3829: my $symb;
1.157 albertel 3830: if ($env{'form.replydisc'}) {
3831: $symb=(split(/\:\:\:/,$env{'form.replydisc'}))[0];
3832: } elsif ($env{'form.editdisc'}) {
3833: $symb=(split(/\:\:\:/,$env{'form.editdisc'}))[0];
3834: } elsif ($env{'form.origpage'}) {
1.133 albertel 3835: $symb="";
3836: } else {
3837: $symb=&Apache::lonnet::symbread($feedurl);
3838: }
3839: unless ($symb) {
1.157 albertel 3840: $symb=$env{'form.symb'};
1.133 albertel 3841: }
1.237 raeburn 3842: if (defined($symb)) {
3843: ($symb,$feedurl)=&get_feedurl_and_clean_symb($symb);
3844: } else {
3845: # backward compatibility (bulletin boards used to be 'wrapped')
3846: &Apache::lonenc::check_decrypt(\$feedurl);
3847: &dewrapper(\$feedurl);
3848: }
1.133 albertel 3849: my $goahead=1;
1.305 www 3850: if ($feedurl=~/$LONCAPA::assess_re/) {
1.133 albertel 3851: unless ($symb) { $goahead=0; }
3852: }
3853: if (!$goahead) {
3854: # Ambiguous Problem Resource
3855: $r->internal_redirect('/adm/ambiguous');
3856: return OK;
1.31 www 3857: }
1.8 www 3858: # Go ahead with feedback, no ambiguous reference
1.133 albertel 3859: unless (
3860: (
3861: ($feedurl=~m:^/res:) && ($feedurl!~m:^/res/adm:)
3862: )
3863: ||
1.157 albertel 3864: ($env{'request.course.id'} && ($feedurl!~m:^/adm:))
1.133 albertel 3865: ||
1.157 albertel 3866: ($env{'request.course.id'} && ($symb=~/^bulletin\_\_\_/))
1.133 albertel 3867: ) {
1.135 albertel 3868: &Apache::loncommon::content_type($r,'text/html');
3869: $r->send_http_header;
1.133 albertel 3870: # Unable to give feedback
1.233 raeburn 3871: &Apache::lonenc::check_encrypt(\$feedurl);
1.133 albertel 3872: &no_redirect_back($r,$feedurl);
1.178 albertel 3873: return OK;
1.133 albertel 3874: }
1.6 albertel 3875: # --------------------------------------------------- Print login screen header
1.157 albertel 3876: unless ($env{'form.sendit'}) {
1.233 raeburn 3877: &Apache::lonenc::check_encrypt(\$feedurl);
1.135 albertel 3878: &Apache::loncommon::content_type($r,'text/html');
3879: $r->send_http_header;
1.234 raeburn 3880: if (($env{'form.replydisc'}) || ($env{'form.editdisc'})) {
1.235 raeburn 3881: my ($blocked,$blocktext) =
3882: &Apache::loncommon::blocking_status('boards');
1.234 raeburn 3883: if ($blocked) {
3884: $r->print(&blocked_reply_or_edit($blocktext));
3885: return OK;
3886: }
3887: }
1.303 raeburn 3888: my $options=&screen_header($feedurl,$symb,$group);
1.133 albertel 3889: if ($options) {
1.255 raeburn 3890: &mail_screen($r,$feedurl,$options,$symb,$attachmax{'text'});
1.133 albertel 3891: } else {
3892: &fail_redirect($r,$feedurl);
3893: }
3894: return OK;
1.6 albertel 3895: }
3896:
3897: # Get previous user input
1.9 albertel 3898: my $prevattempts=&Apache::loncommon::get_previous_attempt(
1.157 albertel 3899: $symb,$env{'user.name'},$env{'user.domain'},
3900: $env{'request.course.id'});
1.6 albertel 3901:
3902: # Get output from resource
1.237 raeburn 3903: &Apache::lonenc::check_encrypt(\$feedurl);
1.6 albertel 3904: my $usersaw=&resource_output($feedurl);
3905:
1.50 albertel 3906: # Get resource answer (need to allow student to view grades for this to work)
1.253 raeburn 3907: &Apache::lonnet::appenv({'allowed.vgr'=>'F'});
1.238 raeburn 3908: my $usersymb = &Apache::lonenc::check_encrypt($symb);
1.237 raeburn 3909: my $useranswer=
3910: &Apache::loncommon::get_student_answers(
1.238 raeburn 3911: $usersymb,$env{'user.name'},$env{'user.domain'},
1.237 raeburn 3912: $env{'request.course.id'});
1.50 albertel 3913: &Apache::lonnet::delenv('allowed.vgr');
1.42 www 3914: # Get attachments, if any, and not too large
3915: my $attachmenturl='';
1.255 raeburn 3916: my $toolarge='';
1.157 albertel 3917: if (($env{'form.origpage'}) || ($env{'form.editdisc'}) ||
3918: ($env{'form.replydisc'})) {
1.133 albertel 3919: my ($symb,$idx);
1.157 albertel 3920: if ($env{'form.replydisc'}) {
3921: ($symb,$idx)=split(/\:\:\:/,$env{'form.replydisc'});
3922: } elsif ($env{'form.editdisc'}) {
3923: ($symb,$idx)=split(/\:\:\:/,$env{'form.editdisc'});
3924: } elsif ($env{'form.origpage'}) {
3925: $symb = $env{'form.symb'};
1.133 albertel 3926: }
1.132 albertel 3927: &Apache::lonenc::check_decrypt(\$symb);
1.133 albertel 3928: my @currnewattach = ();
3929: my @deloldattach = ();
3930: my @keepold = ();
3931: &process_attachments(\@currnewattach,\@deloldattach,\@keepold);
3932: $symb=~s|(bulletin___\d+___)adm/wrapper/|$1|;
3933: $attachmenturl=&construct_attachmenturl(\@currnewattach,\@keepold,$symb,$idx);
1.157 albertel 3934: } elsif ($env{'form.attachment.filename'}) {
1.255 raeburn 3935: if (length($env{'form.attachment'})<=$attachmax{'num'}) {
3936: my $now = time;
3937: my $subdir = 'feedback/'.$now;
3938: $attachmenturl=&Apache::lonnet::userfileupload('attachment',undef,$subdir);
3939: } else {
3940: $toolarge = '<p><span class="LC_warning">'.&mt('Attachment not included - exceeded permitted length').'</span><br /></p>';
3941: }
1.42 www 3942: }
1.6 albertel 3943: # Filter HTML out of message (could be nasty)
1.301 raeburn 3944: my $override;
3945: if ($env{'form.discuss'} =~ /^(?:author|question|course|policy)$/) {
3946: $override = 1;
3947: }
3948: my $message=&clear_out_html($env{'form.comment'},$override);
1.6 albertel 3949:
3950: # Assemble email
1.237 raeburn 3951: my ($email,$citations)=&assemble_email($message,$prevattempts,
1.133 albertel 3952: $usersaw,$useranswer);
1.40 albertel 3953:
1.6 albertel 3954: # Who gets this?
1.242 albertel 3955: my ($typestyle,%to) = &Apache::lonmsg::decide_receiver($feedurl);
1.6 albertel 3956:
3957: # Actually send mail
1.297 raeburn 3958: my ($status,$numsent)=&send_msg(&clear_out_html($env{'form.subject'}),
1.194 albertel 3959: $feedurl,$email,$citations,
1.240 raeburn 3960: $attachmenturl,$usersymb,%to);
1.13 www 3961:
3962: # Discussion? Store that.
1.32 albertel 3963: my $numpost=0;
1.207 albertel 3964: if ( ($env{'form.discuss'} ne ''
3965: && $env{'form.discuss'} !~ /^(?:author|question|course|policy)/)
3966: || $env{'form.anondiscuss'} ne '') {
1.297 raeburn 3967: my $subject = &clear_out_html($env{'form.subject'});
1.201 albertel 3968: my $anonmode=($env{'form.discuss'} eq 'anon' || $env{'form.anondiscuss'} );
1.133 albertel 3969: $typestyle.=&adddiscuss($symb,$message,$anonmode,$attachmenturl,
1.303 raeburn 3970: $subject,$group);
1.32 albertel 3971: $numpost++;
1.14 www 3972: }
1.175 www 3973:
3974: # Add to blog?
3975:
3976: my $blog='';
3977: if ($env{'form.blog'}) {
1.297 raeburn 3978: my $subject = &clear_out_html($env{'form.subject'});
1.175 www 3979: $status.=&Apache::lonrss::addentry($env{'user.name'},
3980: $env{'user.domain'},
3981: 'CourseBlog_'.$env{'request.course.id'},
3982: $subject,$message,$feedurl,'public');
1.278 raeburn 3983: if (&Apache::loncommon::course_type() eq 'Community') {
3984: $blog='<br />'.&mt('Added to my community blog').'<br />';
3985: } else {
3986: $blog='<br />'.&mt('Added to my course blog').'<br />';
3987: }
1.175 www 3988: }
1.133 albertel 3989:
1.6 albertel 3990: # Receipt screen and redirect back to where came from
1.255 raeburn 3991: &redirect_back($r,$feedurl,$typestyle,$numsent,$numpost,$blog,$status,$env{'form.previous'},undef,undef,undef,undef,undef,undef,$group,$toolarge);
1.133 albertel 3992: }
3993: return OK;
1.234 raeburn 3994: }
3995:
3996: sub blocked_reply_or_edit {
3997: my ($blocktext) = @_;
3998: return
3999: &Apache::loncommon::start_page('Resource Feedback and Discussion').
4000: $blocktext.'<br /><br /><a href="javascript:history.go(-1)">'.
4001: &mt('Back to previous page').
4002: &Apache::loncommon::end_page();
1.133 albertel 4003: }
1.6 albertel 4004:
1.133 albertel 4005: sub wrap_symb {
4006: my ($ressymb)=@_;
4007: if ($ressymb =~ /bulletin___\d+___/) {
4008: unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
4009: $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
4010: }
1.6 albertel 4011: }
1.133 albertel 4012: return $ressymb;
4013: }
4014: sub dewrapper {
4015: my ($feedurl)=@_;
4016: if ($$feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) {
4017: $$feedurl=~s|^/adm/wrapper||;
4018: }
4019: }
4020:
4021: sub get_feedurl {
4022: my ($symb)=@_;
4023: my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
4024: my $feedurl = &Apache::lonnet::clutter($url);
4025: &dewrapper(\$feedurl);
4026: return $feedurl;
1.15 www 4027: }
1.1 www 4028:
1.133 albertel 4029: sub get_feedurl_and_clean_symb {
4030: my ($symb)=@_;
4031: &Apache::lonenc::check_decrypt(\$symb);
4032: # backward compatibility (bulletin boards used to be 'wrapped')
4033: unless ($symb =~ m|bulletin___\d+___adm/wrapper|) {
4034: $symb=~s|(bulletin___\d+___)|$1adm/wrapper|;
4035: }
4036: my $feedurl = &get_feedurl($symb);
4037: return ($symb,$feedurl);
4038: }
1.180 raeburn 4039:
4040: sub editing_allowed {
1.208 raeburn 4041: my ($postid,$group) = @_;
4042: $postid = &unescape($postid);
1.180 raeburn 4043: my $can_edit = 0;
1.208 raeburn 4044: if ($group ne '') {
4045: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4046: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
4047: if ($postid =~ m|^bulletin___\d+___adm/wrapper(/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard)|) {
4048: if (&check_group_priv($group,'egp') eq 'ok') {
4049: $can_edit = 1;
4050: }
4051: return $can_edit;
4052: }
4053: }
1.180 raeburn 4054: my $cid = $env{'request.course.id'};
4055: my $role = (split(/\./,$env{'request.role'}))[0];
4056: my $section = $env{'request.course.sec'};
1.184 albertel 4057: my $allow_editing_config =
4058: $env{'course.'.$cid.'.allow_discussion_post_editing'};
1.180 raeburn 4059: if ($allow_editing_config =~ m/^\s*yes\s*$/i) {
4060: $can_edit = 1;
4061: } else {
1.184 albertel 4062: foreach my $editor (split(/,/,$allow_editing_config)) {
4063: my ($editor_role,$editor_sec) = split(/:/,$editor);
4064: if ($editor_role eq $role
4065: && defined($editor_sec)
4066: && defined($section)
4067: && $editor_sec eq $section) {
4068: $can_edit = 1;
4069: last;
4070: }
4071: if ($editor_role eq $role
4072: && !defined($editor_sec)) {
4073: $can_edit = 1;
4074: }
4075: }
1.180 raeburn 4076: }
4077: return $can_edit;
4078: }
4079:
1.208 raeburn 4080: sub check_group_priv {
4081: my ($group,$grp_priv) = @_;
4082: foreach my $priv ('mdg','vcg') {
4083: my $checkcourse = $env{'request.course.id'}.
4084: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'');
4085: if (&Apache::lonnet::allowed($priv,$checkcourse)) {
4086: return 'ok';
4087: }
4088: }
4089: if ($grp_priv && $group ne '') {
4090: if (&Apache::lonnet::allowed($grp_priv,$env{'request.course.id'}.'/'.$group)) {
4091: return 'ok';
4092: }
4093: }
4094: return '';
4095: }
4096:
1.211 albertel 4097: sub group_args {
1.208 raeburn 4098: my ($group) = @_;
1.211 albertel 4099: if ($group eq '') { return ''; }
4100: my $extra_args = '&group='.$group;
1.208 raeburn 4101: if (exists($env{'form.ref'})) {
1.211 albertel 4102: $extra_args .= '&ref='.$env{'form.ref'};
1.208 raeburn 4103: }
4104: return $extra_args;
4105: }
4106:
1.237 raeburn 4107: sub get_resource_title {
4108: my ($symb,$feedurl) = @_;
4109: my ($restitle,$plainurl);
4110: if (defined($symb)) {
4111: my $plain_symb = &Apache::lonenc::check_decrypt($symb);
4112: $restitle = &Apache::lonnet::gettitle($plain_symb);
4113: }
4114: if (defined($feedurl)) {
4115: $plainurl = &Apache::lonenc::check_decrypt($feedurl);
4116: }
4117: if (!defined($restitle)) {
4118: if (defined($feedurl)) {
4119: $restitle = &Apache::lonnet::gettitle($plainurl);
4120: }
4121: }
4122: if ($plainurl ne $feedurl) {
4123: my ($plain_filename) = ($plainurl =~ m-/([^/]+)$-);
4124: if ($plain_filename eq $restitle) {
4125: $restitle = &mt('Untitled resource');
4126: }
4127: }
4128: if ($restitle eq '') {
4129: $restitle = &mt('Untitled resource');
4130: }
4131: return $restitle;
4132: }
4133:
1.1 www 4134: 1;
4135: __END__
1.257 jms 4136:
4137:
4138: =pod
4139:
4140: =head1 NAME
4141:
4142: Apache::lonfeedback.pm
4143:
4144: =head1 SYNOPSIS
4145:
4146: Handles feedback from students to instructors and system administrators.
4147:
4148: Provides a screenshot of the current resource, as well as previous attempts if the resource was a homework.
4149:
4150: Used by lonmsg.pm.
4151:
4152: This is part of the LearningOnline Network with CAPA project
4153: described at http://www.lon-capa.org.
4154:
4155: =head1 OVERVIEW
4156:
4157: None
4158:
4159: =head1 SUBROUTINES
4160:
4161: =over
4162:
4163: =item discussion_open()
4164:
4165: =item discussion_visible()
4166:
4167: =item list_discussion()
4168:
4169: =item send_feedback_link()
4170:
4171: =item send_message_link()
4172:
4173: =item action_links_bar()
4174:
4175: =item postingform_display()
4176:
4177: =item build_posting_display
4178:
4179: =item filter_regexp()
4180:
4181: =item get_post_contents()
4182:
4183: =item replicate_attachments()
4184:
4185: =item mail_screen()
4186:
4187: =item print_display_options()
4188:
4189: =item print_sortfilter_options()
4190:
4191: =item print_showposters()
4192:
4193: =item get_post_versions()
4194:
4195: =item get_post_attachments()
4196:
4197: =item fail_redirect()
4198:
4199: =item redirect_back()
4200:
4201: =item no_redirect_back()
4202:
4203: =item screen_header()
4204:
4205: =item resource_output()
4206:
4207: =item clear_out_html()
4208:
4209: =item assemble_email()
4210:
4211: =item feedback_available()
4212:
4213: =item send_msg()
4214:
4215: =item adddiscuss()
4216:
4217: =item get_discussion_info()
4218:
4219: =item show_preview()
4220:
4221: =item newline_to_br()
4222:
1.283 faziophi 4223: =item tidy_html()
4224:
1.257 jms 4225: =item generate_preview_button()
4226:
4227: =item modify_attachments()
4228:
4229: =item process_attachments()
4230:
4231: =item generate_attachments_button()
4232:
4233: =item extract_attachments()
4234:
4235: =item construct_attachmenturl()
4236:
4237: =item add_blog_checkbox()
4238:
4239: =item has_discussion()
4240:
4241: =item sort_filter_names()
4242:
4243: =item handler()
4244:
4245: =item blocked_reply_or_edit()
4246:
4247: =item wrap_symb()
4248:
4249: =item dewrapper()
4250:
4251: =item get_feedurl()
4252:
4253: =item get_feedurl_and_clean_symb()
4254:
4255: =item editing_allowed()
4256:
4257: =item check_group_priv()
4258:
4259: =item group_args()
4260:
4261: =item get_resource_title()
4262:
4263: =back
4264:
1.258 bisitz 4265: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>