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