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