--- loncom/interface/lonfeedback.pm 2012/05/01 15:56:16 1.290.2.7.2.5 +++ loncom/interface/lonfeedback.pm 2010/09/21 04:18:50 1.302 @@ -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.302 2010/09/21 04:18:50 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".''; $discussion .= &action_links_bar($colspan,$ressymb,$visible, $newpostsflag,$group, - $prevread,$markondisp,$seehidden); + $prevread,$markondisp); my $escsymb=&escape($ressymb); my $numhidden = keys(%notshown); if ($numhidden > 0) { @@ -684,7 +659,7 @@ END END $discussion .= &action_links_bar($colspan,$ressymb,$visible, $newpostsflag,$group, - $prevread,$markondisp,$seehidden); + $prevread,$markondisp); $discussion .= "


\n"; @@ -748,9 +723,8 @@ END } } if ((&discussion_open($status)) && ($outputtarget ne 'tex')) { - if (($group ne '') && ($mode eq 'board')) { - if ((&check_group_priv($group,'pgd') eq 'ok') && - ($ressymb =~ m{^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$})) { + if (($group ne '') && ($mode eq 'board')) { + if (&check_group_priv($group,'pgd') eq 'ok') { $discussion .= &postingform_display($mode,$ressymb,$now,$subject, $comment,$outputtarget,$attachnum, @@ -758,44 +732,27 @@ END $group,$crstype); } } else { - 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.').''; - } + $discussion.= + &postingform_display($mode,$ressymb,$now,$subject, + $comment,$outputtarget,$attachnum, + $currnewattach,$currdelold,'',$crstype); } } - if (!(&discussion_open($status)) && ($outputtarget ne 'tex')) { - $discussion.= ''. - &mt('This discussion is closed.').''; - } } elsif ($outputtarget ne 'tex') { $discussion.=''; @@ -803,50 +760,6 @@ END return $discussion; } -sub can_see_hidden { - my ($mode,$ressymb,$feedurl,$group,$cdom,$cnum,$crs) = @_; - my $seehidden; - if ($env{'request.course.id'}) { - unless ($cdom ne '' && $cnum ne '') { - $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - } - if ($crs eq '') { - $crs = '/'.$env{'request.course.id'}; - if ($env{'request.course.sec'}) { - $crs.='_'.$env{'request.course.sec'}; - } - $crs=~s{_}{/}g; - } - if ($mode eq '') { - $mode='board'; - if ($feedurl =~ /$LONCAPA::assess_re/) { - $mode='problem'; - } - } - if (($group ne '') && ($mode eq 'board') && - ($ressymb =~ m{^bulletin___\d+\Q___adm/wrapper/adm/$cdom/$cnum/\E\d+/bulletinboard$})) { - if (&check_group_priv($group,'dgp') eq 'ok') { - $seehidden = 1; - } - } else { - $seehidden=&Apache::lonnet::allowed('rin',$crs); - } - } - return $seehidden; -} - -sub discussion_link { - my ($ressymb,$linktext,$cmd,$item,$flag,$prev,$adds,$title) = @_; - my $link = ''; - return $link; -} - sub send_feedback_link { my ($ressymb,$target) = @_; my $output = ''. @@ -869,8 +782,7 @@ sub send_message_link { } sub action_links_bar { - my ($colspan,$ressymb,$visible,$newpostsflag,$group,$prevread,$markondisp, - $seehidden) = @_; + my ($colspan,$ressymb,$visible,$newpostsflag,$group,$prevread,$markondisp) = @_; my $discussion = ''. ''. ''; + $discussion .= '">'.&mt('Export').'?  '; if ($newpostsflag) { if (!$markondisp) { $discussion .=''; } - 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].= '
'; @@ -900,17 +812,7 @@ sub action_links_bar { $discussion .= '&previous='.$prevread; } $discussion .= &group_args($group); - $discussion .= '">'.&mt('Export').''; - if ($seehidden) { - $discussion .= '  '; - $discussion .=''.&mt('Undelete all deleted entries').''; - } - $discussion.='\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 .= '
    '; - foreach my $item (@{$currnewattach}) { + $newattachmsg .= '
      '; + foreach my $item (@{$currnewattach}) { $item =~ m#.*/([^/]+)$#; $newattachmsg .= '
    1. '.$1.'
    2. '."\n"; - } - $newattachmsg .= '
    '."\n"; - } else { - $$currnewattach[0] =~ m#.*/([^/]+)$#; - $newattachmsg .= ''.$1.'
    '."\n"; - } + } + $newattachmsg .= '
