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