'.
'';
}
return $discussion;
}
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,$prevread,$sortposts,$ressymb,$target,$readkey,$showunmark,$showonlyunread,$totposters,$rolefilter,$sectionpick,$statusfilter,$toggkey,$outputtarget) = @_;
+ 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,$statusfilter,$toggkey,$outputtarget,$anonhash,$anoncnt) = @_;
my @original=();
my @index=();
my $symb=&Apache::lonenc::check_decrypt($ressymb);
+ my $escsymb=&Apache::lonnet::escape($ressymb);
my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
$env{'course.'.$env{'request.course.id'}.'.domain'},
$env{'course.'.$env{'request.course.id'}.'.num'});
@@ -822,6 +833,13 @@ sub build_posting_display {
my %allattachments = ();
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.
+ my $key=$contrib{$idx.':sendername'}.'@'.$contrib{$idx.':senderdomain'};
+ unless ($$anonhash{$key}) {
+ $anoncnt++;
+ $$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);
@@ -860,7 +878,7 @@ sub build_posting_display {
$contrib{$idx.':sendername'}.' at '.
$contrib{$idx.':senderdomain'}.')';
if ($contrib{$idx.':anonymous'}) {
- $sender.=' ['.&mt('anonymous').'] '.
+ $sender.=' ['.$$anonhash{$key}.'] '.
$screenname;
}
@@ -893,16 +911,16 @@ sub build_posting_display {
} else {
@{$$namesort{$lastname}{$firstname}} = ("$idx");
}
- if ($env{'course.'.$env{'request.course.id'}.'.allow_discussion_post_editing'} =~ m/yes/i) {
+ if (&editing_allowed()) {
if (($env{'user.domain'} eq $contrib{$idx.':senderdomain'}) && ($env{'user.name'} eq $contrib{$idx.':sendername'})) {
$sender.=' '.&mt('Edit').'';
unless ($seeid) {
- $sender.=" ';
}
}
@@ -911,23 +929,23 @@ sub build_posting_display {
if ($hidden) {
unless ($studenthidden) {
$sender.=' '.&mt('Make Visible').'';
}
} else {
$sender.=' '.&mt('Hide').'';
}
$sender.=' '.&mt('Delete').'';
@@ -935,6 +953,8 @@ sub build_posting_display {
} else {
if ($screenname) {
$sender=''.$screenname.'';
+ } else {
+ $sender=''.$$anonhash{$key}.'';
}
# Set up for sorting by domain, then username for anonymous
unless (defined($$usernamesort{'__anon'})) {
@@ -960,9 +980,9 @@ sub build_posting_display {
$env{'request.course.id'}.
($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
$sender.=' '.&mt('Reply').'';
}
@@ -1076,7 +1096,7 @@ sub build_posting_display {
my @postversions = ();
$$discussionitems[$idx] .= &mt('This post has been edited by the author.');
if ($seeid) {
- $$discussionitems[$idx] .= ' '.&mt('Display all versions').'';
+ $$discussionitems[$idx] .= ' '.&mt('Display all versions').'';
}
$$discussionitems[$idx].=' '.&mt('Earlier version(s) were posted on: ');
if ($contrib{$idx.':history'} =~ m/:/) {
@@ -1182,11 +1202,7 @@ sub get_post_contents {
if ($type eq 'allversions' || $type eq 'export') {
$start = 0;
if ($$contrib{$idx.':history'}) {
- if ($$contrib{$idx.':history'} =~ m/:/) {
- @postversions = split/:/,$$contrib{$idx.':history'};
- } else {
- @postversions = ("$$contrib{$idx.':history'}");
- }
+ @postversions = split(/:/,$$contrib{$idx.':history'});
}
&get_post_versions($messages,$$contrib{$idx.':message'},1);
&get_post_versions($subjects,$$contrib{$idx.':subject'},1);
@@ -1242,7 +1258,7 @@ END
}
}
if ($type eq 'allversions') {
- $discussion.=(' |