'.
'
|
END
+ if ($sortposts) {
+ my %sort_types = ();
+ my %role_types = ();
+ my %status_types = ();
+ &sort_filter_names(\%sort_types,\%role_types,\%status_types);
+
+ $discussion .= ''.&mt('Sorted by').': '.$sort_types{$sortposts}.' ';
+ if (defined($ENV{'form.totposters'})) {
+ $discussion .= &mt('Posts by').': ';
+ if ($totposters > 0) {
+ foreach my $poster (@posters) {
+ $poster =~ s/:/\@/;
+ $discussion .= $poster.',';
+ }
+ $discussion =~ s/,//;
+ } else {
+ $discussion .= &mt('None selected');
+ }
+ } else {
+ my $filterchoice ='';
+ if (@sectionpick > 0) {
+ $filterchoice = ''.&mt('sections').'- '.$ENV{'form.sectionpick'};
+ $filterchoice .= ' ';
+ }
+ if (@rolefilter > 0) {
+ $filterchoice .= ''.&mt('roles').'- ';
+ foreach (@rolefilter) {
+ $filterchoice .= $role_types{$_}.', ';
+ }
+ $filterchoice .= ' ';
+ }
+ if ($statusfilter) {
+ $filterchoice .= ''.&mt('status').'- '.$status_types{$statusfilter};
+ }
+ if ($filterchoice) {
+ $discussion .= ''.&mt('Filters').': '.$filterchoice;
+ }
+ $discussion .= ' | ';
+ }
+ }
if ($dischash{$toggkey}) {
my $storebutton = &mt('Store read/unread changes');
$discussion.=''.
@@ -645,38 +689,38 @@ to course faculty
Title:
ENDDISCUSS
- if ($ENV{'form.origpage'}) {
- $discussion.=''."\n";
- foreach (@currnewattach) {
- $discussion.=''."\n";
- }
- }
- $discussion.="\n";
- if ($outputtarget ne 'tex') {
- $discussion.=&generate_attachments_button('',$attachnum,$ressymb,$now,\@currnewattach,\@currdelold,'',$mode);
- if (@currnewattach > 0) {
- $newattachmsg .= 'New attachments ';
- if (@currnewattach > 1) {
- $newattachmsg .= '';
- foreach my $item (@currnewattach) {
- $item =~ m#.*/([^/]+)$#;
- $newattachmsg .= '- '.$1.'
'."\n";
+ if ($ENV{'form.origpage'}) {
+ $discussion.=''."\n";
+ foreach (@currnewattach) {
+ $discussion.=''."\n";
+ }
+ }
+ $discussion.="\n";
+ if ($outputtarget ne 'tex') {
+ $discussion.=&generate_attachments_button('',$attachnum,$ressymb,$now,\@currnewattach,\@currdelold,'',$mode);
+ if (@currnewattach > 0) {
+ $newattachmsg .= 'New attachments ';
+ if (@currnewattach > 1) {
+ $newattachmsg .= '';
+ foreach my $item (@currnewattach) {
+ $item =~ m#.*/([^/]+)$#;
+ $newattachmsg .= '- '.$1.'
'."\n";
+ }
+ $newattachmsg .= ' '."\n";
+ } else {
+ $currnewattach[0] =~ m#.*/([^/]+)$#;
+ $newattachmsg .= ''.$1.' '."\n";
}
- $newattachmsg .= ' '."\n";
- } else {
- $currnewattach[0] =~ m#.*/([^/]+)$#;
- $newattachmsg .= ''.$1.' '."\n";
}
- }
- $discussion.=$newattachmsg;
- $discussion.=&generate_preview_button();
- }
+ $discussion.=$newattachmsg;
+ $discussion.=&generate_preview_button();
+ }
}
- } else {
- if (&discussion_open($status) &&
- &Apache::lonnet::allowed('pch',
- $ENV{'request.course.id'}.
- ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
+ } else {
+ if (&discussion_open($status) &&
+ &Apache::lonnet::allowed('pch',
+ $ENV{'request.course.id'}.
+ ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
if ($outputtarget ne 'tex') {
$discussion.=''.
@@ -690,11 +734,10 @@ 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,$prevread,$sortposts,$ressymb,$target,$readkey,$showunmark,$showonlyunread,$totposters,$rolefilter,$sectionpick,$statusfilter,$toggkey,$outputtarget) = @_;
-
my @original=();
my @index=();
-
- my %contrib=&Apache::lonnet::restore($ressymb,$ENV{'request.course.id'},
+ my $symb=&Apache::lonenc::check_decrypt($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'});
@@ -703,6 +746,11 @@ sub build_posting_display {
if ($prevread eq '0') {
$prevread = $oldest-1;
}
+ my ($skiptest,$rolematch,$roleregexp,$secregexp,$statusregexp);
+ if ($sortposts) {
+ ($skiptest,$roleregexp,$secregexp,$statusregexp) = &filter_regexp($rolefilter,$sectionpick,$statusfilter);
+ $rolematch = $roleregexp.':'.$secregexp.':'.$statusregexp;
+ }
for (my $id=1;$id<=$contrib{'version'};$id++) {
my $idx=$id;
my $posttime = $contrib{$idx.':timestamp'};
@@ -951,47 +999,32 @@ sub build_posting_display {
my $uname = $contrib{$idx.':sendername'};
my $udom = $contrib{$idx.':senderdomain'};
my $poster = $uname.':'.$udom;
- my $rolematch = '';
- my $skiptest = 1;
- if ($totposters > 0) {
- if (grep/^$poster$/,@{$posters}) {
- $$shown{$idx} = 1;
- }
- } else {
- if ($rolefilter) {
- if ($rolefilter eq 'all') {
- $rolematch = '([^:]+)';
- } else {
- $rolematch = $rolefilter;
- $skiptest = 0;
- }
- }
- if ($sectionpick) {
- if ($sectionpick eq 'all') {
- $rolematch .= ':([^:]*)';
- } else {
- $rolematch .= ':'.$sectionpick;
- $skiptest = 0;
- }
- }
- if ($statusfilter) {
- if ($statusfilter eq 'all') {
- $rolematch .= ':([^:]+)';
- } else {
- $rolematch .= ':'.$statusfilter;
- $skiptest = 0;
+ if (defined($ENV{'form.totposters'})) {
+ if ($totposters == 0) {
+ $$shown{$idx} = 0;
+ } elsif ($totposters > 0) {
+ if (grep/^$poster$/,@{$posters}) {
+ $$shown{$idx} = 1;
}
}
+ } elsif ($sortposts) {
if ($skiptest) {
$$shown{$idx} = 1;
} else {
foreach my $role (@{$$roleinfo{$poster}}) {
- if ($role =~ m/^$rolematch$/) {
+ if ($role =~ /^cc:/) {
+ my $cc_regexp = $roleregexp.':[^:]*:'.$statusregexp;
+ if ($role =~ /$cc_regexp/) {
+ $$shown{$idx} = 1;
+ }
+ } elsif ($role =~ /^$rolematch$/) {
$$shown{$idx} = 1;
last;
}
}
}
+ } else {
+ $$shown{$idx} = 1;
}
}
unless ($$notshown{$idx} == 1) {
@@ -1041,6 +1074,60 @@ sub build_posting_display {
}
}
+sub filter_regexp {
+ my ($rolefilter,$sectionpick,$statusfilter) = @_;
+ my ($roleregexp,$secregexp,$statusregexp);
+ my $skiptest = 1;
+ if (@{$rolefilter} > 0) {
+ my @okrolefilter = ();
+ foreach (@{$rolefilter}) {
+ unless ($_ eq '') {
+ push @okrolefilter, $_;
+ }
+ }
+ if (@okrolefilter > 0) {
+ if (grep/^all$/,@okrolefilter) {
+ $roleregexp='[^:]+';
+ } else {
+ if (@okrolefilter == 1) {
+ $roleregexp=$okrolefilter[0];
+ } else {
+ $roleregexp='('.join('|',@okrolefilter).')';
+ }
+ $skiptest = 0;
+ }
+ }
+ }
+ if (@{$sectionpick} > 0) {
+ my @oksectionpick = ();
+ foreach (@{$sectionpick}) {
+ unless ($_ eq '') {
+ push @oksectionpick, $_;
+ }
+ }
+ if ((@oksectionpick > 0) && (!grep/^all$/,@oksectionpick)) {
+ if (@oksectionpick == 1) {
+ $secregexp = $oksectionpick[0];
+ } else {
+ $secregexp .= '('.join('|',@oksectionpick).')';
+ }
+ $skiptest = 0;
+ } else {
+ $secregexp .= '[^:]*';
+ }
+ }
+ if (defined($statusfilter) && $statusfilter ne '') {
+ if ($statusfilter eq 'all') {
+ $statusregexp = '[^:]+';
+ } else {
+ $statusregexp = $statusfilter;
+ $skiptest = 0;
+ }
+ }
+ return ($skiptest,$roleregexp,$secregexp,$statusregexp);
+}
+
+
sub get_post_contents {
my ($contrib,$idx,$seeid,$type,$messages,$subjects,$allattachments,$attachtxt,$imsfiles,$screenname,$plainname,$numver) = @_;
my $discussion = '';
@@ -1480,10 +1567,8 @@ END
sub print_display_options {
my ($r,$symb,$previous,$dispchgA,$dispchgB,$markchg,$toggchg,$feedurl) = @_;
- # backward compatibility (bulletin boards used to be 'wrapped')
- if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) {
- $feedurl=~s|^/adm/wrapper||;
- }
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->send_http_header;
my $function = &Apache::loncommon::get_users_function();
my $tabcolor = &Apache::loncommon::designparm($function.'.tabbg',
@@ -1664,6 +1749,7 @@ $lt{'sdpf'} $lt{'prca'} - $l
|
+
@@ -1681,10 +1767,11 @@ END
sub print_sortfilter_options {
my ($r,$symb,$previous,$feedurl) = @_;
- # backward compatibility (bulletin boards used to be 'wrapped')
- if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) {
- $feedurl=~s|^/adm/wrapper||;
- }
+
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->send_http_header;
+
+ &Apache::lonenc::check_encrypt(\$symb);
my @sections = ();
my $section_sel = '';
my $numsections = 0;
@@ -1734,14 +1821,20 @@ sub print_sortfilter_options {
'diop' => 'Display Options',
'curr' => 'Current setting ',
'actn' => 'Action',
- 'prca' => 'Options can be set that control the sort order of the posts, in addition to which posts are displayed.',
+ 'prca' => 'Set options that control the sort order of posts, and/or which posts are displayed.',
'soor' => 'Sort order',
- 'disp' => 'Specific user roles',
- 'actv' => 'Specific role status',
+ 'spur' => 'Specific user roles',
+ 'sprs' => 'Specific role status',
'spse' => 'Specific sections',
'psub' => 'Pick specific users (by name)',
'shal' => 'Show a list of current posters'
);
+
+ my %sort_types = ();
+ my %role_types = ();
+ my %status_types = ();
+ &sort_filter_names(\%sort_types,\%role_types,\%status_types);
+
$r->print(<
@@ -1756,47 +1849,48 @@ $bodytag
$lt{'soor'} |
|
- $lt{'disp'} |
+ $lt{'sprs'} |
|
- $lt{'actv'} |
+ $lt{'spur'} |
|
$lt{'spse'} |
|
$lt{'psub'} |
-
+ |
|
|
-
- | |