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