--- loncom/interface/lonfeedback.pm 2011/12/10 22:54:34 1.307 +++ loncom/interface/lonfeedback.pm 2012/05/28 19:03:03 1.355 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.307 2011/12/10 22:54:34 www Exp $ +# $Id: lonfeedback.pm,v 1.355 2012/05/28 19:03:03 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -82,6 +82,26 @@ 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(); } @@ -257,14 +277,15 @@ sub list_discussion { $visit ++; my $seeid; - 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); + if (&Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { + $seeid = 1; } + 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=(); @@ -286,7 +307,7 @@ sub list_discussion { $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,$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,$seehidden,$canvote,$prevread,$sortposts,$encsymb,$readkey,$showunmark,$showonlyunread,$totposters,\@rolefilter,\@sectionpick,\@grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,\%anonhash,$anoncnt,$group); my $discussion=''; my $manifestfile; @@ -296,10 +317,8 @@ sub list_discussion { my $copyresult; my $function = &Apache::loncommon::get_users_function(); - my $color = &Apache::loncommon::designparm($function.'.tabbg', - $env{'user.domain'}); my %lt = &Apache::lonlocal::texthash( - 'cuse' => 'Current discussion settings', + 'cuse' => 'My settings for this discussion', 'allposts' => 'All posts', 'unread' => 'New posts only', 'unmark' => 'Unread only', @@ -441,10 +460,10 @@ imscp_v1p1.xsd http://www.imsglobal.org/ } |); $discussion.='
'. - "\n".''; + "\n".'
'; $discussion .= &action_links_bar($colspan,$ressymb,$visible, $newpostsflag,$group, - $prevread,$markondisp); + $prevread,$markondisp,$seehidden); my $escsymb=&escape($ressymb); my $numhidden = keys(%notshown); if ($numhidden > 0) { @@ -494,7 +513,9 @@ imscp_v1p1.xsd http://www.imsglobal.org/ my $currdepth = 0; my $firstidx = $alldiscussion{$showposts[0]}; foreach my $post (@showposts) { - unless (($sortposts eq 'thread') || (($sortposts eq '') && ($env{'environment.threadeddiscussion'})) || ($outputtarget eq 'export')) { + unless (($sortposts eq 'thread') || + (($sortposts eq '') && (!$env{'environment.unthreadeddiscussion'})) || + ($outputtarget eq 'export')) { $alldiscussion{$post} = $post; } unless ( ($notshown{$alldiscussion{$post}} eq '1') || ($shown{$alldiscussion{$post}} == 0) ) { @@ -504,7 +525,7 @@ imscp_v1p1.xsd http://www.imsglobal.org/ my $thisdepth=$depth[$alldiscussion{$post}]; if ($outputtarget ne 'tex' && $outputtarget ne 'export') { for (1..$thisdepth) { - $discussion.=''; + $discussion.=''; } } my $colspan=$maxdepth-$thisdepth+1; @@ -562,17 +583,12 @@ imscp_v1p1.xsd http://www.imsglobal.org/ unless ($outputtarget eq 'tex' || $outputtarget eq 'export') { my $colspan=$maxdepth+1; $discussion .= < -