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