--- loncom/interface/lonfeedback.pm 2012/01/10 20:06:07 1.334
+++ loncom/interface/lonfeedback.pm 2012/03/09 15:02:31 1.338
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.334 2012/01/10 20:06:07 www Exp $
+# $Id: lonfeedback.pm,v 1.338 2012/03/09 15:02:31 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -955,6 +955,9 @@ sub build_posting_display {
my $thisuser=$env{'user.name'}.':'.$env{'user.domain'};
# Array with likes to figure out averages, etc.
my @theselikes=();
+# Hashes containing likes and unlikes for this user.
+ my %userlikes=();
+ my %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'}:''));
@@ -994,10 +997,23 @@ sub build_posting_display {
next if ($contrib{$idx.':deleted'});
next if ($contrib{$idx.':hidden'});
unless ((($hiddens{$idx}) && (!$seeid)) || ($deletions{$idx}) || (!$contrib{$idx.':message'})) {
- push(@theselikes,$likes{$symb.':'.$idx.':likes'});
+ 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
+# Figure out average likes and standard deviation if there are enough
+# discussions to warrant that
my $ave=0;
my $stddev=10000;
if ($#theselikes>1) {
@@ -1021,7 +1037,7 @@ sub build_posting_display {
my $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'});
@@ -1071,7 +1087,7 @@ sub build_posting_display {
my %subjects = ();
my %attachtxt = ();
my %allattachments = ();
- my ($screenname,$plainname);
+ my ($screenname,$plainname,$showaboutme);
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.
@@ -1081,7 +1097,7 @@ sub build_posting_display {
$$anonhash{$key}=&mt('Anonymous').' '.$anoncnt;
}
my ($message,$subject,$vgrlink,$ctlink);
- &get_post_contents(\%contrib,$idx,$seeid,$outputtarget,\%messages,\%subjects,\%allattachments,\%attachtxt,$imsfiles,\$screenname,\$plainname,$numoldver);
+ &get_post_contents(\%contrib,$idx,$seeid,$outputtarget,\%messages,\%subjects,\%allattachments,\%attachtxt,$imsfiles,\$screenname,\$plainname,\$showaboutme,$numoldver);
# Set up for sorting by subject
@@ -1111,12 +1127,18 @@ sub build_posting_display {
}
}
if (!$contrib{$idx.':anonymous'} || $see_anonymous) {
- $sender=&Apache::loncommon::aboutmewrapper(
- $plainname,
- $contrib{$idx.':sendername'},
- $contrib{$idx.':senderdomain'}).' ('.
- $contrib{$idx.':sendername'}.':'.
- $contrib{$idx.':senderdomain'}.')';
+ 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 = ''.$sender.'';
if ($contrib{$idx.':anonymous'}) {
$sender.=' ['.$$anonhash{$key}.'] '.
@@ -1362,15 +1384,15 @@ sub build_posting_display {
$message.
'';
# Put in the like and unlike buttons
- unless ($likes{$symb.':'.$idx.':likers'}=~/\,\Q$thisuser\E\,/) {
- $$discussionitems[$idx].=' '.&discussion_link($symb,'','like',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Like this posting"));
- } else {
+ if ($userlikes{$idx}) {
$$discussionitems[$idx].='
';
- }
- unless ($likes{$symb.':'.$idx.':unlikers'}=~/\,\Q$thisuser\E\,/) {
- $$discussionitems[$idx].=' '.&discussion_link($symb,'
',,'unlike',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Unlike this posting"));
} 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"));
}
my $thislikes=$likes{$symb.':'.$idx.':likes'};
if ($thislikes>0) {
@@ -1468,7 +1490,7 @@ sub filter_regexp {
sub get_post_contents {
- my ($contrib,$idx,$seeid,$type,$messages,$subjects,$allattachments,$attachtxt,$imsfiles,$screenname,$plainname,$numver) = @_;
+ my ($contrib,$idx,$seeid,$type,$messages,$subjects,$allattachments,$attachtxt,$imsfiles,$screenname,$plainname,$showaboutme,$numver) = @_;
my $discussion = '';
my $start=$numver;
my $end=$numver + 1;
@@ -1486,13 +1508,20 @@ sub get_post_contents {
$$contrib{$idx.':sendername'},
$$contrib{$idx.':senderdomain'});
$$screenname=$$contrib{$idx.':screenname'};
-
- my $sender=&Apache::loncommon::aboutmewrapper(
+ $$showaboutme = &Apache::lonnet::usertools_access($$contrib{$idx.':sendername'},
+ $$contrib{$idx.':senderdomain'},
+ 'aboutme');
+ my $sender = $$plainname;
+ if ($$showaboutme) {
+ $sender = &Apache::loncommon::aboutmewrapper(
$$plainname,
$$contrib{$idx.':sendername'},
- $$contrib{$idx.':senderdomain'}).' ('.
- $$contrib{$idx.':sendername'}.':'.
- $$contrib{$idx.':senderdomain'}.')';
+ $$contrib{$idx.':senderdomain'});
+ }
+ if ($seeid) {
+ $sender .= ' ('.$$contrib{$idx.':sendername'}.':'.
+ $$contrib{$idx.':senderdomain'}.')';
+ }
my $attachmenturls = $$contrib{$idx.':attachmenturl'};
my @postversions = ();
if ($type eq 'allversions' || $type eq 'export') {
@@ -3474,14 +3503,13 @@ sub generate_attachments_button {
my ($idx,$attachnum,$ressymb,$now,$currnewattach,$deloldattach,
$numoldver,$mode,$blockblog) = @_;
my $origpage = $ENV{'REQUEST_URI'};
- my $att=$attachnum.' '.&mt("attachments");
my %lt = &Apache::lonlocal::texthash(
- 'clic' => 'Click to add/remove attachments',
+ 'clic' => 'Add/remove attachments',
);
my $response = (<