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