'."\n"; + } else { + $$currnewattach[0] =~ m#.*/([^/]+)$#; + $newattachmsg .= ''.$1.'
'."\n"; + } } $postingform .= $newattachmsg; $postingform .= &generate_preview_button(); @@ -1008,31 +910,16 @@ 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'}:'')); @@ -1062,56 +949,7 @@ 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'}); @@ -1144,7 +982,7 @@ sub build_posting_display { } else { $$replies[$$depth[$idx]]=1; } - unless ((($hiddens{$idx}) && (!$seehidden)) || ($deletions{$idx})) { + unless ((($hiddens{$idx}) && (!$seeid)) || ($deletions{$idx})) { $$visible++; if ($contrib{$idx.':history'}) { if ($contrib{$idx.':history'} =~ /:/) { @@ -1159,7 +997,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 +1007,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 @@ -1199,18 +1037,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}.'] '. @@ -1259,18 +1091,18 @@ sub build_posting_display { $sender .= &group_args($group); $sender .= '" '.$target.'>'.&mt('Edit').''; - unless ($seehidden) { + unless ($seeid) { my $grpargs = &group_args($group); $sender.=" '; } } } - if ($seehidden) { + if ($seeid) { if ($hiddens{$idx}) { unless ($studenthidden) { $sender.=' '; } } - } else { + } else { if ($screenname) { $sender=''.$screenname.''; } else { @@ -1318,7 +1150,7 @@ sub build_posting_display { } } if ($outputtarget ne 'tex') { - if (&discussion_open($status)) { + if (&discussion_open($status)) { if (($group ne '') && (&check_group_priv($group,'pgd') eq 'ok')) { $sender.=' '.&mt('Reply').''; } } - if ($viewgrades) { + if ($viewgrades) { $vgrlink=&Apache::loncommon::submlink(&mt('Submissions'), $contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$ressymb); } - if ($$dischash{$readkey}=~/\.$idx\./) { + if ($$dischash{$readkey}=~/\.$idx\./) { $ctlink = ''; } else { $ctlink = ''; @@ -1387,15 +1219,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 +1294,12 @@ sub build_posting_display { $$discussionitems[$idx].='
  '. $ctlink.'
'. - "
". - $message. - '
'; - 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].= - '
'. - ''.$novote.' '. - ''.$novote.''; - } else { - if ($userlikes{$idx}) { - $$discussionitems[$idx].=''.&mt('You like this posting').''; - } else { - $$discussionitems[$idx].=' '.&discussion_link($symb,''.&mt('Like').'','like',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Like this posting")); - } - if ($userunlikes{$idx}) { - $$discussionitems[$idx].=''.&mt('You unlike this posting').''; - } else { - $$discussionitems[$idx].=' '.&discussion_link($symb,''.&mt('Unlike').'','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 +1379,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 +1397,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 +1588,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 +1596,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'}; } @@ -1983,7 +1759,7 @@ $latexHelp

$lt{'title'}:

-

END if ( ($env{'form.editdisc'}) || ($env{'form.replydisc'}) ) { @@ -2498,11 +2274,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 +2307,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 +2559,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 +2592,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 +2618,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 +2667,16 @@ 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); + 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', + &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='