--- loncom/interface/lonfeedback.pm 2010/01/21 23:13:50 1.284 +++ loncom/interface/lonfeedback.pm 2011/12/11 19:17:54 1.309 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.284 2010/01/21 23:13:50 raeburn Exp $ +# $Id: lonfeedback.pm,v 1.309 2011/12/11 19:17:54 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -49,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; } @@ -126,7 +135,7 @@ sub list_discussion { $crs=~s/\_/\//g; my $encsymb=&Apache::lonenc::check_encrypt($ressymb); my $viewgrades=(&Apache::lonnet::allowed('vgr',$crs) - && ($ressymb=~/\.(problem|exam|quiz|assess|survey|form|task)$/)); + && ($ressymb=~/$LONCAPA::assess_re/)); my %usernamesort = (); my %namesort =(); @@ -272,17 +281,12 @@ sub list_discussion { my $maxdepth=0; 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; &Apache::lonnet::put('nohist_'.$cid.'_discuss',\%discinfo,$env{'user.domain'},$env{'user.name'}); - &build_posting_display(\%usernamesort,\%subjectsort,\%namesort,\%notshown,\%newitem,\%dischash,\%shown,\%alldiscussion,\%imsitems,\%imsfiles,\%roleinfo,\@discussionitems,\@replies,\@depth,\@posters,\$maxdepth,\$visible,\$newpostsflag,\$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$encsymb,$target,$readkey,$showunmark,$showonlyunread,$totposters,\@rolefilter,\@sectionpick,\@grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,\%anonhash,$anoncnt,$group); + &build_posting_display(\%usernamesort,\%subjectsort,\%namesort,\%notshown,\%newitem,\%dischash,\%shown,\%alldiscussion,\%imsitems,\%imsfiles,\%roleinfo,\@discussionitems,\@replies,\@depth,\@posters,\$maxdepth,\$visible,\$newpostsflag,\$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$encsymb,$readkey,$showunmark,$showonlyunread,$totposters,\@rolefilter,\@sectionpick,\@grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,\%anonhash,$anoncnt,$group); my $discussion=''; my $manifestfile; @@ -317,6 +321,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'}; @@ -368,8 +373,7 @@ sub list_discussion { # Print the discusssion if ($outputtarget eq 'tex') { $discussion.='{\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.'}}'; } elsif ($outputtarget eq 'export') { @@ -416,7 +420,6 @@ imscp_v1p1.xsd http://www.imsglobal.org/ } } else { my $colspan=$maxdepth+1; -#JW $discussion.= &Apache::lonhtmlcommon::scripttag(qq| function verifydelete (caller,symb,idx,newflag,previous,groupparm) { var symbparm = symb+':::'+idx @@ -514,7 +517,6 @@ imscp_v1p1.xsd http://www.imsglobal.org/ $threadinsert='
Reply: '.$thisdepth.''; } $discussionitems[$alldiscussion{$post}]=~s/<\/td>]*)>/$threadinsert<\/td>/; - $discussionitems[$alldiscussion{$post}]=~s/]+)>(Edit|Hide|Delete|Reply|Submissions)<\/a>//g; $discussionitems[$alldiscussion{$post}]=~s/(|<\/b>|<\/a>|]+)>)//g; $discussionitems[$alldiscussion{$post}]='\vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}'.$discussionitems[$alldiscussion{$post}]; @@ -719,9 +721,10 @@ END $attachnum += @{$currnewattach}; } } - if (&discussion_open($status)) { + if ((&discussion_open($status)) && ($outputtarget ne 'tex')) { if (($group ne '') && ($mode eq 'board')) { - if (&check_group_priv($group,'pgd') eq 'ok') { + if ((&check_group_priv($group,'pgd') eq 'ok') && + ($ressymb =~ m{^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$})) { $discussion .= &postingform_display($mode,$ressymb,$now,$subject, $comment,$outputtarget,$attachnum, @@ -729,39 +732,64 @@ END $group,$crstype); } } else { - $discussion.= - &postingform_display($mode,$ressymb,$now,$subject, - $comment,$outputtarget,$attachnum, - $currnewattach,$currdelold,'',$crstype); + if (&Apache::lonnet::allowed('pch',$env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { + + $discussion.= + &postingform_display($mode,$ressymb,$now,$subject, + $comment,$outputtarget,$attachnum, + $currnewattach,$currdelold,'',$crstype); + } else { + $discussion.= ''. + &mt('This discussion is closed.').''; + } } } - } else { + if (!(&discussion_open($status)) && ($outputtarget ne 'tex')) { + $discussion.= ''. + &mt('This discussion is closed.').''; + } + } elsif ($outputtarget ne 'tex') { $discussion.=''; + $discussion.= &send_message_link($ressymb).''; } return $discussion; } + +sub discussion_link { + my ($ressymb,$linktext,$cmd,$item,$flag,$prev,$adds)=@_; + my $link='/adm/feedback?inhibitmenu=yes&modal=yes&'.$cmd.'='.&escape($ressymb).':::'.$item; + if ($flag) { $link .= '&previous='.$prev; } + if ($adds) { $link .= $adds; } + return &Apache::loncommon::modal_link($link,$linktext,600,400); +} + + sub send_feedback_link { - my ($ressymb,$target) = @_; - my $output = ''. - ' '. - ''.&mt('Post Discussion').''; - return $output; + my ($ressymb) = @_; + return ''. + &discussion_link($ressymb, + ''.&mt('Post Discussion').'', + 'replydisc'). + ''; } sub send_message_link { @@ -769,7 +797,7 @@ sub send_message_link { my $output = ''. ' '.&mt('Send Feedback').''; return $output; } @@ -780,7 +808,7 @@ sub action_links_bar { ''. '
'; my $escsymb=&escape($ressymb); - if ($visible>2) { + if ($visible) { $discussion .= ' @@ -847,7 +885,7 @@ sub postingform_display {
$lt{'note'}
$lt{'title'}: 

- + ENDDISCUSS if ($env{'form.origpage'}) { $postingform .= '\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 = '
'.$lt{'newa'}.'
'; - if (@{$currnewattach} > 1) { - $newattachmsg .= '
    '; - foreach my $item (@{$currnewattach}) { - $item =~ m#.*/([^/]+)$#; - $newattachmsg .= '
  1. '.$1.'
  2. '."\n"; - } - $newattachmsg .= '
'."\n"; - } else { - $$currnewattach[0] =~ m#.*/([^/]+)$#; - $newattachmsg .= ''.$1.'
'."\n"; - } - } - $postingform .= $newattachmsg; - $postingform .= &generate_preview_button(); + if ((ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)) { + $newattachmsg = '
'.$lt{'newa'}.'
'; + if (@{$currnewattach} > 1) { + $newattachmsg .= '
    '; + foreach my $item (@{$currnewattach}) { + $item =~ m#.*/([^/]+)$#; + $newattachmsg .= '
  1. '.$1.'
  2. '."\n"; + } + $newattachmsg .= '
'."\n"; + } else { + $$currnewattach[0] =~ m#.*/([^/]+)$#; + $newattachmsg .= ''.$1.'
'."\n"; + } } + $postingform .= $newattachmsg; + $postingform .= &generate_preview_button(); return $postingform; } sub build_posting_display { - my ($usernamesort,$subjectsort,$namesort,$notshown,$newitem,$dischash,$shown,$alldiscussion,$imsitems,$imsfiles,$roleinfo,$discussionitems,$replies,$depth,$posters,$maxdepth,$visible,$newpostsflag,$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$ressymb,$target,$readkey,$showunmark,$showonlyunread,$totposters,$rolefilter,$sectionpick,$grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,$anonhash,$anoncnt,$group) = @_; + my ($usernamesort,$subjectsort,$namesort,$notshown,$newitem,$dischash,$shown,$alldiscussion,$imsitems,$imsfiles,$roleinfo,$discussionitems,$replies,$depth,$posters,$maxdepth,$visible,$newpostsflag,$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$ressymb,$readkey,$showunmark,$showonlyunread,$totposters,$rolefilter,$sectionpick,$grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,$anonhash,$anoncnt,$group) = @_; my @original=(); my @index=(); my $skip_group_check = 0; @@ -911,6 +947,19 @@ sub build_posting_display { if ((@{$grouppick} == 0) || (grep(/^all$/,@{$grouppick}))) { $skip_group_check = 1; } + my (%deletions,%hiddens); + if ($contrib{'deleted'}) { + my $deleted = $contrib{'deleted'}; + $deleted =~ s/^\.//; + $deleted =~ s/\.$//; + %deletions = map { $_ => 1 } (split(/\.\./,$deleted)); + } + if ($contrib{'hidden'}) { + my $hidden = $contrib{'hidden'}; + $hidden =~ s/^\.//; + $hidden =~ s/\.$//; + %hiddens = map { $_ => 1 } (split(/\.\./,$hidden)); + } if ($contrib{'version'}) { my $oldest = $contrib{'1:timestamp'}; if ($prevread eq '0') { @@ -924,13 +973,13 @@ sub build_posting_display { } for (my $id=1;$id<=$contrib{'version'};$id++) { my $idx=$id; + next if ($contrib{$idx.':deleted'}); + next if ($contrib{$idx.':hidden'}); my $posttime = $contrib{$idx.':timestamp'}; if ($prevread <= $posttime) { $$newpostsflag = 1; } - my $hidden=($contrib{'hidden'}=~/\.$idx\./); my $studenthidden=($contrib{'studenthidden'}=~/\.$idx\./); - my $deleted=($contrib{'deleted'}=~/\.$idx\./); my $origindex='0.'; my $numoldver=0; if ($contrib{$idx.':replyto'}) { @@ -954,7 +1003,7 @@ sub build_posting_display { } else { $$replies[$$depth[$idx]]=1; } - unless ((($hidden) && (!$seeid)) || ($deleted)) { + unless ((($hiddens{$idx}) && (!$seeid)) || ($deletions{$idx})) { $$visible++; if ($contrib{$idx.':history'}) { if ($contrib{$idx.':history'} =~ /:/) { @@ -988,7 +1037,7 @@ sub build_posting_display { $message.=$attachtxt{$numoldver}; $subject=$subjects{$numoldver}; if ($message) { - if ($hidden) { + if ($hiddens{$idx}) { $message=''.$message.''; if ($studenthidden) { $message .='

Deleted by poster (student).'; @@ -1015,6 +1064,7 @@ sub build_posting_display { $contrib{$idx.':senderdomain'}).' ('. $contrib{$idx.':sendername'}.':'. $contrib{$idx.':senderdomain'}.')'; + $sender = ''.$sender.''; if ($contrib{$idx.':anonymous'}) { $sender.=' ['.$$anonhash{$key}.'] '. $screenname; @@ -1051,53 +1101,41 @@ sub build_posting_display { } else { @{$$namesort{$lastname}{$firstname}} = ("$idx"); } - if (&editing_allowed($escsymb.':::'.$idx,$group)) { - if (($env{'user.domain'} eq $contrib{$idx.':senderdomain'}) && ($env{'user.name'} eq $contrib{$idx.':sendername'})) { - $sender.=' '.&mt('Edit').''; - - unless ($seeid) { - my $grpargs = &group_args($group); - $sender.=" '; + if ($outputtarget ne 'tex') { + if (&editing_allowed($escsymb.':::'.$idx,$group)) { + if (($env{'user.domain'} eq $contrib{$idx.':senderdomain'}) && ($env{'user.name'} eq $contrib{$idx.':sendername'})) { + $sender.=' '. + &discussion_link($symb,&mt('Edit'),'editdisc',$idx,$$newpostsflag,$prevread,&group_args($group)); + unless ($seeid) { + my $grpargs = &group_args($group); + $sender.=" '; + } } } - } - if ($seeid) { - if ($hidden) { - unless ($studenthidden) { - $sender.=' '.&mt('Make Visible').''; - } - } else { - $sender.=' '.&mt('Hide').''; - } - my $grpargs = &group_args($group); - $sender.= - " "; - $sender .= &mt('Delete').''; + } else { + $sender.=' '. + &discussion_link($symb,&mt('Hide'),'hide',$idx,$$newpostsflag,$prevread,&group_args($group)); + } + my $grpargs = &group_args($group); + $sender.= + " "; + $sender .= &mt('Delete').''; + } } - } else { + } else { if ($screenname) { $sender=''.$screenname.''; } else { $sender=''.$$anonhash{$key}.''; } + $sender = ''.$sender.''; # Set up for sorting by domain, then username for anonymous unless (defined($$usernamesort{'__anon'})) { %{$$usernamesort{'__anon'}} = (); @@ -1117,36 +1155,29 @@ sub build_posting_display { @{$$namesort{'__anon'}{'__anon'}} = ("$idx"); } } - if (&discussion_open($status)) { - if (($group ne '') && - (&check_group_priv($group,'pgd') eq 'ok')) { - $sender.=' '.&mt('Reply').''; - } elsif (&Apache::lonnet::allowed('pch', - $env{'request.course.id'}. - ($env{'request.course.sec'}?'/'. - $env{'request.course.sec'}:''))) { - $sender.=' '.&mt('Reply').''; } - } - if ($viewgrades) { - $vgrlink=&Apache::loncommon::submlink('Submissions', - $contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$ressymb); - } - if ($$dischash{$readkey}=~/\.$idx\./) { - $ctlink = ''; - } else { - $ctlink = ''; + if ($viewgrades) { + $vgrlink=&Apache::loncommon::submlink(&mt('Submissions'), + $contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$ressymb); + } + if ($$dischash{$readkey}=~/\.$idx\./) { + $ctlink = ''; + } else { + $ctlink = ''; + } } } #figure out at what position this needs to print @@ -1163,7 +1194,7 @@ sub build_posting_display { if ($outputtarget eq 'export') { %{$$imsitems{$idx}} = (); $$imsitems{$idx}{'isvisible'}='true'; - if ($hidden) { + if ($hiddens{$idx}) { $$imsitems{$idx}{'isvisible'}='false'; } $$imsitems{$idx}{'title'}=$subjects{$numoldver}; @@ -1245,7 +1276,7 @@ sub build_posting_display { $$newitem{$idx} = 1; $$discussionitems[$idx] .= ' - '; + '; } else { $$newitem{$idx} = 0; $$discussionitems[$idx] .= ' @@ -1254,7 +1285,7 @@ sub build_posting_display { } $$discussionitems[$idx] .= ''; if ($$dischash{$toggkey}) { $$discussionitems[$idx].=''. + ''; } if ($discussoptions) { - $discussoptions='

' - .' '.&mt('Discussion Contributions').'

'.&Apache::lonhtmlcommon::coursepreflink(&mt('Discussion Settings'),'discussion').'

' - .$discussoptions; + $discussoptions=''. + ''; } - return $msgoptions.$discussoptions; + return &Apache::loncommon::start_data_table().$msgoptions.$discussoptions.&Apache::loncommon::end_data_table(); } sub resource_output { @@ -2667,9 +2721,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 -tag my %html=(M=>1); # Check if more is allowed @@ -2680,8 +2732,8 @@ sub clear_out_html { #

#

'.&mt('NEW').'
'.&mt('NEW').'   '. ''.$subject.'  '. - ''.$sender.' '.$vgrlink.' ('. + $sender.' '.$vgrlink.' ('. &Apache::lonlocal::locallocaltime($posttime).')  '. @@ -1266,9 +1297,8 @@ sub build_posting_display { my @postversions = (); $$discussionitems[$idx] .= &mt('This post has been edited by the author.'); if ($seeid) { - $$discussionitems[$idx] .= '  '.&mt('Display all versions').''; + $$discussionitems[$idx] .= '  '. + &discussion_link($symb,&mt('Display all versions'),'allversions',$idx,$$newpostsflag,$prevread,&group_args($group)); } $$discussionitems[$idx].='
'.&mt('Earlier version(s) were posted on: '); if ($contrib{$idx.':history'} =~ m/:/) { @@ -1396,7 +1426,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/\
/g; $$subjects{$i}=&Apache::lontexconvert::msgtexconverted($$subjects{$i}); @@ -1664,28 +1696,46 @@ END END + my ($textareaheader,$textareaclass); + if (&Apache::lonhtmlcommon::htmlareabrowser()) { + $textareaheader = &Apache::lonhtmlcommon::htmlareaselectactive(); + $textareaclass = 'class="LC_richDefaultOff"'; + if ($env{'request.course.id'}) { + unless (($env{'course.'.$env{'request.course.id'}.'.allow_limited_html_in_feedback'} =~ /^\s*yes\s*$/i) || ($env{'form.sendmessageonly'})) { + undef($textareaclass); + } + } + } + # Breadcrumbs my $brcrum = [{'href' => '', 'text' => 'Resource Feedback and Discussion'}]; my %onload = ('onload' => 'window.focus();setposttype();'); + my %parms=('add_entries' => \%onload); + if ($env{'form.modal'} ne 'yes') { 'bread_crumbs' => $brcrum } my $start_page= - &Apache::loncommon::start_page('Resource Feedback and Discussion',$js, - {'add_entries' => \%onload, - 'bread_crumbs' => $brcrum,}); + &Apache::loncommon::start_page('Resource Feedback and Discussion',$js,\%parms); if ($quote ne '') { - &newline_to_br(\$quote); + $quote = &HTML::Entities::decode($quote); + unless (&contains_block_html($quote)) { + &newline_to_br(\$quote); + } $quote='
'.&Apache::lontexconvert::msgtexconverted($quote).'
'; } - + my $header=''; + unless ($env{'form.modal'}) { + $header="

$restitle

"; + } $r->print(<$restitle +$header
$prevtag + END if ($env{'form.replydisc'}) { $r->print(<print(< +$options $quote -

$lt{'myqu'}

+

$lt{'myqu'} +$textareaheader +

$latexHelp

$lt{'title'}:

-

-

END if ( ($env{'form.editdisc'}) || ($env{'form.replydisc'}) ) { if ($env{'form.origpage'}) { @@ -1731,6 +1782,7 @@ END } } else { $r->print(< $lt{'atta'} $attachmaxtext:

END @@ -1785,7 +1837,6 @@ END } } $r->print(&generate_preview_button(). - &Apache::lonhtmlcommon::htmlareaselectactive('comment'). &Apache::loncommon::end_page()); } @@ -2234,7 +2285,7 @@ sub print_showposters { my $group = $env{'form.group'}; my $ressymb = &wrap_symb($symb); if (($group ne '') && - ($ressymb =~ m|^bulletin___ \d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$|)) { + ($ressymb =~ m|^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$|)) { if (&check_group_priv($group,'dgp') eq 'ok') { $seeid = 1; } @@ -2395,7 +2446,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, @@ -2507,16 +2558,14 @@ 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 %parms=('only_body' => 1); + if ($env{'form.modal'}) { + $parms{'add_entries'}={'onLoad' => 'document.forms.reldt.submit()'}; + } else { + $parms{'redirect'}=[0,$feedurl]; } my $start_page= - &Apache::loncommon::start_page('Feedback sent',undef, - {'redirect' => [0,$feedurl], - 'only_body' => 1, - 'add_entries' => \%onload}); + &Apache::loncommon::start_page('Feedback sent',undef,\%parms); my $end_page = &Apache::loncommon::end_page(); $r->print(< 1, 'bgcolor' => '#FFFFFF', @@ -2575,7 +2620,7 @@ ENDNOREDIRTWO } sub screen_header { - my ($feedurl,$symb) = @_; + my ($feedurl,$symb,$group) = @_; 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'); @@ -2624,10 +2669,19 @@ sub screen_header { } if (($env{'request.course.id'}) && (!$env{'form.sendmessageonly'})) { my ($blocked,$blocktext) = &Apache::loncommon::blocking_status('boards'); - if (!$blocked && &discussion_open(undef,$symb) && - &Apache::lonnet::allowed('pch', - $env{'request.course.id'}. - ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $realsymb = $symb; + if ($symb=~/^bulletin___/) { + my $filename=(&Apache::lonnet::decode_symb($symb))[2]; + $filename=~s|^adm/wrapper/||; + $realsymb=&Apache::lonnet::symbread($filename); + } + if (!$blocked && &discussion_open(undef,$realsymb) && + (&Apache::lonnet::allowed('pch', + $env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) || + (($group ne '') && ($symb =~ m{^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$}) && (&check_group_priv($group,'pgd') eq 'ok')))) { $discussoptions='
' + .'
'.&mt('Send Feedback').'
'.&Apache::lonhtmlcommon::coursepreflink(&mt('Feedback Settings'),'feedback').'
'.$msgoptions.'
' + .'
'.&mt('Discussion Contributions').'
'.&Apache::lonhtmlcommon::coursepreflink(&mt('Discussion Settings'),'discussion').'
'.$discussoptions.'
%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, + 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); } @@ -2768,7 +2820,7 @@ sub send_msg { } sub adddiscuss { - my ($symb,$email,$anon,$attachmenturl,$subject)=@_; + my ($symb,$email,$anon,$attachmenturl,$subject,$group)=@_; my $status=''; my $realsymb; if ($symb=~/^bulletin___/) { @@ -2776,9 +2828,16 @@ sub adddiscuss { $filename=~s|^adm/wrapper/||; $realsymb=&Apache::lonnet::symbread($filename); } + my ($cnum,$cdom); + if ($env{'request.course.id'}) { + $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + } if (&discussion_open(undef,$realsymb) && - &Apache::lonnet::allowed('pch',$env{'request.course.id'}. - ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { + (&Apache::lonnet::allowed('pch',$env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) || + (($group ne '') && (&check_group_priv($group,'pgd') eq 'ok') && + ($symb =~ m{^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$})))) { my %contrib=('message' => $email, 'sendername' => $env{'user.name'}, @@ -2929,7 +2988,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/\
/g; $subject=&Apache::lontexconvert::msgtexconverted($subject); @@ -2950,16 +3009,17 @@ 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 ); + 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*/>| + >.* + )}xs + ); } sub tidy_html { @@ -3035,12 +3095,14 @@ END # Breadcrumbs my $brcrum = [{'href' => '', 'text' => 'Discussion Post Attachments'}]; + my %parms=(); + if ($env{'form.modal'} ne 'yes') { 'bread_crumbs' => $brcrum } + my $start_page = - &Apache::loncommon::start_page('Discussion Post Attachments',$js, - {'bread_crumbs' => $brcrum,}); + &Apache::loncommon::start_page('Discussion Post Attachments',$js,\%parms); 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/\
/g; $subject=&Apache::lontexconvert::msgtexconverted($subject); my $timestamp=$env{'form.timestamp'}; @@ -3398,7 +3460,7 @@ sub handler { # --------------------------- Get query string for limited number of parameters &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, - ['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']); + ['modal','hide','unhide','deldisc','postdata','preview','replydisc','editdisc','cmd','symb','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navtime','navmaps','navurl','sortposts','applysort','rolefilter','statusfilter','sectionpick','groupick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export','sendmessageonly','group','ref']); my $group = $env{'form.group'}; my %attachmax = ( text => &mt('(128 KB max size)'), @@ -3449,10 +3511,11 @@ sub handler { # Breadcrumbs my $brcrum = [{'href' => '', 'text' => 'Discussion Post Versions'}]; + + my %parms=(); + if ($env{'form.modal'} ne 'yes') { 'bread_crumbs' => $brcrum } - $r->print(&Apache::loncommon::start_page('Discussion Post Versions',undef, - {'bread_crumbs' => $brcrum,}) - ); + $r->print(&Apache::loncommon::start_page('Discussion Post Versions',undef,\%parms)); my $crs='/'.$env{'request.course.id'}; if ($env{'request.course.sec'}) { @@ -3556,10 +3619,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, @@ -3748,7 +3807,7 @@ ENDREDIR my $mode='board'; my $status='OPEN'; my $previous=$env{'form.previous'}; - if ($feedurl =~ /\.(problem|exam|quiz|assess|survey|form|library|task)$/) { + if ($feedurl =~ /$LONCAPA::assess_re/) { $mode='problem'; $status=$Apache::inputtags::status[-1]; } @@ -3788,7 +3847,7 @@ ENDREDIR &dewrapper(\$feedurl); } my $goahead=1; - if ($feedurl=~/\.(problem|exam|quiz|assess|survey|form|task)$/) { + if ($feedurl=~/$LONCAPA::assess_re/) { unless ($symb) { $goahead=0; } } if (!$goahead) { @@ -3826,7 +3885,7 @@ ENDREDIR return OK; } } - my $options=&screen_header($feedurl,$symb); + my $options=&screen_header($feedurl,$symb,$group); if ($options) { &mail_screen($r,$feedurl,$options,$symb,$attachmax{'text'}); } else { @@ -3882,7 +3941,11 @@ ENDREDIR } } # Filter HTML out of message (could be nasty) - my $message=&clear_out_html($env{'form.comment'}); + my $override; + if ($env{'form.discuss'} =~ /^(?:author|question|course|policy)$/) { + $override = 1; + } + my $message=&clear_out_html($env{'form.comment'},$override); # Assemble email my ($email,$citations)=&assemble_email($message,$prevattempts, @@ -3892,8 +3955,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); @@ -3902,10 +3964,10 @@ 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); + $subject,$group); $numpost++; } @@ -3913,7 +3975,7 @@ 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'},