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