--- loncom/interface/lonfeedback.pm 2012/05/01 15:56:16 1.290.2.7.2.5 +++ 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.290.2.7.2.5 2012/05/01 15:56:16 raeburn Exp $ +# $Id: lonfeedback.pm,v 1.298 2010/08/14 15:24:46 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -58,15 +58,15 @@ sub discussion_open { return 1; } # It was not explicitly open, check if the problem is available. -# If the problem is not available, close the discussion +# 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; + !($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER' + || $status eq 'OPEN')) { + return 0; } # The problem is available, but check if the instructor explictly closed discussion if (defined($close) && $close ne '' && $close < time) { - return 0; + return 0; } return 1; } @@ -82,26 +82,6 @@ sub discussion_visible { return 1; } -sub discussion_vote_available { - my ($status,$symb)=@_; - my $canvote=&Apache::lonnet::EXT('resource.0.discussvote',$symb); - if ((lc($canvote) eq 'yes') || - ((lc($canvote) eq 'notended') && (&discussion_open($status,$symb)))) { - return 1; - } -} - -sub get_realsymb { - my ($symb) = @_; - my $realsymb = $symb; - if ($symb=~/^bulletin___/) { - my $filename=(&Apache::lonnet::decode_symb($symb))[2]; - $filename=~s{^adm/wrapper/}{}; - $realsymb=&Apache::lonnet::symbread($filename); - } - return $realsymb; -} - sub list_discussion { my ($mode,$status,$ressymb,$imsextras,$group)=@_; unless ($ressymb) { $ressymb=&Apache::lonnet::symbread(); } @@ -277,14 +257,14 @@ sub list_discussion { $visit ++; my $seeid; - if (&Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { - $seeid = 1; + if (($group ne '') && ($mode eq 'board') && + ($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; + } + } else { + $seeid=&Apache::lonnet::allowed('rin',$crs); } - my $seehidden = &can_see_hidden($mode,$ressymb,undef,$group,$cdom,$cnum,$crs); -# Is voting on discussions available - my $realsymb = &get_realsymb($ressymb); - my $canvote = &discussion_vote_available($status,$realsymb); - my @discussionitems=(); my %shown = (); my @posteridentity=(); @@ -302,16 +282,12 @@ 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; &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,$seehidden,$canvote,$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,$target,$readkey,$showunmark,$showonlyunread,$totposters,\@rolefilter,\@sectionpick,\@grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,\%anonhash,$anoncnt,$group); my $discussion=''; my $manifestfile; @@ -445,7 +421,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 @@ -470,7 +445,7 @@ imscp_v1p1.xsd http://www.imsglobal.org/ "\n".'
'; my $escsymb=&escape($ressymb); - if ($visible) { + if ($visible>2) { $discussion .= ''.&mt('Export').''; - if ($seehidden) { - $discussion .= ' '; - $discussion .=''.&mt('Undelete all deleted entries').''; - } - $discussion.=' | '; + $discussion .= '">'.&mt('Export').'? '; if ($newpostsflag) { if (!$markondisp) { $discussion .='
@@ -985,22 +890,22 @@ ENDDISCUSS
}
$postingform .= "\n";
$postingform .= &generate_attachments_button('',$attachnum,$ressymb,
- $now,$currnewattach,
- $currdelold,'',$mode,
- $blockblog);
+ $now,$currnewattach,
+ $currdelold,'',$mode,
+ $blockblog);
if ((ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)) {
$newattachmsg = ' '.$lt{'newa'}.' '; if (@{$currnewattach} > 1) { - $newattachmsg .= '
'."\n"; - } + } + $newattachmsg .= ' '."\n"; + } } $postingform .= $newattachmsg; $postingform .= &generate_preview_button(); @@ -1008,50 +913,22 @@ ENDDISCUSS } 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,$seehidden,$canvote,$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,$target,$readkey,$showunmark,$showonlyunread,$totposters,$rolefilter,$sectionpick,$grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,$anonhash,$anoncnt,$group) = @_; my @original=(); my @index=(); my $skip_group_check = 0; my $symb=&Apache::lonenc::check_decrypt($ressymb); my $escsymb=&escape($ressymb); -# These are the discussion contributions my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'}, $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}); - my (%likes,%userlikes,%userunlikes,@theselikes,$oneplus,$twoplus,$oneminus,$twominus); -# And these are the likes/unlikes - my $thisuser=$env{'user.name'}.':'.$env{'user.domain'}; - if ($seeid || $canvote) { - %likes=&Apache::lonnet::dump('disclikes', - $env{'course.'.$env{'request.course.id'}.'.domain'}, - $env{'course.'.$env{'request.course.id'}.'.num'}, - '^'.$symb.':'); -# Array with likes to figure out averages, etc. - @theselikes=(); -# Hashes containing likes and unlikes for this user. - %userlikes=(); - %userunlikes=(); - } -# Is the user allowed to see the real name behind anonymous postings? + my $see_anonymous = &Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')); 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') { @@ -1062,65 +939,16 @@ sub build_posting_display { ($skiptest,$roleregexp,$secregexp,$statusregexp) = &filter_regexp($rolefilter,$sectionpick,$statusfilter); $rolematch = $roleregexp.':'.$secregexp.':'.$statusregexp; - } - if ($seeid || $canvote) { -# We need to go through this twice, first to get the likes/dislikes, then to actually build the display - for (my $id=1;$id<=$contrib{'version'};$id++) { - my $idx=$id; - next if ($contrib{$idx.':deleted'}); - next if ($contrib{$idx.':hidden'}); - unless ((($hiddens{$idx}) && (!$seehidden)) || ($deletions{$idx}) || (!$contrib{$idx.':message'})) { - if ($likes{$symb.':'.$idx.':likes'} ne '') { - push(@theselikes,$likes{$symb.':'.$idx.':likes'}); - if (ref($likes{$symb.':'.$idx.':likers'}) eq 'HASH') { - if (exists($likes{$symb.':'.$idx.':likers'}{$thisuser})) { - $userlikes{$idx} = 1; - } - } - if (ref($likes{$symb.':'.$idx.':unlikers'}) eq 'HASH') { - if (exists($likes{$symb.':'.$idx.':unlikers'}{$thisuser})) { - $userunlikes{$idx} = 1; - } - } - } - } - } -# Figure out average likes and standard deviation if there are enough -# discussions to warrant that - my $ave=0; - my $stddev=10000; - if ($#theselikes>1) { - my $sum=0; - my $num=$#theselikes+1; - foreach my $thislike (@theselikes) { - $sum+=$thislike; - } - $ave=$sum/$num; - my $sumsq=0; - foreach my $thislike (@theselikes) { - $sumsq+=($thislike-$ave)*($thislike-$ave); - } - $stddev=sqrt($sumsq/$num); - } -# Now we know the average likes $ave and the standard deviation $stddev -# Get the boundaries for markup - $oneplus=$ave+$stddev; - $twoplus=$ave+2.*$stddev; - $oneminus=$ave-$stddev; - $twominus=$ave-2.*$stddev; - } -# -# This is now the real loop. Go through all entries, pick up what we need -# + } 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'}) { @@ -1144,7 +972,7 @@ sub build_posting_display { } else { $$replies[$$depth[$idx]]=1; } - unless ((($hiddens{$idx}) && (!$seehidden)) || ($deletions{$idx})) { + unless ((($hidden) && (!$seeid)) || ($deleted)) { $$visible++; if ($contrib{$idx.':history'}) { if ($contrib{$idx.':history'} =~ /:/) { @@ -1159,7 +987,7 @@ sub build_posting_display { my %subjects = (); my %attachtxt = (); my %allattachments = (); - my ($screenname,$plainname,$showaboutme); + my ($screenname,$plainname); my $sender = &mt('Anonymous'); # Anonymous users getting number within a discussion # Since idx is in static order, this should give the same sequence every time. @@ -1169,7 +997,7 @@ sub build_posting_display { $$anonhash{$key}=&mt('Anonymous').' '.$anoncnt; } my ($message,$subject,$vgrlink,$ctlink); - &get_post_contents(\%contrib,$idx,$seeid,$seehidden,$outputtarget,\%messages,\%subjects,\%allattachments,\%attachtxt,$imsfiles,\$screenname,\$plainname,\$showaboutme,$numoldver); + &get_post_contents(\%contrib,$idx,$seeid,$outputtarget,\%messages,\%subjects,\%allattachments,\%attachtxt,$imsfiles,\$screenname,\$plainname,$numoldver); # Set up for sorting by subject @@ -1178,7 +1006,7 @@ sub build_posting_display { $message.=$attachtxt{$numoldver}; $subject=$subjects{$numoldver}; if ($message) { - if ($hiddens{$idx}) { + if ($hidden) { $message=''.$message.''; if ($studenthidden) { $message .=' Deleted by poster (student).'; @@ -1199,18 +1027,12 @@ sub build_posting_display { } } if (!$contrib{$idx.':anonymous'} || $see_anonymous) { - if ($showaboutme) { - $sender = &Apache::loncommon::aboutmewrapper( - $plainname, - $contrib{$idx.':sendername'}, - $contrib{$idx.':senderdomain'}); - } else { - $sender = $plainname; - } - if ($see_anonymous) { - $sender .= ' ('.$contrib{$idx.':sendername'}.':'. - $contrib{$idx.':senderdomain'}.')'; - } + $sender=&Apache::loncommon::aboutmewrapper( + $plainname, + $contrib{$idx.':sendername'}, + $contrib{$idx.':senderdomain'}).' ('. + $contrib{$idx.':sendername'}.':'. + $contrib{$idx.':senderdomain'}.')'; $sender = ''.$sender.''; if ($contrib{$idx.':anonymous'}) { $sender.=' ['.$$anonhash{$key}.'] '. @@ -1248,48 +1070,46 @@ sub build_posting_display { } else { @{$$namesort{$lastname}{$firstname}} = ("$idx"); } - 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.=' '.&mt('Edit').''; + 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.=' '.&mt('Edit').''; - unless ($seehidden) { - my $grpargs = &group_args($group); - $sender.=" '; - } + unless ($seeid) { + my $grpargs = &group_args($group); + $sender.=" '; } } - if ($seehidden) { - if ($hiddens{$idx}) { - unless ($studenthidden) { - $sender.=' '.&mt('Make Visible').''; - } - } else { - $sender.=' '; - } - my $grpargs = &group_args($group); - $sender.= - " "; - $sender .= &mt('Delete').''; - } + $sender .= '">'.&mt('Make Visible').''; + } + } else { + $sender.=' '.&mt('Hide').''; + } + my $grpargs = &group_args($group); + $sender.= + " "; + $sender .= &mt('Delete').''; } } else { if ($screenname) { @@ -1317,38 +1137,36 @@ sub build_posting_display { @{$$namesort{'__anon'}{'__anon'}} = ("$idx"); } } - if ($outputtarget ne 'tex') { - 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 ((&discussion_open($status)) && ($outputtarget ne 'tex')) { + 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) { + } + if (($viewgrades) && ($outputtarget ne 'tex')) { $vgrlink=&Apache::loncommon::submlink(&mt('Submissions'), - $contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$ressymb); - } - if ($$dischash{$readkey}=~/\.$idx\./) { - $ctlink = ''; - } else { - $ctlink = ''; - } + $contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$ressymb); + } + if (($$dischash{$readkey}=~/\.$idx\./) && ($outputtarget ne 'tex')) { + $ctlink = ''; + } else { + $ctlink = ''; } } #figure out at what position this needs to print @@ -1365,7 +1183,7 @@ sub build_posting_display { if ($outputtarget eq 'export') { %{$$imsitems{$idx}} = (); $$imsitems{$idx}{'isvisible'}='true'; - if ($hiddens{$idx}) { + if ($hidden) { $$imsitems{$idx}{'isvisible'}='false'; } $$imsitems{$idx}{'title'}=$subjects{$numoldver}; @@ -1387,15 +1205,14 @@ sub build_posting_display { } else { if ($message) { my $spansize = 2; - my ($uname,$udom); if ($showonlyunread && $prevread > $posttime) { $$notshown{$idx} = 1; } elsif ($showunmark && $$dischash{$readkey}=~/\.$idx\./) { $$notshown{$idx} = 1; } else { # apply filters - $uname = $contrib{$idx.':sendername'}; - $udom = $contrib{$idx.':senderdomain'}; + my $uname = $contrib{$idx.':sendername'}; + my $udom = $contrib{$idx.':senderdomain'}; my $poster = $uname.':'.$udom; if ($env{'form.totposters'} ne '') { if ($totposters == 0) { @@ -1463,70 +1280,12 @@ sub build_posting_display { $$discussionitems[$idx].=' | '. $ctlink.' | '; } - my $likesize="100"; - if ($seeid || $canvote) { -# Figure out size based on likes - my $thislikes=$likes{$symb.':'.$idx.':likes'}; - if ($thislikes>$twoplus) { - $likesize="200"; - } elsif ($thislikes>$oneplus) { - $likesize="150"; - } - if ($thislikes<$twominus) { - $likesize="50"; - } elsif ($thislikes<$oneminus) { - $likesize="75"; - } - } -# Actually glue in the message itself $$discussionitems[$idx].= '
'. - "'; - if ($canvote) { - my $ownpost; - if (($uname eq $env{'user.name'}) && - ($udom eq $env{'user.domain'})) { - $ownpost = 1; - } -# Put in the like and unlike buttons - if ($ownpost || (($hiddens{$idx}) && ($seehidden))) { - my $novote; - if ($ownpost) { - $novote = &mt('No voting for your own posts.'); - } else { - $novote = &mt('No voting for hidden posts.'); - } - $$discussionitems[$idx].= - ''. - ' '. - ''; - } else { - if ($userlikes{$idx}) { - $$discussionitems[$idx].=''; - } else { - $$discussionitems[$idx].=' '.&discussion_link($symb,'','like',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Like this posting")); - } - if ($userunlikes{$idx}) { - $$discussionitems[$idx].=''; - } else { - $$discussionitems[$idx].=' '.&discussion_link($symb,'','unlike',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Unlike this posting")); - } - } - } - if ($seeid || $canvote) { - my $thislikes=$likes{$symb.':'.$idx.':likes'}; - if ($thislikes>0) { - $$discussionitems[$idx].=' ('.&mt("[_1] likes",$thislikes).')'; - } elsif ($thislikes<0) { - $$discussionitems[$idx].=' ('.&mt("[_1] unlikes",abs($thislikes)).')'; - } - } -# If there is any history to this post, inform the reader + $message.''; if ($contrib{$idx.':history'}) { my @postversions = (); $$discussionitems[$idx] .= &mt('This post has been edited by the author.'); - if ($seehidden) { + if ($seeid) { $$discussionitems[$idx] .= ' '.&mt('Display all versions').''; @@ -1606,13 +1365,13 @@ sub filter_regexp { sub get_post_contents { - my ($contrib,$idx,$seeid,$seehidden,$type,$messages,$subjects,$allattachments,$attachtxt,$imsfiles,$screenname,$plainname,$showaboutme,$numver) = @_; + my ($contrib,$idx,$seeid,$type,$messages,$subjects,$allattachments,$attachtxt,$imsfiles,$screenname,$plainname,$numver) = @_; my $discussion = ''; my $start=$numver; my $end=$numver + 1; %{$$imsfiles{$idx}}=(); if ($type eq 'allversions') { - unless($seehidden) { + unless($seeid) { $discussion=&mt('You do not have privileges to view all versions of posts.').' '.&mt('Please select a different role.'); return $discussion; } @@ -1624,20 +1383,13 @@ sub get_post_contents { $$contrib{$idx.':sendername'}, $$contrib{$idx.':senderdomain'}); $$screenname=$$contrib{$idx.':screenname'}; - $$showaboutme = &Apache::lonnet::usertools_access($$contrib{$idx.':sendername'}, - $$contrib{$idx.':senderdomain'}, - 'aboutme'); - my $sender = $$plainname; - if ($$showaboutme) { - $sender = &Apache::loncommon::aboutmewrapper( + + my $sender=&Apache::loncommon::aboutmewrapper( $$plainname, $$contrib{$idx.':sendername'}, - $$contrib{$idx.':senderdomain'}); - } - if ($seeid) { - $sender .= ' ('.$$contrib{$idx.':sendername'}.':'. - $$contrib{$idx.':senderdomain'}.')'; - } + $$contrib{$idx.':senderdomain'}).' ('. + $$contrib{$idx.':sendername'}.':'. + $$contrib{$idx.':senderdomain'}.')'; my $attachmenturls = $$contrib{$idx.':attachmenturl'}; my @postversions = (); if ($type eq 'allversions' || $type eq 'export') { @@ -1822,7 +1574,6 @@ END $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}); unless (($contrib{'hidden'}=~/\.$idx\./) || ($contrib{'deleted'}=~/\.$idx\./)) { - my $numoldver = 0; if ($contrib{$idx.':history'}) { if ($contrib{$idx.':history'} =~ /:/) { my @oldversions = split(/:/,$contrib{$idx.':history'}); @@ -1831,25 +1582,36 @@ END $numoldver = 1; } } - if ($idx > 0) { - my (%msgversions,%subversions,$htmldecode); - $htmldecode = 0; - if ($env{'form.replydisc'}) { - $htmldecode = 1; + if ($env{'form.replydisc'}) { + if ($contrib{$idx.':history'}) { + if ($contrib{$idx.':history'} =~ /:/) { + my @oldversions = split(/:/,$contrib{$idx.':history'}); + $numoldver = @oldversions; + } else { + $numoldver = 1; + } } - &get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver); - &get_post_versions(\%subversions,$contrib{$idx.':subject'},$htmldecode, - $numoldver); - $subject = $subversions{$numoldver}; - if ($env{'form.replydisc'}) { + if ($idx > 0) { + my %msgversions = (); + &get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver); $quote = $msgversions{$numoldver}; - $subject = &HTML::Entities::encode(&mt('Re: ').$subject,'<>&"'); - } else { - $comment = $msgversions{$numoldver}; } - } - if ($env{'form.editdisc'}) { + if ($idx > 0) { + my %subversions = (); + &get_post_versions(\%subversions,$contrib{$idx.':subject'},1,$numoldver); + $subject = &mt('Re: ').$subversions{$numoldver}; + } + $subject = &HTML::Entities::encode($subject,'<>&"'); + } else { $attachmenturls = $contrib{$idx.':attachmenturl'}; + if ($idx > 0) { + my %msgversions = (); + &get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver); + $comment = $msgversions{$numoldver}; + my %subversions = (); + &get_post_versions(\%subversions,$contrib{$idx.':subject'},0,$numoldver); + $subject = $subversions{$numoldver}; + } if (defined($contrib{$idx.':replyto'})) { $parentmsg = $contrib{$idx.':replyto'}; } @@ -1928,11 +1690,6 @@ END 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 @@ -1983,7 +1740,7 @@ $latexHelp". - $message. - '
$lt{'title'}:
-
END if ( ($env{'form.editdisc'}) || ($env{'form.replydisc'}) ) { @@ -2498,11 +2255,24 @@ sub print_showposters { $r->send_http_header; &Apache::lonenc::check_encrypt(\$symb); + my $crs='/'.$env{'request.course.id'}; + if ($env{'request.course.sec'}) { + $crs.='_'.$env{'request.course.sec'}; + } + $crs=~s/\_/\//g; + my $seeid; my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; my $group = $env{'form.group'}; my $ressymb = &wrap_symb($symb); - my $seehidden = &can_see_hidden('',$ressymb,$feedurl,$group,$cdom,$cnum); + if (($group ne '') && + ($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; + } + } else { + $seeid=&Apache::lonnet::allowed('rin',$crs); + } my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'}, $cdom,$cnum); my %namesort = (); @@ -2518,7 +2288,7 @@ sub print_showposters { for (my $idx=1;$idx<=$contrib{'version'};$idx++) { my $hidden=($contrib{'hidden'}=~/\.$idx\./); my $deleted=($contrib{'deleted'}=~/\.$idx\./); - unless ((($hidden) && (!$seehidden)) || ($deleted)) { + unless ((($hidden) && (!$seeid)) || ($deleted)) { if ((!$contrib{$idx.':anonymous'}) || (&Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')))) { my %names = &Apache::lonnet::get('environment',['firstname','lastname'],$contrib{$idx.':senderdomain'},$contrib{$idx.':sendername'}); my $lastname = $names{'lastname'}; @@ -2770,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], @@ -2807,17 +2573,13 @@ sub no_redirect_back { 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', 'add_entries' => \%onload,); if ($feedurl !~ m{^/adm/feedback}) { - $body_options{'redirect'} = [2,$feedurl]; + $body_options{'rediect'} = [2,$feedurl]; } my $start_page= &Apache::loncommon::start_page('Feedback not sent',undef, @@ -2837,7 +2599,7 @@ ENDNOREDIRTWO } sub screen_header { - my ($feedurl,$symb,$group) = @_; + 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'); @@ -2886,14 +2648,10 @@ sub screen_header { } if (($env{'request.course.id'}) && (!$env{'form.sendmessageonly'})) { my ($blocked,$blocktext) = &Apache::loncommon::blocking_status('boards'); - my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - my $realsymb = &get_realsymb($symb); - if (!$blocked && &discussion_open(undef,$realsymb) && - (&Apache::lonnet::allowed('pch', + if (!$blocked && &discussion_open(undef,$symb) && + &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')))) { + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { $discussoptions='