--- loncom/interface/lonfeedback.pm 2009/03/04 17:07:31 1.267 +++ loncom/interface/lonfeedback.pm 2010/08/14 15:24:46 1.298 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.267 2009/03/04 17:07:31 bisitz Exp $ +# $Id: lonfeedback.pm,v 1.298 2010/08/14 15:24:46 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -41,6 +41,7 @@ use Apache::lonnavmaps; use Apache::lonenc(); use Apache::lonrss(); use HTML::LCParser(); +#use HTML::Tidy::libXML; use Apache::lonspeller(); use Apache::longroup; use Cwd; @@ -48,13 +49,22 @@ use LONCAPA; sub discussion_open { my ($status,$symb)=@_; +# Advanced roles can always discuss if ($env{'request.role.adv'}) { return 1; } +# Get discussion closing date + my $close=&Apache::lonnet::EXT('resource.0.discussend',$symb); +# If it is defined and in the future, the instructor wants this discussion to be open + if (defined($close) && $close ne '' && $close > time) { + return 1; + } +# It was not explicitly open, check if the problem is available. +# If the problem is not available, close the discussion if (defined($status) && !($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER' || $status eq 'OPEN')) { return 0; } - my $close=&Apache::lonnet::EXT('resource.0.discussend',$symb); +# The problem is available, but check if the instructor explictly closed discussion if (defined($close) && $close ne '' && $close < time) { return 0; } @@ -91,7 +101,7 @@ sub list_discussion { if (not &discussion_visible($status)) { if ($mode ne 'board') { &Apache::lonenc::check_encrypt(\$ressymb); - return '<br />'.&send_message_link($ressymb); + return '<br /><div class="LC_feedback_link">'.&send_message_link($ressymb)."</div>"; } } if ($group ne '' && $mode eq 'board') { @@ -103,14 +113,17 @@ sub list_discussion { my ($blocked,$blocktext) = &Apache::loncommon::blocking_status('boards'); if ($blocked) { + $blocktext = '<br /><div class="LC_feedback_link"><span class="LC_feedback_link">'.$blocktext."</span>"; &Apache::lonenc::check_encrypt(\$ressymb); if ($mode ne 'board') { - $blocktext.='<br />'.&send_message_link($ressymb); + $blocktext.=&send_message_link($ressymb).'</div>'; + }else{ + $blocktext.="</div>"; } return $blocktext; } - my @bgcols = ("#cccccc","#eeeeee"); + my @bgcols = ("LC_disc_old_item","LC_disc_new_item"); my $discussiononly=0; if ($mode eq 'board') { $discussiononly=1; } unless ($env{'request.course.id'}) { return ''; } @@ -169,6 +182,7 @@ sub list_discussion { my $cdom = $env{'course.'.$cid.'.domain'}; my $cnum = $env{'course.'.$cid.'.num'}; + my $crstype = &Apache::loncommon::course_type(); # Get information about students and non-students in course for filtering display of posts my %roleshash = (); @@ -268,10 +282,6 @@ sub list_discussion { my %anonhash=(); my $anoncnt=0; my $target=''; - unless ($env{'browser.interface'} eq 'textual' || - $env{'environment.remote'} eq 'off' ) { - $target='target="LONcom"'; - } my $now = time; $discinfo{$visitkey} = $visit; @@ -312,6 +322,7 @@ sub list_discussion { 'dpwn' => 'Deleted posts will no longer be visible to you and other students', 'bwco' => 'but will continue to be visible to your instructor', 'depo' => 'Deleted posts will no longer be visible to you or anyone else.', + 'discussions' => 'DISCUSSIONS' ); my $currdisp = $lt{'allposts'}; @@ -352,10 +363,10 @@ sub list_discussion { $togglink = 'toggoff'; } - $chglink .= '&changes='.$displinkA.'_'.$displinkB.'_'.$marklink.'_'.$togglink; + $chglink .= '&changes='.$displinkA.'_'.$displinkB.'_'.$marklink.'_'.$togglink; if ($newpostsflag) { - $chglink .= '&previous='.$prevread; + $chglink .= '&previous='.$prevread; } $chglink.=&group_args($group); @@ -363,8 +374,7 @@ sub list_discussion { # Print the discusssion if ($outputtarget eq 'tex') { $discussion.='<tex>{\tiny \vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}'. - '\textbf{DISCUSSIONS}\makebox[2 cm][b]{\hrulefill}'. - '\vskip 0 mm\noindent\textbf{'.$lt{'cuse'}.'}:\vskip 0 mm'. + '\textbf{'.$lt{'discussions'}.'}\makebox[2 cm][b]{\hrulefill}\vskip 0 mm'. '\noindent\textbf{'.$lt{'disa'}.'}: \textit{'.$currdisp.'}\vskip 0 mm'. '\noindent\textbf{'.$lt{'npce'}.'}: \textit{'.$currmark.'}}</tex>'; } elsif ($outputtarget eq 'export') { @@ -398,8 +408,7 @@ sub list_discussion { my $manifestfilename = $tempexport.$manifest; if ($manifestfile = Apache::File->new('>'.$manifestfilename)) { $manifestok=1; - print $manifestfile qq| -<?xml version="1.0" encoding="UTF-8"?> + print $manifestfile qq|<?xml version="1.0" encoding="UTF-8"?> <manifest xmlns="http://www.imsglobal.org/xsd/imscp_v1p1" xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" identifier="MANIFEST-$ressymb" xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1 @@ -412,13 +421,12 @@ imscp_v1p1.xsd http://www.imsglobal.org/ } } else { my $colspan=$maxdepth+1; - $discussion.= qq| -<script> + $discussion.= &Apache::lonhtmlcommon::scripttag(qq| function verifydelete (caller,symb,idx,newflag,previous,groupparm) { var symbparm = symb+':::'+idx var prevparm = "" if (newflag == 1) { - prevparm = "&previous="+previous + prevparm = "&previous="+previous } if (caller == 'studentdelete') { if (confirm("$lt{'aysu'}\\n$lt{'dpwn'},\\n$lt{'bwco'}")) { @@ -432,9 +440,9 @@ imscp_v1p1.xsd http://www.imsglobal.org/ } } } -</script> - |; - $discussion.='<form name="readchoices" method="post" action="/adm/feedback?chgreads='.$ressymb.'" ><table bgcolor="#AAAAAA" cellpadding="2" cellspacing="2" border="0">'; + |); + $discussion.='<form name="readchoices" method="post" action="/adm/feedback?chgreads='.$ressymb.'" >'. + "\n".'<table class="LC_discussion">'; $discussion .= &action_links_bar($colspan,$ressymb,$visible, $newpostsflag,$group, $prevread,$markondisp); @@ -445,7 +453,7 @@ imscp_v1p1.xsd http://www.imsglobal.org/ $discussion.="\n".'<tr><td bgcolor="#CCCCCC" colspan="'.$colspan.'">'. '<a href="/adm/feedback?allposts=1&symb='.$escsymb; if ($newpostsflag) { - $discussion .= '&previous='.$prevread; + $discussion .= '&previous='.$prevread; } $discussion .= &group_args($group); $discussion .= '">'.&mt('Show all posts').'</a> '.&mt('to display').' '. @@ -510,7 +518,6 @@ imscp_v1p1.xsd http://www.imsglobal.org/ $threadinsert='<br /><strong>Reply: '.$thisdepth.'</strong>'; } $discussionitems[$alldiscussion{$post}]=~s/<\/td><td([^>]*)>/$threadinsert<\/td><td TeXwidth="65 mm" align="left">/; - $discussionitems[$alldiscussion{$post}]=~s/<a([^>]+)>(Edit|Hide|Delete|Reply|Submissions)<\/a>//g; $discussionitems[$alldiscussion{$post}]=~s/(<b>|<\/b>|<\/a>|<a([^>]+)>)//g; $discussionitems[$alldiscussion{$post}]='<tex>\vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}</tex>'.$discussionitems[$alldiscussion{$post}]; @@ -525,11 +532,11 @@ imscp_v1p1.xsd http://www.imsglobal.org/ print $manifestfile "\n". '<item identifier="ITEM-'.$ressymb.'-'.$alldiscussion{$post}.'" isvisible="'. $imsitems{$alldiscussion{$post}}{'isvisible'}.'" identifieref="RES-'.$ressymb.'-'.$alldiscussion{$post}.'">'. - '<title>'.$imsitems{$alldiscussion{$post}}{'title'}.'</title>'; + '<title>'.$imsitems{$alldiscussion{$post}}{'title'}.'</title></item>'; $imsresources .= "\n". '<resource identifier="RES-'.$ressymb.'-'.$alldiscussion{$post}.'" type="webcontent" href="'.$postfilename.'">'."\n". '<file href="'.$postfilename.'">'."\n". - $imsfiles{$alldiscussion{$post}}{$imsitems{$alldiscussion{$post}}{'currversion'}}."\n". + $imsfiles{$alldiscussion{$post}}{$imsitems{$alldiscussion{$post}}{'currversion'}}.'</file>'."\n". '</resource>'; } my $postingfile; @@ -547,7 +554,7 @@ imscp_v1p1.xsd http://www.imsglobal.org/ } $copyresult.=&replicate_attachments($imsitems{$alldiscussion{$post}}{'allattachments'},$tempexport); } else { - $discussion.='<td bgcolor="'.$bgcols[$newitem{$alldiscussion{$post}}]. + $discussion.='<td class="'.$bgcols[$newitem{$alldiscussion{$post}}]. '" colspan="'.$colspan.'">'. $discussionitems[$alldiscussion{$post}]. '</td></tr>'; } @@ -557,14 +564,14 @@ imscp_v1p1.xsd http://www.imsglobal.org/ my $colspan=$maxdepth+1; $discussion .= <<END; <tr bgcolor="#FFFFFF"> - <td colspan="$colspan" valign="top"> - <table border="0" bgcolor="#FFFFFF" width="100%" cellspacing="2" cellpadding="2"> + <td colspan="$colspan" class="LC_disc_action_links_bar"> + <table class="LC_disc_action_table"> <tr> <td align="left"> <table border="0" cellpadding="0" cellspacing="4"> <tr> <td> - <font size="-1"><b>$lt{'cuse'}</b>:</td> + <font size="-1"><b>$lt{'cuse'}</b>:</font></td> <td> </td> <td><font size="-1"> END @@ -586,7 +593,7 @@ END </font></td> <td> </td> <td align="left"> - <font size="-1"><b><a href="$chglink">$lt{'chgt'}</a>?</font></b> + <font size="-1"><b><a href="$chglink">$lt{'chgt'}</a>?</b></font> </td> </tr> </table> @@ -596,7 +603,7 @@ END my %sort_types = (); my %role_types = (); my %status_types = (); - &sort_filter_names(\%sort_types,\%role_types,\%status_types); + &sort_filter_names(\%sort_types,\%role_types,\%status_types,$crstype); $discussion .= '<td><font size="-1"><b>'.&mt('Sorted by').'</b>: '.$sort_types{$sortposts}.'<br />'; if (defined($env{'form.totposters'})) { @@ -639,9 +646,9 @@ END if ($dischash{$toggkey}) { my $storebutton = &mt('Save read/unread changes'); $discussion.='<td align="right">'. - '<input type="hidden" name="discsymb" value="'.$ressymb.'">'."\n". + '<input type="hidden" name="discsymb" value="'.$ressymb.'" />'."\n". '<input type="button" name="readoptions" value="'.$storebutton.'"'. - ' onClick="this.form.submit();">'."\n". + ' onclick="this.form.submit();" />'."\n". '</td>'; } $discussion .= (<<END); @@ -722,13 +729,13 @@ END &postingform_display($mode,$ressymb,$now,$subject, $comment,$outputtarget,$attachnum, $currnewattach,$currdelold, - $group); + $group,$crstype); } } else { $discussion.= &postingform_display($mode,$ressymb,$now,$subject, $comment,$outputtarget,$attachnum, - $currnewattach,$currdelold); + $currnewattach,$currdelold,'',$crstype); } } } else { @@ -738,9 +745,20 @@ END $env{'request.course.id'}. ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { if ($outputtarget ne 'tex') { - $discussion.= &send_feedback_link($ressymb,$target); + $discussion.= &send_feedback_link($ressymb,$target); + if ($env{'request.role.adv'}) { + my $close = &Apache::lonnet::EXT('resource.0.discussend',$ressymb); + if (defined($close) && $close ne '' && $close < time) { + $discussion .= ' '.&mt('(Closed for [_1] roles)', + &Apache::lonnet::plaintext('st',$crstype)); + } + } } - } + } else { + if ($outputtarget ne 'tex') { + $discussion.= '<span class="LC_feedback_link">'.&mt('This discussion is closed.').'</span>'; + } + } if ($outputtarget ne 'tex') { $discussion.= &send_message_link($ressymb); } @@ -754,9 +772,9 @@ sub send_feedback_link { my $output = '<span class="LC_feedback_link">'. ' <a href="/adm/feedback?replydisc='. &escape($ressymb).':::" '.$target.'>'. - '<img alt="" src="'. + '<img alt="" class="LC_noBorder" src="'. &Apache::loncommon::lonhttpdurl('/adm/lonMisc/chat.gif'). - '" border="0" />'.&mt('Post Discussion').'</a></span>'; + '" border="0" /><span class="LC_menubuttons_inline_text">'.&mt('Post Discussion').'</span></a></span>'; return $output; } @@ -764,55 +782,53 @@ sub send_message_link { my ($ressymb) = @_; my $output = '<span class="LC_message_link">'. ' <a href="/adm/feedback?sendmessageonly=1&symb='. - &escape($ressymb).'"><img alt="" src="'. - &Apache::loncommon::lonhttpdurl('/res/adm/pages/com.png'). - '" border="0" />'.&mt('Send Message').'</a></span>'; + &escape($ressymb).'"><img alt="" class="LC_noBorder" src="'. + &Apache::loncommon::lonhttpdurl('/res/adm/pages/feedback.png'). + '" border="0" /><span class="LC_menubuttons_inline_text">'.&mt('Send Feedback').'</span></a></span>'; return $output; } sub action_links_bar { my ($colspan,$ressymb,$visible,$newpostsflag,$group,$prevread,$markondisp) = @_; - my $discussion = '<tr><td bgcolor="#DDDDBB" colspan="'.$colspan.'">'. - '<table border="0" width="100%" bgcolor="#DDDDBB"><tr>'; + my $discussion = '<tr><td class="LC_disc_action_links_bar" colspan="'.$colspan.'">'. + '<table width="100%" class="LC_disc_action_table"><tr>'. + '<td class="LC_disc_action_left">'; my $escsymb=&escape($ressymb); if ($visible>2) { - $discussion .= '<td align="left">'. - '<a href="/adm/feedback?cmd=threadedon&symb='.$escsymb; + $discussion .= '<a href="/adm/feedback?cmd=threadedon&symb='.$escsymb; if ($newpostsflag) { - $discussion .= '&previous='.$prevread; + $discussion .= '&previous='.$prevread; } $discussion .= &group_args($group); $discussion .='">'.&mt('Threaded View').'</a> '. '<a href="/adm/feedback?cmd=threadedoff&symb='.$escsymb; if ($newpostsflag) { - $discussion .= '&previous='.$prevread; + $discussion .= '&previous='.$prevread; } $discussion .= &group_args($group); $discussion .='">'.&mt('Chronological View').'</a> - <a href= "/adm/feedback?cmd=sortfilter&symb='.$escsymb; + <a href="/adm/feedback?cmd=sortfilter&symb='.$escsymb; if ($newpostsflag) { - $discussion .= '&previous='.$prevread; + $discussion .= '&previous='.$prevread; } $discussion .= &group_args($group); $discussion .='">'.&mt('Sorting/Filtering options').'</a>'.(' ' x2); - } else { - $discussion .= '<td align="left">'; } - $discussion .='<a href= "/adm/feedback?export='.$escsymb; + $discussion .='<a href="/adm/feedback?export='.$escsymb; if ($newpostsflag) { - $discussion .= '&previous='.$prevread; + $discussion .= '&previous='.$prevread; } $discussion .= &group_args($group); $discussion .= '">'.&mt('Export').'?</a> </td>'; if ($newpostsflag) { if (!$markondisp) { - $discussion .='<td align="right"><a href="/adm/preferences?action=changediscussions'; + $discussion .='<td class="LC_disc_action_right"><a href="/adm/preferences?action=changediscussions'; $discussion .= &group_args($group); $discussion .= '">'. &mt('Preferences on what is marked as NEW'). '</a><br /><a href="/adm/feedback?markread=1&symb='.$escsymb; $discussion .= &group_args($group); - $discussion .= '">'.&mt('Mark NEW posts no longer new').'</a>'; + $discussion .= '">'.&mt('Mark NEW posts no longer new').'</a></td>'; } else { $discussion .= '<td> </td>'; } @@ -825,7 +841,8 @@ sub action_links_bar { sub postingform_display { my ($mode,$ressymb,$now,$subject,$comment,$outputtarget,$attachnum, - $currnewattach,$currdelold,$group) = @_; + $currnewattach,$currdelold,$group,$crstype) = @_; + if ($outputtarget eq 'tex') { return ''; } my $newattachmsg; my %lt = &Apache::lonlocal::texthash( 'note' => 'Note: in anonymous discussion, your name is visible only to course faculty', @@ -834,7 +851,15 @@ sub postingform_display { 'poan' => 'Post Anonymous Discussion', 'newa' => 'New attachments', ); - my $postingform = (<<ENDDISCUSS); + if ($crstype eq 'Community') { + $lt{'note'} = &mt('Note: in anonymous discussion, your name is visible only to community facilitators'); + } + my ($postingform,$textareaclass); + if (&Apache::lonhtmlcommon::htmlareabrowser()) { + $postingform = &Apache::lonhtmlcommon::htmlareaselectactive(); + $textareaclass = 'class="LC_richDefaultOff"'; + } + $postingform .= (<<ENDDISCUSS); <form action="/adm/feedback" method="post" name="mailform" enctype="multipart/form-data"> <input type="submit" name="discuss" value="$lt{'podi'}" /> <input type="submit" name="anondiscuss" value="$lt{'poan'}" /> <input type="hidden" name="symb" value="$ressymb" /> <input type="hidden" name="sendit" value="true" /> @@ -842,7 +867,7 @@ sub postingform_display { <br /><a name="newpost"></a> <font size="1">$lt{'note'}</font><br /> <b>$lt{'title'}:</b> <input type="text" name="subject" value="$subject" size="30" /><br /><br /> -<textarea name="comment" cols="80" rows="14" wrap="hard">$comment</textarea> +<textarea name="comment" cols="80" rows="14" id="comment" $textareaclass>$comment</textarea> ENDDISCUSS if ($env{'form.origpage'}) { $postingform .= '<input type="hidden" name="origpage" value="'. @@ -861,31 +886,29 @@ ENDDISCUSS } my $blockblog = &Apache::loncommon::blocking_status('blogs'); if (!$blockblog) { - $postingform .= &add_blog_checkbox(); + $postingform .= &add_blog_checkbox($crstype); } $postingform .= "</form>\n"; - if ($outputtarget ne 'tex') { - $postingform .= &generate_attachments_button('',$attachnum,$ressymb, + $postingform .= &generate_attachments_button('',$attachnum,$ressymb, $now,$currnewattach, $currdelold,'',$mode, $blockblog); - if ((ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)) { - $newattachmsg = '<br /><b>'.$lt{'newa'}.'</b><br />'; - if (@{$currnewattach} > 1) { - $newattachmsg .= '<ol>'; - foreach my $item (@{$currnewattach}) { - $item =~ m#.*/([^/]+)$#; - $newattachmsg .= '<li><a href="'.$item.'">'.$1.'</a></li>'."\n"; - } - $newattachmsg .= '</ol>'."\n"; - } else { - $$currnewattach[0] =~ m#.*/([^/]+)$#; - $newattachmsg .= '<a href="'.$$currnewattach[0].'">'.$1.'</a><br />'."\n"; - } - } - $postingform .= $newattachmsg; - $postingform .= &generate_preview_button(); + if ((ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)) { + $newattachmsg = '<br /><b>'.$lt{'newa'}.'</b><br />'; + if (@{$currnewattach} > 1) { + $newattachmsg .= '<ol>'; + foreach my $item (@{$currnewattach}) { + $item =~ m#.*/([^/]+)$#; + $newattachmsg .= '<li><a href="'.$item.'">'.$1.'</a></li>'."\n"; + } + $newattachmsg .= '</ol>'."\n"; + } else { + $$currnewattach[0] =~ m#.*/([^/]+)$#; + $newattachmsg .= '<a href="'.$$currnewattach[0].'">'.$1.'</a><br />'."\n"; + } } + $postingform .= $newattachmsg; + $postingform .= &generate_preview_button(); return $postingform; } @@ -1010,6 +1033,7 @@ sub build_posting_display { $contrib{$idx.':senderdomain'}).' ('. $contrib{$idx.':sendername'}.':'. $contrib{$idx.':senderdomain'}.')'; + $sender = '<b>'.$sender.'</b>'; if ($contrib{$idx.':anonymous'}) { $sender.=' <font color="red"><b>['.$$anonhash{$key}.']</b></font> '. $screenname; @@ -1046,12 +1070,12 @@ sub build_posting_display { } else { @{$$namesort{$lastname}{$firstname}} = ("$idx"); } - if (&editing_allowed($escsymb.':::'.$idx,$group)) { + if ((&editing_allowed($escsymb.':::'.$idx,$group)) && ($outputtarget ne 'tex')) { if (($env{'user.domain'} eq $contrib{$idx.':senderdomain'}) && ($env{'user.name'} eq $contrib{$idx.':sendername'})) { $sender.=' <a href="/adm/feedback?editdisc='. $escsymb.':::'.$idx; if ($$newpostsflag) { - $sender .= '&previous='.$prevread; + $sender .= '&previous='.$prevread; } $sender .= &group_args($group); $sender .= '" '.$target.'>'.&mt('Edit').'</a>'; @@ -1063,13 +1087,13 @@ sub build_posting_display { } } } - if ($seeid) { + if (($seeid) && ($outputtarget ne 'tex')) { if ($hidden) { unless ($studenthidden) { $sender.=' <a href="/adm/feedback?unhide='. $escsymb.':::'.$idx; if ($$newpostsflag) { - $sender .= '&previous='.$prevread; + $sender .= '&previous='.$prevread; } $sender .= '">'.&mt('Make Visible').'</a>'; } @@ -1077,7 +1101,7 @@ sub build_posting_display { $sender.=' <a href="/adm/feedback?hide='. $escsymb.':::'.$idx; if ($$newpostsflag) { - $sender .= '&previous='.$prevread; + $sender .= '&previous='.$prevread; } $sender .= &group_args($group); $sender .= '">'.&mt('Hide').'</a>'; @@ -1093,6 +1117,7 @@ sub build_posting_display { } else { $sender='<i>'.$$anonhash{$key}.'</i>'; } + $sender = '<b>'.$sender.'</b>'; # Set up for sorting by domain, then username for anonymous unless (defined($$usernamesort{'__anon'})) { %{$$usernamesort{'__anon'}} = (); @@ -1112,13 +1137,13 @@ sub build_posting_display { @{$$namesort{'__anon'}{'__anon'}} = ("$idx"); } } - if (&discussion_open($status)) { + if ((&discussion_open($status)) && ($outputtarget ne 'tex')) { if (($group ne '') && (&check_group_priv($group,'pgd') eq 'ok')) { $sender.=' <a href="/adm/feedback?replydisc='. $escsymb.':::'.$idx; if ($$newpostsflag) { - $sender .= '&previous='.$prevread; + $sender .= '&previous='.$prevread; } $sender .= &group_args($group); $sender .= '" '.$target.'>'.&mt('Reply').'</a>'; @@ -1129,16 +1154,16 @@ sub build_posting_display { $sender.=' <a href="/adm/feedback?replydisc='. $escsymb.':::'.$idx; if ($$newpostsflag) { - $sender .= '&previous='.$prevread; + $sender .= '&previous='.$prevread; } $sender .= '" '.$target.'>'.&mt('Reply').'</a>'; } } - if ($viewgrades) { - $vgrlink=&Apache::loncommon::submlink('Submissions', + if (($viewgrades) && ($outputtarget ne 'tex')) { + $vgrlink=&Apache::loncommon::submlink(&mt('Submissions'), $contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$ressymb); } - if ($$dischash{$readkey}=~/\.$idx\./) { + if (($$dischash{$readkey}=~/\.$idx\./) && ($outputtarget ne 'tex')) { $ctlink = '<label><b>'.&mt('Mark unread').'?</b> <input type="checkbox" name="postunread_'.$idx.'" /></label>'; } else { $ctlink = '<label><b>'.&mt('Mark read').'?</b> <input type="checkbox" name="postread_'.$idx.'" /></label>'; @@ -1166,7 +1191,7 @@ sub build_posting_display { $$imsitems{$idx}{'attach'}=$attachtxt{$numoldver}; $$imsitems{$idx}{'timestamp'}=$contrib{$idx.':timestamp'}; $$imsitems{$idx}{'sender'}=$plainname.' ('. - $contrib{$idx.':sendername'}.' at '. + $contrib{$idx.':sendername'}.':'. $contrib{$idx.':senderdomain'}.')'; $$imsitems{$idx}{'isanonymous'}='false'; if ($contrib{$idx.':anonymous'}) { @@ -1239,24 +1264,24 @@ sub build_posting_display { if ($prevread > 0 && $prevread <= $posttime) { $$newitem{$idx} = 1; $$discussionitems[$idx] .= ' - <p><table border="0" width="100%"> - <tr><td align="left"><font color="#FF0000"><b>'.&mt('NEW').'</b></font></td>'; + <table border="0" width="100%"> + <tr><td align="left"><font color="#FF0000"><b>'.&mt('NEW').' </b></font></td>'; } else { $$newitem{$idx} = 0; $$discussionitems[$idx] .= ' - <p><table border="0" width="100%"> + <table border="0" width="100%"> <tr><td align="left"> </td>'; } - $$discussionitems[$idx] .= '<td align ="left"> '. + $$discussionitems[$idx] .= '<td align="left"> '. '<b>'.$subject.'</b> '. - $sender.'</b> '.$vgrlink.' ('. + $sender.' '.$vgrlink.' ('. &Apache::lonlocal::locallocaltime($posttime).')</td>'; if ($$dischash{$toggkey}) { $$discussionitems[$idx].='<td align="right"> '. $ctlink.'</td>'; } $$discussionitems[$idx].= '</tr></table><blockquote>'. - $message.'</blockquote></p>'; + $message.'</blockquote>'; if ($contrib{$idx.':history'}) { my @postversions = (); $$discussionitems[$idx] .= &mt('This post has been edited by the author.'); @@ -1363,7 +1388,7 @@ sub get_post_contents { $$plainname, $$contrib{$idx.':sendername'}, $$contrib{$idx.':senderdomain'}).' ('. - $$contrib{$idx.':sendername'}.' at '. + $$contrib{$idx.':sendername'}.':'. $$contrib{$idx.':senderdomain'}.')'; my $attachmenturls = $$contrib{$idx.':attachmenturl'}; my @postversions = (); @@ -1391,7 +1416,9 @@ sub get_post_contents { my ($timesent,$attachmsg); my %currattach = (); $timesent = &Apache::lonlocal::locallocaltime($postversions[$i]); - &newline_to_br(\$messages->{$i}); + unless (&contains_block_html($messages->{$i})) { + &newline_to_br(\$messages->{$i}); + } $$messages{$i}=&Apache::lontexconvert::msgtexconverted($$messages{$i}); $$subjects{$i}=~s/\n/\<br \/\>/g; $$subjects{$i}=&Apache::lontexconvert::msgtexconverted($$subjects{$i}); @@ -1405,7 +1432,7 @@ sub get_post_contents { foreach my $key (sort(keys(%currattach))) { if ($$allattachments{$key}{'filename'} =~ m-^/uploaded/([^/]+/[^/]+)(/feedback)?(/?\d*)/([^/]+)$-) { my $fname = $1.$3.'/'.$4; - $$imsfiles{$idx}{$i} .= '<file href="'.$fname.'">'."\n"; + $$imsfiles{$idx}{$i} .= '<file href="'.$fname.'" />'."\n"; $$attachtxt{$i}.= '<a href="'.$fname.'">'.$4.'</a><br />'; } } @@ -1478,7 +1505,6 @@ sub mail_screen { } my %lt = &Apache::lonlocal::texthash( - 'plch' => 'Please check at least one of the following feedback types:', 'myqu' => 'My question/comment/feedback:', 'title' => 'Title', 'reta' => 'Retained attachments', @@ -1660,13 +1686,27 @@ END </script> END + my ($textareaheader,$textareaclass); + if (&Apache::lonhtmlcommon::htmlareabrowser()) { + $textareaheader = &Apache::lonhtmlcommon::htmlareaselectactive(); + $textareaclass = 'class="LC_richDefaultOff"'; + } + + # Breadcrumbs + my $brcrum = [{'href' => '', + 'text' => 'Resource Feedback and Discussion'}]; + my %onload = ('onload' => 'window.focus();setposttype();'); my $start_page= &Apache::loncommon::start_page('Resource Feedback and Discussion',$js, - {'add_entries' => \%onload}); + {'add_entries' => \%onload, + 'bread_crumbs' => $brcrum,}); if ($quote ne '') { - &newline_to_br(\$quote); + $quote = &HTML::Entities::decode($quote); + unless (&contains_block_html($quote)) { + &newline_to_br(\$quote); + } $quote='<blockquote>'.&Apache::lontexconvert::msgtexconverted($quote).'</blockquote>'; } @@ -1684,24 +1724,24 @@ END END } elsif ($env{'form.editdisc'}) { $r->print(<<END); -<input type="hidden" name="editdisc" value ="$env{'form.editdisc'}" /> -<input type="hidden" name="parentmsg" value ="$parentmsg" /> +<input type="hidden" name="editdisc" value="$env{'form.editdisc'}" /> +<input type="hidden" name="parentmsg" value="$parentmsg" /> END } $r->print(<<END); -$lt{'plch'} $options<hr /> $quote -<p>$lt{'myqu'}</p> +<p>$lt{'myqu'} +$textareaheader +</p> <p> $latexHelp </p> <p> $lt{'title'}: <input type="text" name="subject" size="30" value="$subject" /></p> <p> -<textarea name="comment" id="comment" cols="60" rows="10" wrap="hard">$comment +<textarea name="comment" id="comment" cols="60" rows="10" $textareaclass>$comment </textarea></p> -<p> END if ( ($env{'form.editdisc'}) || ($env{'form.replydisc'}) ) { if ($env{'form.origpage'}) { @@ -1723,6 +1763,7 @@ END } } else { $r->print(<<END); +<p> $lt{'atta'} $attachmaxtext: <input type="file" name="attachment" /> </p> END @@ -1736,7 +1777,7 @@ END $r->print(<<END); <p> <input type="hidden" name="sendit" value="1" /> -<input type="button" value="$send" onClick='gosubmit();' /> +<input type="button" value="$send" onclick='gosubmit();' /> </p> </form> END @@ -1777,7 +1818,6 @@ END } } $r->print(&generate_preview_button(). - &Apache::lonhtmlcommon::htmlareaselectactive('comment'). &Apache::loncommon::end_page()); } @@ -1927,7 +1967,7 @@ END &Apache::loncommon::end_page(); $r->print(<<END); $start_page -<form name="modifydisp" method="POST" action="/adm/feedback"> +<form name="modifydisp" method="post" action="/adm/feedback"> $lt{'sdpf'}<br/> $lt{'prca'} <ol><li>$lt{'whpo'}</li><li>$lt{'unwh'}</li><li>$lt{'wipa'}</li></ol> <br /> END @@ -1943,9 +1983,9 @@ END $r->print(<<END); <td>$lt{'disa'}</td> <td>$lt{$discdisp}</td> - <td><label><input type="checkbox" name="discdisp" onClick="discdispChk('0')" /> $lt{'chgt'} "$dispchangeA"</label> + <td><label><input type="checkbox" name="discdisp" onclick="discdispChk('0')" /> $lt{'chgt'} "$dispchangeA"</label> <br /> - <label><input type="checkbox" name="discdisp" onClick="discdispChk('1')" /> $lt{'chgt'} "$dispchangeB"</label> + <label><input type="checkbox" name="discdisp" onclick="discdispChk('1')" /> $lt{'chgt'} "$dispchangeB"</label> </td> END $r->print(&Apache::loncommon::end_data_table_row()); @@ -1960,7 +2000,7 @@ END $r->print(<<END); <td>$lt{'dotm'}</td> <td>$lt{$disctogg}</td> - <td><label><input type="checkbox" name="disctogg" onClick="discdispChk('2')" />$lt{'chgt'} "$toggchange"</label></td> + <td><label><input type="checkbox" name="disctogg" onclick="discdispChk('2')" />$lt{'chgt'} "$toggchange"</label></td> END my $save = &mt('Save'); $r->print(&Apache::loncommon::end_data_table_row()); @@ -1970,11 +2010,11 @@ END <br /> <input type="hidden" name="symb" value="$symb" /> <input type="hidden" name="previous" value="$previous" /> -<input type="hidden" name="$dispchgA" value=""/> -<input type="hidden" name="$dispchgB" value=""/> -<input type="hidden" name="$markchg" value=""/> +<input type="hidden" name="$dispchgA" value="" /> +<input type="hidden" name="$dispchgB" value="" /> +<input type="hidden" name="$markchg" value="" /> <input type="hidden" name="$toggchg" value="" /> -<input type="button" name="sub" value="$save" onClick="javascript:setDisp()" /> +<input type="button" name="sub" value="$save" onclick="javascript:setDisp()" /> END if (exists($env{'form.group'})) { $r->print('<input type="hidden" name="group" value="'.$env{'form.group'}.'" />'); @@ -2005,7 +2045,14 @@ sub print_sortfilter_options { my $group_sel = ''; my $numgroupvis = 5; my %sectioncount = &Apache::loncommon::get_sections(); - + my @courseroles = qw(st ad ep ta in); + my $crstype = &Apache::loncommon::course_type(); + my $ccrole = 'cc'; + if ($crstype eq 'Community') { + $ccrole = 'co'; + } + push(@courseroles,$ccrole); + if ($env{'request.course.sec'} !~ /^\s*$/) { #Restrict section choice to current section @sections = ('all',$env{'request.course.sec'}); $numvisible = 2; @@ -2068,7 +2115,7 @@ sub print_sortfilter_options { my %sort_types = (); my %role_types = (); my %status_types = (); - &sort_filter_names(\%sort_types,\%role_types,\%status_types); + &sort_filter_names(\%sort_types,\%role_types,\%status_types,$crstype); my $js = <<END; <script type="text/javascript"> @@ -2115,22 +2162,22 @@ END $r->print(<<END); $start_page -<form name="modifyshown" method="POST" action="/adm/feedback"> +<form name="modifyshown" method="post" action="/adm/feedback"> <b>$lt{'diso'}</b><br/> $lt{'prca'} <br /><br /> <table border="0"> <tr> - <td><b>$lt{'soor'}</b></td> - <td> </td> - <td><b>$lt{'sprs'}</b></td> - <td> </td> - <td><b>$lt{'spur'}</b></td> - <td> </td> - <td><b>$lt{'spse'}</b></td> - <td> </td> - <td><b>$lt{'spgr'}</b></td> - <td> </td> - <td><b>$lt{'psub'}</b></td> + <th>$lt{'soor'}</th> + <th> </th> + <th>$lt{'sprs'}</th> + <th> </th> + <th>$lt{'spur'}</th> + <th> </th> + <th>$lt{'spse'}</th> + <th> </th> + <th>$lt{'spgr'}</th> + <th> </th> + <th>$lt{'psub'}</th> </tr> <tr> <td align="center" valign="top"> @@ -2157,10 +2204,11 @@ $start_page <select name="rolefilter" multiple="multiple" size="5"> <option value="all">$role_types{'all'}</option> <option value="st">$role_types{'st'}</option> - <option value="cc">$role_types{'cc'}</option> + <option value="$ccrole">$role_types{$ccrole}</option> <option value="in">$role_types{'in'}</option> <option value="ta">$role_types{'ta'}</option> <option value="ep">$role_types{'ep'}</option> + <option value="ad">$role_types{'ad'}</option> <option value="cr">$role_types{'cr'}</option> </select> </td> @@ -2184,7 +2232,7 @@ $start_page <br /> <input type="hidden" name="previous" value="$previous" /> <input type="hidden" name="applysort" value="$symb" /> -<input type="button" name="sub" value="$lt{'stor'}" onClick="verifyFilter()" /> +<input type="button" name="sub" value="$lt{'stor'}" onclick="verifyFilter()" /> END if (exists($env{'form.group'})) { $r->print('<input type="hidden" name="group" value="'.$env{'form.group'}.'" />'); @@ -2307,7 +2355,7 @@ END <br /> <input type="hidden" name="sortposts" value="$sortposts" /> <input type="hidden" name="userpick" value="$symb" /> -<input type="button" name="store" value="Display posts" onClick="javascript:document.pickpostersform.submit()" /> +<input type="button" name="store" value="Display posts" onclick="javascript:document.pickpostersform.submit()" /> </form> $end_page END @@ -2379,7 +2427,7 @@ sub fail_redirect { my ($r,$feedurl) = @_; if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' }; my %lt = &Apache::lonlocal::texthash( - 'sorr' => 'Sorry, no recipients ...', + 'sorr' => 'Sorry, no recipients ...', ); my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif'); $r->print(&Apache::loncommon::start_page('Feedback not sent',undef, @@ -2410,7 +2458,7 @@ sub redirect_back { if ($previous > 0) { $qrystr = 'previous='.$previous; if ($feedurl =~ /\?register=1/) { - $feedurl .= '&'.$qrystr; + $feedurl .= '&'.$qrystr; } else { $feedurl .= '?'.$qrystr; } @@ -2419,18 +2467,18 @@ sub redirect_back { if (defined($sort)) { my $sortqry = 'sortposts='.$sort; if (($feedurl =~ /\?register=1/) || ($feedurl =~ /\?previous=/)) { - $feedurl .= '&'.$sortqry; + $feedurl .= '&'.$sortqry; } else { $feedurl .= '?'.$sortqry; } $sorttag = '<input type="hidden" name="sortposts" value="'.$sort.'" />'; if (defined($numpicks)) { my $userpickqry = 'totposters='.$numpicks; - $feedurl .= '&'.$userpickqry; + $feedurl .= '&'.$userpickqry; $userpicktag = '<input type="hidden" name="totposters" value="'.$numpicks.'" />'; } else { if (ref($sectionpick) eq 'ARRAY') { - $feedurl .= '§ionpick='; + $feedurl .= '&sectionpick='; $sectag .= '<input type="hidden" name="sectionpick" value="'; foreach my $sec (@{$sectionpick}) { $feedurl .= $sec.','; @@ -2440,11 +2488,11 @@ sub redirect_back { $sectag =~ s/,$//; $sectag .= '" />'; } else { - $feedurl .= '§ionpick='.$sectionpick; + $feedurl .= '&sectionpick='.$sectionpick; $sectag = '<input type="hidden" name="sectionpick" value="'.$sectionpick.'" />'; } if (ref($grouppick) eq 'ARRAY') { - $feedurl .= '&grouppick='; + $feedurl .= '&grouppick='; $sectag .= '<input type="hidden" name="grouppick" value="'; foreach my $grp (@{$grouppick}) { $feedurl .= $grp.','; @@ -2454,11 +2502,11 @@ sub redirect_back { $grptag =~ s/,$//; $grptag .= '" />'; } else { - $feedurl .= '&grouppick='.$grouppick; + $feedurl .= '&grouppick='.$grouppick; $grptag = '<input type="hidden" name="grouppick" value="'.$grouppick.'" />'; } if (ref($rolefilter) eq 'ARRAY') { - $feedurl .= '&rolefilter='; + $feedurl .= '&rolefilter='; $roletag .= '<input type="hidden" name="rolefilter" value="'; foreach my $role (@{$rolefilter}) { $feedurl .= $role.','; @@ -2468,16 +2516,17 @@ sub redirect_back { $roletag =~ s/,$//; $roletag .= '" />'; } else { - $feedurl .= '&rolefilter='.$rolefilter; + $feedurl .= '&rolefilter='.$rolefilter; $roletag = '<input type="hidden" name="rolefilter" value="'.$rolefilter.'" />'; } - $feedurl .= '&statusfilter='.$statusfilter; + $feedurl .= '&statusfilter='.$statusfilter; $statustag ='<input type="hidden" name="statusfilter" value="'.$statusfilter.'" />'; } } my $grouptag; if ($group ne '') { - $grouptag = '<input type="hidden" name="group" value="'.$group.'" />'; my $refarg; + $grouptag = '<input type="hidden" name="group" value="'.$group.'" />'; + my $refarg; if (exists($env{'form.ref'})) { $refarg = '&ref='.$env{'form.ref'}; $grouptag .= '<input type="hidden" name="ref" value="'.$env{'form.ref'}.'" />'; @@ -2491,10 +2540,6 @@ sub redirect_back { &Apache::lonenc::check_encrypt(\$feedurl); my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif'); my %onload; - if ($env{'environment.remote'} ne 'off') { - $onload{'onload'} = - "if (window.name!='loncapaclient') { this.document.reldt.submit(); self.window.close(); }"; - } my $start_page= &Apache::loncommon::start_page('Feedback sent',undef, {'redirect' => [0,$feedurl], @@ -2525,13 +2570,9 @@ ENDREDIR sub no_redirect_back { my ($r,$feedurl) = @_; - my $nofeed=&mt('Sorry, no feedback possible on this resource ...'); + my $nofeed=&mt('Sorry, no feedback possible on this resource ...'); my %onload; - if ($env{'environment.remote'} ne 'off') { - $onload{'onload'} = - "if (window.name!='loncapaclient') { self.window.close(); }"; - } my %body_options = ('only_body' => 1, 'bgcolor' => '#FFFFFF', @@ -2559,6 +2600,22 @@ ENDNOREDIRTWO sub screen_header { my ($feedurl,$symb) = @_; + my $crscontent = &mt('Question/Comment/Feedback about course content'); + my $crspolicy = &mt('Question/Comment/Feedback about course policy'); + my $contribdisc = &mt('Contribution to course discussion of resource'); + my $anoncontrib = &mt('Anonymous contribution to course discussion of resource'); + my $namevis = &mt('name only visible to course faculty'); + my $crstype; + if ($env{'request.course.id'}) { + $crstype = &Apache::loncommon::course_type(); + if ($crstype eq 'Community') { + $crscontent = &mt('Question/Comment/Feedback about community content'); + $crspolicy = &mt('Question/Comment/Feedback about community policy'); + $contribdisc = &mt('Contribution to community discussion of resource'); + $anoncontrib = &mt('Anonymous contribution to community discussion of resource'); + $namevis = &mt('name only visible to community facilitators'); + } + } my $msgoptions=''; my $discussoptions=''; unless (($env{'form.replydisc'}) || ($env{'form.editdisc'})) { @@ -2579,13 +2636,13 @@ sub screen_header { if (&feedback_available(0,1)) { $msgoptions.= '<p><label><input type="radio" name="discuss" value="course" /> '. - ($optionhash{'comment'}?$optionhash{'comment'}:&mt('Question/Comment/Feedback about course content')). + ($optionhash{'comment'}?$optionhash{'comment'}:$crscontent). '</label></p>'; } if (&feedback_available(0,0,1)) { $msgoptions.= '<p><label><input type="radio" name="discuss" value="policy" /> '. - ($optionhash{'policy'}?$optionhash{'policy'}:&mt('Question/Comment/Feedback about course policy')). + ($optionhash{'policy'}?$optionhash{'policy'}:$crspolicy). '</label></p>'; } } @@ -2596,20 +2653,27 @@ sub screen_header { $env{'request.course.id'}. ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { $discussoptions='<label><input type="radio" name="discuss" value="nonanon" checked="checked" /> '. - &mt('Contribution to course discussion of resource'); - $discussoptions.='</label><br /><label><input type="radio" name="discuss" value="anon" /> '. - &mt('Anonymous contribution to course discussion of resource'). - ' <i>('.&mt('name only visible to course faculty').')</i></label> '. + $contribdisc. + '</label><br /><label><input type="radio" name="discuss" value="anon" /> '. + $anoncontrib. + ' <i>('.$namevis.')</i></label> '. '<a href="/adm/preferences?action=changescreenname">'.&mt('Change Screenname').'</a>'; my $blockblog = &Apache::loncommon::blocking_status('blogs'); if (!$blockblog) { - $discussoptions.= &add_blog_checkbox(); + $discussoptions.= &add_blog_checkbox($crstype); } } } - if ($msgoptions) { $msgoptions='<h2><img src="'.&Apache::loncommon::lonhttpdurl('/res/adm/pages/com.png').'" />'.&mt('Sending Messages').'</h2>'.$msgoptions; } + if ($msgoptions) { + $msgoptions='<h2><img src="'.&Apache::loncommon::lonhttpdurl('/res/adm/pages/feedback.png').'" />' + .' '.&mt('Send Feedback').'</h2><p>'.&Apache::lonhtmlcommon::coursepreflink(&mt('Feedback Settings'),'feedback').'</p>' + .$msgoptions; + } if ($discussoptions) { - $discussoptions='<h2><img src="'.&Apache::loncommon::lonhttpdurl('/adm/lonMisc/chat.gif').'" />'.&mt('Discussion Contributions').'</h2>'.$discussoptions; } + $discussoptions='<h2><img src="'.&Apache::loncommon::lonhttpdurl('/adm/lonMisc/chat.gif').'" alt="" />' + .' '.&mt('Discussion Contributions').'</h2><p>'.&Apache::lonhtmlcommon::coursepreflink(&mt('Discussion Settings'),'discussion').'</p>' + .$discussoptions; + } return $msgoptions.$discussoptions; } @@ -2627,9 +2691,7 @@ sub resource_output { } sub clear_out_html { - my ($message,$override,$ignore_htmlarea)=@_; - if (!$ignore_htmlarea - && !&Apache::lonhtmlcommon::htmlareablocked()) { return $message; } + my ($message,$override)=@_; # Always allow the <m>-tag my %html=(M=>1); # Check if more is allowed @@ -2638,11 +2700,12 @@ sub clear_out_html { ($override)) { # allows <B> <I> <P> <A> <LI> <OL> <UL> <EM> <BR> <TT> <STRONG> # <BLOCKQUOTE> <DIV .*> <DIV> <IMG> <M> <SPAN> <H1> <H2> <H3> <H4> <SUB> - # <SUP> + # <SUP> <TABLE> <TR> <TD> <TH> <TBODY> %html=(B=>1, I=>1, P=>1, A=>1, LI=>1, OL=>1, UL=>1, EM=>1, - BR=>1, TT=>1, STRONG=>1, BLOCKQUOTE=>1, DIV=>1, IMG=>1, - M=>1, ALGEBRA=>1, SUB=>1, SUP=>1, SPAN=>1, - H1=>1, H2=>1, H3=>1, H4=>1, H5=>1); + BR=>1, TT=>1, STRONG=>1, BLOCKQUOTE=>1, PRE=>1, DIV=>1, IMG=>1, + M=>1, CHEM=>1, ALGEBRA=>1, SUB=>1, SUP=>1, SPAN=>1, + H1=>1, H2=>1, H3=>1, H4=>1, H5=>1, H6=>1, + TABLE=>1, TR=>1, TD=>1, TH=>1, TBODY=>1); } # Do the substitution of everything that is not explicitly allowed $message =~ s/\<(\/?\s*(\w+)[^\>\<]*)/ @@ -2659,6 +2722,9 @@ sub assemble_email { 'orig' => 'Original screen output (if applicable)', 'corr' => 'Correct Answer(s) (if applicable)', ); + if (&Apache::loncommon::course_type() eq 'Community') { + $lt{'prev'} = &mt('Previous attempts of member (if applicable)'); + } my $email=<<"ENDEMAIL"; $message ENDEMAIL @@ -2885,7 +2951,7 @@ sub show_preview { &newline_to_br(\$message); $message=&Apache::lonspeller::markeduptext($message); $message=&Apache::lontexconvert::msgtexconverted($message); - my $subject=&clear_out_html($env{'form.subject'},undef,1); + my $subject=&clear_out_html($env{'form.subject'}); $subject=~s/\n/\<br \/\>/g; $subject=&Apache::lontexconvert::msgtexconverted($subject); @@ -2905,6 +2971,31 @@ sub show_preview { ); } +sub contains_block_html { + my ($message)=@_; + return ($message =~ m{ + <(br|h1|h2|h3|h4|h5|h6|p|ol|ul|table|pre|address|blockquote|center|div) + \s* + (\w+\=['"]\w+['"])* + \s* + ( + \s*/>| + >.*</\1\s*> + )}xs + ); +} + +sub tidy_html { + my ($message)=@_; +# my $tidy = HTML::Tidy::libXML->new(); +# my $xhtml = $tidy->clean($message, 'utf-8', 1); +# $xhtml =~ m/<body>(.*)<\/body>/is; +# my $clean = $1; +# # remove any empty block-level tags +# $clean =~ s/<(table|p|div|tbody|blockquote|m|pre|algebra|center|ol|ul|span|h1|h2|h3|h4|h5|h6)\s*\/>//i; +# $message=$clean; + return $message; +} sub newline_to_br { my ($message)=@_; @@ -2935,10 +3026,10 @@ sub generate_preview_button { return(<<ENDPREVIEW); <br /> <form name="preview" action="/adm/feedback?preview=1" method="post" target="preview"> -<input type="hidden" name="subject"> +<input type="hidden" name="subject" /> <input type="hidden" name="comment" /> <input type="button" value="$pre" -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();" /> +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();" /> </form> ENDPREVIEW } @@ -2964,11 +3055,15 @@ sub modify_attachments { </script> END + # Breadcrumbs + my $brcrum = [{'href' => '', + 'text' => 'Discussion Post Attachments'}]; my $start_page = - &Apache::loncommon::start_page('Discussion Post Attachments',$js); + &Apache::loncommon::start_page('Discussion Post Attachments',$js, + {'bread_crumbs' => $brcrum,}); my $orig_subject = &unescape($env{'form.subject'}); - my $subject=&clear_out_html($orig_subject,undef,1); + my $subject=&clear_out_html($orig_subject); $subject=~s/\n/\<br \/\>/g; $subject=&Apache::lontexconvert::msgtexconverted($subject); my $timestamp=$env{'form.timestamp'}; @@ -2993,7 +3088,7 @@ $toolarge <table class="LC_data_table"> <tr> <td colspan="2"> - <b>Subject:</b> $subject</b><br /><br /> + <b>Subject:</b> <b>$subject</b><br /><br /> END if ($idx) { if ($attachmenturls) { @@ -3021,7 +3116,7 @@ END </td></tr> <tr> <td> - $lt{'adda'}</td><td><input type="file" name="addnewattach" /><input type="button" name="upload" value="Upload" onClick="this.form.submit()" /> + $lt{'adda'}</td><td><input type="file" name="addnewattach" /><input type="button" name="upload" value="Upload" onclick="this.form.submit()" /> </td> </tr> <tr> @@ -3044,7 +3139,7 @@ END $r->print('<input type="hidden" name="deloldattach" value="'.$item.'" />'."\n"); } $r->print(<<END); - <input type="button" name="rtntoedit" value="$lt{'stch'}" onClick="setAction()"/> + <input type="button" name="rtntoedit" value="$lt{'stch'}" onclick="setAction()" /> </form> $end_page END @@ -3091,7 +3186,7 @@ sub generate_attachments_button { <br /> <form name="attachment" action="/adm/feedback?attach=$ressymb" method="post"> $lt{'clic'}: <input type="button" value="$att" -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); +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); END if (!$blockblog) { $response .= 'setblogvalue();'; @@ -3106,8 +3201,8 @@ this.form.submit();" /> <input type="hidden" name="timestamp" value="$now" /> <input type="hidden" name="subject" /> <input type="hidden" name="comment" /> -<input type="hidden" name="blog" value = "0" /> -<input type="hidden" name="discuss" value = "0" /> +<input type="hidden" name="blog" value="0" /> +<input type="hidden" name="discuss" value="0" /> <input type="hidden" name="numoldver" value="$numoldver" /> ENDATTACH if (defined($deloldattach)) { @@ -3236,7 +3331,8 @@ sub construct_attachmenturl { } sub add_blog_checkbox { - my ($checkstatus); + my ($crstype) = @_; + my $checkstatus; if ($env{'form.blog'}) { $checkstatus = 'checked="checked"'; } @@ -3250,8 +3346,13 @@ function setblogvalue() { } } </script><br /> -<label><input type="checkbox" name="blog" '.$checkstatus.' /> '. -&mt('Add to my public course blog').'</label><br />'."\n"; +<label><input type="checkbox" name="blog" '.$checkstatus.' /> '; + if ($crstype eq 'Community') { + $output .= &mt('Add to my public community blog'); + } else { + $output .= &mt('Add to my public course blog'); + } + $output .= '</label><br />'."\n"; return $output; } @@ -3275,8 +3376,9 @@ sub has_discussion { } sub sort_filter_names { - my ($sort_types,$role_types,$status_types) = @_; - %{$sort_types} = ( + my ($sort_types,$role_types,$status_types,$crstype) = @_; + if (ref($sort_types) eq 'HASH') { + %{$sort_types} = ( ascdate => 'Date order - oldest first', descdate => 'Date order - newest first', thread => 'Threaded', @@ -3284,22 +3386,28 @@ sub sort_filter_names { username => 'By domain and username', lastfirst => 'By last name, first name' ); - %{$role_types} = ( - all => 'All roles', - st => 'Students', - cc => 'Course Coordinators', - in => 'Instructors', - ta => 'TAs', - ep => 'Exam proctors', - ad => 'Administrators', - cr => 'Custom roles' - ); - %{$status_types} = ( + } + my @courseroles = qw(st in ta ep ad); + if ($crstype eq 'Community') { + push(@courseroles,'co'); + } else { + push(@courseroles,'cc'); + } + if (ref($role_types) eq 'HASH') { + foreach my $role (@courseroles) { + $role_types->{$role} = &Apache::lonnet::plaintext($role,$crstype); + } + $role_types->{'all'} = 'All roles'; + $role_types->{'cr'} = 'Custom role'; + } + if (ref($status_types) eq 'HASH') { + %{$status_types} = ( all => 'Roles of any status', Active => 'Only active roles', Expired => 'Only past roles', Future => 'Only future roles', ); + } } sub handler { @@ -3316,7 +3424,7 @@ sub handler { ['hide','unhide','deldisc','postdata','preview','replydisc','editdisc','cmd','symb','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navtime','navmaps','navurl','sortposts','applysort','rolefilter','statusfilter','sectionpick','groupick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export','sendmessageonly','group','ref']); my $group = $env{'form.group'}; my %attachmax = ( - text => '(128 KB max size)', + text => &mt('(128 KB max size)'), num => 131072, ); if ($env{'form.editdisc'}) { @@ -3361,7 +3469,13 @@ sub handler { &Apache::loncommon::no_cache($r); $r->send_http_header; - $r->print(&Apache::loncommon::start_page('Discussion Post Versions')); + # Breadcrumbs + my $brcrum = [{'href' => '', + 'text' => 'Discussion Post Versions'}]; + + $r->print(&Apache::loncommon::start_page('Discussion Post Versions',undef, + {'bread_crumbs' => $brcrum,}) + ); my $crs='/'.$env{'request.course.id'}; if ($env{'request.course.sec'}) { @@ -3465,10 +3579,6 @@ sub handler { $r->send_http_header; my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif'); my %onload; - if ($env{'environment.remote'} ne 'off') { - $onload{'onload'} = - "if (window.name!='loncapaclient') { this.document.reldt.submit(); self.window.close(); }"; - } my $start_page= &Apache::loncommon::start_page('New posts marked as read',undef, @@ -3801,8 +3911,7 @@ ENDREDIR my ($typestyle,%to) = &Apache::lonmsg::decide_receiver($feedurl); # Actually send mail - my ($status,$numsent)=&send_msg(&clear_out_html($env{'form.subject'}, - undef,1), + my ($status,$numsent)=&send_msg(&clear_out_html($env{'form.subject'}), $feedurl,$email,$citations, $attachmenturl,$usersymb,%to); @@ -3811,7 +3920,7 @@ ENDREDIR if ( ($env{'form.discuss'} ne '' && $env{'form.discuss'} !~ /^(?:author|question|course|policy)/) || $env{'form.anondiscuss'} ne '') { - my $subject = &clear_out_html($env{'form.subject'},undef,1); + my $subject = &clear_out_html($env{'form.subject'}); my $anonmode=($env{'form.discuss'} eq 'anon' || $env{'form.anondiscuss'} ); $typestyle.=&adddiscuss($symb,$message,$anonmode,$attachmenturl, $subject); @@ -3822,12 +3931,16 @@ ENDREDIR my $blog=''; if ($env{'form.blog'}) { - my $subject = &clear_out_html($env{'form.subject'},undef,1); + my $subject = &clear_out_html($env{'form.subject'}); $status.=&Apache::lonrss::addentry($env{'user.name'}, $env{'user.domain'}, 'CourseBlog_'.$env{'request.course.id'}, $subject,$message,$feedurl,'public'); - $blog='<br />'.&mt('Added to my course blog').'<br />'; + if (&Apache::loncommon::course_type() eq 'Community') { + $blog='<br />'.&mt('Added to my community blog').'<br />'; + } else { + $blog='<br />'.&mt('Added to my course blog').'<br />'; + } } # Receipt screen and redirect back to where came from @@ -4063,6 +4176,8 @@ None =item newline_to_br() +=item tidy_html() + =item generate_preview_button() =item modify_attachments()