--- loncom/interface/lonfeedback.pm 2012/03/17 04:02:28 1.349 +++ loncom/interface/lonfeedback.pm 2012/03/17 14:49:29 1.351 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.349 2012/03/17 04:02:28 raeburn Exp $ +# $Id: lonfeedback.pm,v 1.351 2012/03/17 14:49:29 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -513,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) ) { @@ -1117,7 +1119,8 @@ sub build_posting_display { my $origindex='0.'; my $numoldver=0; if ($contrib{$idx.':replyto'}) { - if ( (($env{'environment.threadeddiscussion'}) && ($sortposts eq '')) || ($sortposts eq 'thread') || ($outputtarget eq 'export')) { + if ( ((!$env{'environment.unthreadeddiscussion'}) && ($sortposts eq '')) || + ($sortposts eq 'thread') || ($outputtarget eq 'export')) { # this is a follow-up message $original[$idx]=$original[$contrib{$idx.':replyto'}]; $$depth[$idx]=$$depth[$contrib{$idx.':replyto'}]+1; @@ -1330,7 +1333,8 @@ sub build_posting_display { } if ($outputtarget eq 'export' || $message) { my $thisindex=$idx; - if ( (($env{'environment.threadeddiscussion'}) && ($sortposts eq '')) || ($sortposts eq 'thread') || ($outputtarget eq 'export')) { + if ( ((!$env{'environment.unthreadeddiscussion'}) && ($sortposts eq '')) || + ($sortposts eq 'thread') || ($outputtarget eq 'export')) { $thisindex=$origindex.substr('00'.$$replies[$$depth[$idx]],-2,2); } $$alldiscussion{$thisindex}=$idx; @@ -1453,13 +1457,24 @@ sub build_posting_display { $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 (($uname eq $env{'user.name'}) && ($udom eq $env{'user.domain'})) { - my $novote = &mt('No voting for your own posts'); + 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').''; @@ -4123,11 +4138,21 @@ ENDREDIR if (&discussion_vote_available($status,$realsymb)) { my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'}, $cdom,$cnum); + my $ownpost; if (($contrib{$idx.':sendername'} eq $env{'user.name'}) && ($contrib{$idx.':senderdomain'} eq $env{'user.domain'})) { - $result = &mt("Vote not registered. No voting for your own posts."); + $ownpost = 1; + } + if ($ownpost || $contrib{$idx.':hidden'} || $contrib{$idx.':deleted'}) { + $result = &mt('Vote not registered.').' '; + } + if ($ownpost) { + $result .= &mt('No voting for your own posts.'); + } elsif ($contrib{$idx.':hidden'}) { + $result .= &mt('No voting for hidden posts.'); + } elsif ($contrib{$idx.':deleted'}) { + $result .= &mt('No voting for deleted posts.'); } else { - # # Likes and unlikes are in db-file "disclikes" of the course # The prefix is the $symb to identify the resource discussion, @@ -4248,12 +4273,16 @@ ENDREDIR return OK; } elsif ($env{'form.cmd'}=~/^(threadedoff|threadedon)$/) { my ($symb,$feedurl)=&get_feedurl_and_clean_symb($env{'form.symb'}); - if ($env{'form.cmd'} eq 'threadedon') { + if ($env{'form.cmd'} eq 'threadedoff') { + &Apache::lonnet::put('environment',{'unthreadeddiscussion' => 'on'}); + &Apache::lonnet::appenv({'environment.unthreadeddiscussion' => 'on'}); + &Apache::lonnet::del('environment',['threadeddiscussion']); + &Apache::lonnet::delenv('environment.threadeddiscussion'); + } else { &Apache::lonnet::put('environment',{'threadeddiscussion' => 'on'}); &Apache::lonnet::appenv({'environment.threadeddiscussion' => 'on'}); - } else { - &Apache::lonnet::del('environment',['threadeddiscussion']); - &Apache::lonnet::delenv('environment.threadeddiscussion'); + &Apache::lonnet::del('environment',['unthreadeddiscussion']); + &Apache::lonnet::delenv('environment.unthreadeddiscussion'); } &redirect_back($r,$feedurl,&mt('Changed discussion view mode').'
', '0','0','','',$env{'form.previous'},undef,undef,undef,