--- loncom/interface/lonfeedback.pm 2006/03/21 18:37:25 1.187 +++ loncom/interface/lonfeedback.pm 2006/11/28 21:44:37 1.218 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.187 2006/03/21 18:37:25 albertel Exp $ +# $Id: lonfeedback.pm,v 1.218 2006/11/28 21:44:37 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,7 +42,10 @@ use Apache::lonenc(); use Apache::lonrss(); use HTML::LCParser(); use Apache::lonspeller(); +use Apache::longroup; use Cwd; +use lib '/home/httpd/lib/perl/'; +use LONCAPA; sub discussion_open { my ($status,$symb)=@_; @@ -71,7 +74,7 @@ sub discussion_visible { } sub list_discussion { - my ($mode,$status,$ressymb,$imsextras)=@_; + my ($mode,$status,$ressymb,$imsextras,$group)=@_; my $outputtarget=$env{'form.grade_target'}; if (defined($env{'form.export'})) { if($env{'form.export'}) { @@ -84,6 +87,11 @@ sub list_discussion { } } if (not &discussion_visible($status)) { return ''; } + if ($group ne '' && $mode eq 'board') { + if (&check_group_priv($group,'vgb') ne 'ok') { + return ''; + } + } my @bgcols = ("#cccccc","#eeeeee"); my $discussiononly=0; if ($mode eq 'board') { $discussiononly=1; } @@ -127,21 +135,13 @@ sub list_discussion { my @posters = split/\&/,$dischash{$userpickkey}; # Retain identification of "NEW" posts identified in last display, if continuing 'previous' browsing of posts. - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['previous','sortposts','rolefilter','statusfilter','sectionpick','totposters']); + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['previous','sortposts','rolefilter','statusfilter','sectionpick','grouppick','totposters']); my $sortposts = $env{'form.sortposts'}; my $statusfilter = $env{'form.statusfilter'}; - my @sectionpick = (); - if ($env{'form.sectionpick'} =~ /,/) { - @sectionpick = split/,/,$env{'form.sectionpick'}; - } else { - $sectionpick[0] = $env{'form.sectionpick'}; - } - my @rolefilter = (); - if ($env{'form.rolefilter'} =~ /,/) { - @rolefilter = split/,/,$env{'form.rolefilter'}; - } else { - $rolefilter[0] = $env{'form.rolefilter'}; - } + my @sectionpick = split(/,/,$env{'form.sectionpick'}); + my @grouppick = split(/,/,$env{'form.grouppick'}); + my @rolefilter = split(/,/,$env{'form.rolefilter'}); + my $totposters = $env{'form.totposters'}; $previous = $env{'form.previous'}; if ($previous > 0) { @@ -152,13 +152,15 @@ sub list_discussion { } } + my $cdom = $env{'course.'.$cid.'.domain'}; + my $cnum = $env{'course.'.$cid.'.num'}; + # Get information about students and non-students in course for filtering display of posts my %roleshash = (); my %roleinfo = (); + my ($classgroups,$studentgroups); if ($env{'form.rolefilter'}) { - %roleshash = &Apache::lonnet::dump('nohist_userroles', - $env{'course.'.$cid.'.domain'}, - $env{'course.'.$cid.'.num'}); + %roleshash = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum); foreach (keys %roleshash) { my ($role,$uname,$udom,$sec) = split/:/,$_; if ($role =~ /^cr/) { @@ -174,9 +176,8 @@ sub list_discussion { push @{$roleinfo{$uname.':'.$udom}}, $role.':'.$sec.':'.$status; } } - my ($classlist) = &Apache::loncoursedata::get_classlist( - $env{'course.'.$cid.'.domain'}, - $env{'course.'.$cid.'.num'}); + my ($classlist,$keylist) = + &Apache::loncoursedata::get_classlist($cdom,$cnum); my $sec_index = &Apache::loncoursedata::CL_SECTION(); my $status_index = &Apache::loncoursedata::CL_STATUS(); while (my ($student,$data) = each %$classlist) { @@ -184,6 +185,9 @@ sub list_discussion { $data->[$status_index]); push @{$roleinfo{$student}}, 'st:'.$section.':'.$status; } + ($classgroups,$studentgroups) = + &Apache::loncoursedata::get_group_memberships($classlist,$keylist, + $cdom,$cnum); } # Get discussion display default settings for user @@ -223,7 +227,15 @@ sub list_discussion { } $visit ++; - my $seeid=&Apache::lonnet::allowed('rin',$crs); + 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); + } my @discussionitems=(); my %shown = (); my @posteridentity=(); @@ -250,7 +262,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,$target,$readkey,$showunmark,$showonlyunread,$totposters,\@rolefilter,\@sectionpick,$statusfilter,$toggkey,$outputtarget,\%anonhash,$anoncnt); + &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,$target,$readkey,$showunmark,$showonlyunread,$totposters,\@rolefilter,\@sectionpick,\@grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,\%anonhash,$anoncnt,$group); my $discussion=''; my $manifestfile; @@ -323,6 +335,7 @@ sub list_discussion { if ($newpostsflag) { $chglink .= '&previous='.$prevread; } + $chglink.=&group_args($group); if ($visible) { # Print the discusssion @@ -394,23 +407,26 @@ imscp_v1p1.xsd http://www.imsglobal.org/ $discussion.='
'; $discussion .=' + + - - - - - + + +
'. ''; - my $escsymb=&Apache::lonnet::escape($ressymb); + my $escsymb=&escape($ressymb); if ($visible>2) { $discussion.=''; if ($newpostsflag) { if (!$markondisp) { - $discussion .=''; } @@ -441,6 +462,7 @@ imscp_v1p1.xsd http://www.imsglobal.org/ if ($newpostsflag) { $discussion .= '&previous='.$prevread; } + $discussion .= &group_args($group); $discussion .= '">'.&mt('Show all posts').' '.&mt('to display').' '. $numhidden.' '; if ($showunmark) { @@ -609,6 +631,10 @@ END $filterchoice = ''.&mt('sections').'- '.$env{'form.sectionpick'}; $filterchoice .= '    '; } + if (@grouppick > 0) { + $filterchoice = ''.&mt('groups').'- '.$env{'form.grouppick'}; + $filterchoice .= '    '; + } if (@rolefilter > 0) { $filterchoice .= ''.&mt('roles').'-'; foreach (@rolefilter) { @@ -687,88 +713,126 @@ END if ($discussiononly) { my $now = time; my $attachnum = 0; - my $newattachmsg = ''; - my @currnewattach = (); - my @currdelold = (); + my $currnewattach = []; + my $currdelold = []; my $comment = ''; my $subject = ''; if ($env{'form.origpage'}) { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['addnewattach','deloldattach','delnewattach','timestamp','idx','subject','comment']); - $subject = &Apache::lonnet::unescape($env{'form.subject'}); - $comment = &Apache::lonnet::unescape($env{'form.comment'}); + $subject = &unescape($env{'form.subject'}); + $comment = &unescape($env{'form.comment'}); my @keepold = (); - &process_attachments(\@currnewattach,\@currdelold,\@keepold); - if (@currnewattach > 0) { - $attachnum += @currnewattach; + &process_attachments($currnewattach,$currdelold,\@keepold); + if (@{$currnewattach} > 0) { + $attachnum += @{$currnewattach}; } } if (&discussion_open($status)) { - $discussion.=(< - - - - - -
-Note: in anonymous discussion, your name is visible only -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. '.$1.'
  2. '."\n"; - } - $newattachmsg .= '
'."\n"; - } else { - $currnewattach[0] =~ m#.*/([^/]+)$#; - $newattachmsg .= ''.$1.'
'."\n"; - } + if (($group ne '') && ($mode eq 'board')) { + if (&check_group_priv($group,'pgd') eq 'ok') { + $discussion .= + &postingform_display($mode,$ressymb,$now,$subject, + $comment,$outputtarget,$attachnum, + $currnewattach,$currdelold, + $group); } - $discussion.=$newattachmsg; - $discussion.=&generate_preview_button(); - } + } else { + $discussion.= + &postingform_display($mode,$ressymb,$now,$subject, + $comment,$outputtarget,$attachnum, + $currnewattach,$currdelold); + } } } else { + $discussion.='
'. ''.&mt('Threaded View').'  '. ''.&mt('Chronological View').'   '.&mt('Sorting/Filtering options').'  '; } else { $discussion .= ''; @@ -419,12 +435,17 @@ imscp_v1p1.xsd http://www.imsglobal.org/ if ($newpostsflag) { $discussion .= '&previous='.$prevread; } + $discussion .= &group_args($group); $discussion .= '">'.&mt('Export').'?  '. - &mt('Preferences on what is marked as NEW'). - '
'.&mt('Mark NEW posts no longer new').''; + $discussion .='
'. + &mt('Preferences on what is marked as NEW'). + '
'.&mt('Mark NEW posts no longer new').''; } else { $discussion .= '
 
'; 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.='
'. - ''. - &mt('Post Discussion').'
'; - } + $discussion.=''. + ''. + &mt('Post Discussion').'
'; + } } + $discussion.=''. + &mt('Send Message').'
'; } return $discussion; } +sub postingform_display { + my ($mode,$ressymb,$now,$subject,$comment,$outputtarget,$attachnum, + $currnewattach,$currdelold,$group) = @_; + my $newattachmsg; + my $postingform = (< + + + +
+Note: in anonymous discussion, your name is visible only +to course faculty
+Title: 

+ +ENDDISCUSS + if ($env{'form.origpage'}) { + $postingform .= ''."\n"; + foreach my $att (@{$currnewattach}) { + $postingform .= ''."\n"; + } + } + if (exists($env{'form.ref'})) { + $postingform .= ''; + } + if ($group ne '') { + $postingform .=''; + } + $postingform .= "\n"; + if ($outputtarget ne 'tex') { + $postingform .= &generate_attachments_button('',$attachnum,$ressymb, + $now,$currnewattach, + $currdelold,'',$mode); + if ((ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)) { + $newattachmsg = '
New attachments
'; + if (@{$currnewattach} > 1) { + $newattachmsg .= '
    '; + foreach my $item (@{$currnewattach}) { + $item =~ m#.*/([^/]+)$#; + $newattachmsg .= '
  1. '.$1.'
  2. '."\n"; + } + $newattachmsg .= '
'."\n"; + } else { + $$currnewattach[0] =~ m#.*/([^/]+)$#; + $newattachmsg .= ''.$1.'
'."\n"; + } + } + $postingform .= $newattachmsg; + $postingform .= &generate_preview_button(); + } + return $postingform; +} + 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,$anonhash,$anoncnt) = @_; + 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,$grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,$anonhash,$anoncnt,$group) = @_; my @original=(); my @index=(); + my $skip_group_check = 0; my $symb=&Apache::lonenc::check_decrypt($ressymb); - my $escsymb=&Apache::lonnet::escape($ressymb); + my $escsymb=&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'}); + if ((@{$grouppick} == 0) || (grep(/^all$/,@{$grouppick}))) { + $skip_group_check = 1; + } if ($contrib{'version'}) { my $oldest = $contrib{'1:timestamp'}; if ($prevread eq '0') { @@ -776,7 +840,8 @@ sub build_posting_display { } my ($skiptest,$rolematch,$roleregexp,$secregexp,$statusregexp); if ($sortposts) { - ($skiptest,$roleregexp,$secregexp,$statusregexp) = &filter_regexp($rolefilter,$sectionpick,$statusfilter); + ($skiptest,$roleregexp,$secregexp,$statusregexp) = + &filter_regexp($rolefilter,$sectionpick,$statusfilter); $rolematch = $roleregexp.':'.$secregexp.':'.$statusregexp; } for (my $id=1;$id<=$contrib{'version'};$id++) { @@ -865,7 +930,7 @@ sub build_posting_display { @{$$subjectsort{$subject}} = ("$idx"); } } - if ((!$contrib{$idx.':anonymous'}) || ($seeid)) { + if ((!$contrib{$idx.':anonymous'}) || (&Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')))) { $sender=&Apache::loncommon::aboutmewrapper( $plainname, $contrib{$idx.':sendername'}, @@ -906,14 +971,16 @@ sub build_posting_display { } else { @{$$namesort{$lastname}{$firstname}} = ("$idx"); } - if (&editing_allowed()) { + if (&editing_allowed($escsymb.':::'.$idx,$group)) { if (($env{'user.domain'} eq $contrib{$idx.':senderdomain'}) && ($env{'user.name'} eq $contrib{$idx.':sendername'})) { $sender.=' '.&mt('Edit').''; + $sender .= &group_args($group); + $sender .= '" '.$target.'>'.&mt('Edit').''; + unless ($seeid) { $sender.=" '; @@ -936,6 +1003,7 @@ sub build_posting_display { if ($$newpostsflag) { $sender .= '&previous='.$prevread; } + $sender .= &group_args($group); $sender .= '">'.&mt('Hide').''; } $sender.=' '.&mt('Delete').''; } } else { @@ -970,16 +1039,27 @@ sub build_posting_display { @{$$namesort{'__anon'}{'__anon'}} = ("$idx"); } } - if (&discussion_open($status) && - &Apache::lonnet::allowed('pch', - $env{'request.course.id'}. - ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { - $sender.=' '.&mt('Reply').''; + } elsif (&Apache::lonnet::allowed('pch', + $env{'request.course.id'}. + ($env{'request.course.sec'}?'/'. + $env{'request.course.sec'}:''))) { + $sender.=' '.&mt('Reply').''; } - $sender .= '" '.$target.'>'.&mt('Reply').''; } if ($viewgrades) { $vgrlink=&Apache::loncommon::submlink('Submissions', @@ -1036,7 +1116,7 @@ sub build_posting_display { my $uname = $contrib{$idx.':sendername'}; my $udom = $contrib{$idx.':senderdomain'}; my $poster = $uname.':'.$udom; - if (defined($env{'form.totposters'})) { + if ($env{'form.totposters'} ne '') { if ($totposters == 0) { $$shown{$idx} = 0; } elsif ($totposters > 0) { @@ -1061,6 +1141,23 @@ sub build_posting_display { } } } + if ($$shown{$idx} && !$skip_group_check) { + my $showflag = 0; + if (ref($$classgroups{$poster}{active}) eq 'HASH') { + foreach my $grp (@{$grouppick}) { + if (grep/^\Q$grp\E$/, + keys(%{$$classgroups{$poster}{active}})) { + $showflag = 1; + last; + } + } + } + if ($showflag) { + $$shown{$idx} = 1; + } else { + $$shown{$idx} = 0; + } + } } else { $$shown{$idx} = 1; } @@ -1091,7 +1188,9 @@ 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/:/) { @@ -1154,6 +1253,7 @@ sub filter_regexp { $secregexp .= '[^:]*'; } } + if (defined($statusfilter) && $statusfilter ne '') { if ($statusfilter eq 'all') { $statusregexp = '[^:]+'; @@ -1174,7 +1274,7 @@ sub get_post_contents { %{$$imsfiles{$idx}}=(); if ($type eq 'allversions') { unless($seeid) { - $discussion=&mt('You do not have privileges to view all versions of posts.').&mt('Please select a different role'); + $discussion=&mt('You do not have privileges to view all versions of posts.').' '.&mt('Please select a different role.'); return $discussion; } } @@ -1301,7 +1401,7 @@ sub replicate_attachments { sub mail_screen { my ($r,$feedurl,$options) = @_; if (exists($env{'form.origpage'})) { - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','currnewattach','addnewattach','deloldattach','delnewattach','timestamp','idx','anondiscuss','discuss','blog']); + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','currnewattach','addnewattach','deloldattach','delnewattach','timestamp','idx','anondiscuss','discuss','blog','group','ref']); } my $title=&Apache::lonnet::gettitle($feedurl); @@ -1323,12 +1423,15 @@ sub mail_screen { my $attachnum = 0; my $anonchk = (< 0) { my %msgversions = (); &get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver); - $message = $msgversions{$numoldver}; + $quote = $msgversions{$numoldver}; } - &newline_to_br(\$message); - $quote='
'.&Apache::lontexconvert::msgtexconverted($message).'
'; if ($idx > 0) { my %subversions = (); &get_post_versions(\%subversions,$contrib{$idx.':subject'},1,$numoldver); @@ -1409,20 +1511,17 @@ END $parentmsg = $contrib{$idx.':replyto'}; } unless (exists($env{'form.origpage'})) { - my $anonflag = 0; + my $anonflag = 'nonanon'; if ($contrib{$idx.':anonymous'}) { - $anonflag = 1; + $anonflag = 'anon'; } $anonscript = (< END - my $onload = 'onLoad="window.focus();setposttype();"'; + my %onload = ('onload' => 'window.focus();setposttype();'); my $start_page= &Apache::loncommon::start_page('Resource Feedback and Discussion',$js, - {'add_entries' => $onload}); + {'add_entries' => \%onload}); + + if ($quote ne '') { + &newline_to_br(\$quote); + $quote='
'.&Apache::lontexconvert::msgtexconverted($quote).'
'; + } $r->print(< END } + if (exists($env{'form.group'})) { + $r->print(''); + } + if (exists($env{'form.ref'})) { + $r->print(''); + } $r->print(< @@ -1578,7 +1671,7 @@ END $r->print(&generate_attachments_button($postidx,$attachnum,$ressymb,$now,\@currnewattach,\@currdelold,$numoldver)); if ($attachnum > 0) { if (@currnewattach > 0) { - $newattachmsg .= 'New attachments
'; + $newattachmsg .= '
New attachments
'; if (@currnewattach > 1) { $newattachmsg .= '
    '; foreach my $item (@currnewattach) { @@ -1592,7 +1685,7 @@ END } } if ($attachmsg) { - $r->print("Retained attachments:$attachmsg
    \n"); + $r->print("
    Retained attachments:$attachmsg
    \n"); } if ($newattachmsg) { $r->print("$newattachmsg
    "); @@ -1749,44 +1842,45 @@ END my $end_page = &Apache::loncommon::end_page(); $r->print(< +$start_page +
    $lt{'sdpf'}
    $lt{'prca'}
    1. $lt{'whpo'}
    2. $lt{'unwh'}
    3. $lt{'wipa'}

    - - - - -
    - - - - -
    - - - - - +END + $r->print(&Apache::loncommon::start_data_table()); + $r->print(< + - +END + $r->print(&Apache::loncommon::start_data_table_row()); + $r->print(<$lt{'disa'} - +END + $r->print(&Apache::loncommon::end_data_table_row()); + $r->print(&Apache::loncommon::start_data_table_row()); + $r->print(<$lt{'npmr'} - +END + $r->print(&Apache::loncommon::end_data_table_row()); + $r->print(&Apache::loncommon::start_data_table_row()); + $r->print(<$lt{'dotm'} - -
    $lt{'pref'}$lt{'curr'}$lt{'actn'}?$lt{'pref'} + $lt{'curr'} + $lt{'actn'}?
    $lt{$discdisp}
    $lt{$discmark}
    $lt{$disctogg}
    -
    -
    +END + $r->print(&Apache::loncommon::end_data_table_row()); + $r->print(&Apache::loncommon::end_data_table()); + $r->print(<
    @@ -1796,11 +1890,19 @@ $lt{'sdpf'}
    $lt{'prca'}
    1. $l +END + if (exists($env{'form.group'})) { + $r->print(''); + } + if (exists($env{'form.ref'})) { + $r->print(''); + } + $r->print("

    2. $end_page -END + "); return; } @@ -1811,28 +1913,55 @@ sub print_sortfilter_options { $r->send_http_header; &Apache::lonenc::check_encrypt(\$symb); - my @sections = (); + my @sections; my $section_sel = ''; - my $numsections = 0; my $numvisible = 5; - my %sectioncount = (); - - $numsections = &Apache::loncommon::get_sections($env{'course.'.$env{'request.course.id'}.'.domain'},$env{'course.'.$env{'request.course.id'}.'.num'},\%sectioncount); + my @groups; + my $group_sel = ''; + my $numgroupvis = 5; + my %sectioncount = &Apache::loncommon::get_sections(); if ($env{'request.course.sec'} !~ /^\s*$/) { #Restrict section choice to current section @sections = ('all',$env{'request.course.sec'}); $numvisible = 2; } else { @sections = sort {$a cmp $b} keys(%sectioncount); + if (scalar(@sections) < 4) { + $numvisible = scalar(@sections) + 1; + } unshift(@sections,'all'); # Put 'all' at the front of the list - if ($numsections < 4) { - $numvisible = $numsections + 1; + + } + foreach my $sec (@sections) { + $section_sel .= " \n"; + } + + if (&check_group_priv() eq 'ok') { + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum); + @groups = sort {$a cmp $b} keys(%curr_groups); + if (scalar(@groups) < 4) { + $numgroupvis = scalar(@groups) + 1; + } + unshift(@groups,'all'); # Put 'all' at the front of the list + } else { + my @coursegroups = split(/:/,$env{'request.course.groups'}); + if (@coursegroups > 0) { + @coursegroups = sort {$a cmp $b} @coursegroups; + @groups = ('all',@coursegroups); + if (scalar(@groups) < 4) { + $numgroupvis = scalar(@groups) + 1; + } + } else { + @groups = ('all'); + $numgroupvis = 1; } } - foreach (@sections) { - $section_sel .= " \n"; } - + my $function = &Apache::loncommon::get_users_function(); my $tabcolor = &Apache::loncommon::designparm($function.'.tabbg', $env{'user.domain'}); @@ -1845,6 +1974,7 @@ sub print_sortfilter_options { 'spur' => 'Specific user roles', 'sprs' => 'Specific role status', 'spse' => 'Specific sections', + 'spgr' => 'Specific groups', 'psub' => 'Pick specific users (by name)', 'shal' => 'Show a list of current posters' ); @@ -1876,6 +2006,17 @@ function verifyFilter() { if (secnum == 0) { document.modifyshown.sectionpick.options[0].selected = true } + + var grpnum = 0 + for (var i=0; i @@ -1901,48 +2042,56 @@ $start_page
  $lt{'spse'}  $lt{'spgr'}  $lt{'psub'}
+   +   +   +   + +  

@@ -1950,11 +2099,19 @@ $start_page +END + if (exists($env{'form.group'})) { + $r->print(''); + } + if (exists($env{'form.ref'})) { + $r->print(''); + } + $r->print("

$end_page -END +"); } sub print_showposters { @@ -1969,19 +2126,36 @@ sub print_showposters { $crs.='_'.$env{'request.course.sec'}; } $crs=~s/\_/\//g; - my $seeid=&Apache::lonnet::allowed('rin',$crs); + my $seeid; + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $group = $env{'form.group'}; + my $ressymb = &wrap_symb($symb); + if (($group ne '') && + ($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); + } my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'}, - $env{'course.'.$env{'request.course.id'}.'.domain'}, - $env{'course.'.$env{'request.course.id'}.'.num'}); + $cdom,$cnum); my %namesort = (); my %postcounts = (); + my %lt = &Apache::lonlocal::texthash( + sele => 'Select', + full => 'Fullname', + usdo => 'Username/domain', + post => 'Posts', + ); if ($contrib{'version'}) { for (my $idx=1;$idx<=$contrib{'version'};$idx++) { my $hidden=($contrib{'hidden'}=~/\.$idx\./); my $deleted=($contrib{'deleted'}=~/\.$idx\./); unless ((($hidden) && (!$seeid)) || ($deleted)) { - if ((!$contrib{$idx.':anonymous'}) || ($seeid)) { + if ((!$contrib{$idx.':anonymous'}) || (&Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')))) { my %names = &Apache::lonnet::get('environment',['firstname','lastname'],$contrib{$idx.':senderdomain'},$contrib{$idx.':sendername'}); my $lastname = $names{'lastname'}; my $firstname = $names{'firstname'}; @@ -2009,19 +2183,17 @@ sub print_showposters { } my $start_page = &Apache::loncommon::start_page('Discussion options'); - + my $table_start =&Apache::loncommon::start_data_table(); $r->print(< - - -
- - - - - - +
+ $table_start + + + + + END my $count = 0; @@ -2033,18 +2205,19 @@ END next; } else { $count ++; - $r->print(''); + $r->print(&Apache::loncommon::start_data_table_row(). + ' + + + '. + &Apache::loncommon::end_data_table_row()); } } } } - + $r->print(&Apache::loncommon::end_data_table()); my $end_page = &Apache::loncommon::end_page(); $r->print(< - - -
No.SelectFullname(Username/domain)Posts
#$lt{'sele'}$lt{'full'} ($lt{'usdo'})$lt{'post'}
'.$count.''.$last.', '.$first.' ('.$uname.','.$udom.')'.$postcounts{$_}.'
'.$count.''.$last.', '.$first.' ('.$uname.','.$udom.')'.$postcounts{$_}.'

@@ -2131,18 +2304,18 @@ ENDFAILREDIR } sub redirect_back { - my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$blog,$status,$previous,$sort,$rolefilter,$statusfilter,$sectionpick,$numpicks) = @_; + my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$blog,$status,$previous,$sort,$rolefilter,$statusfilter,$sectionpick,$grouppick,$numpicks,$group) = @_; my $sorttag = ''; my $roletag = ''; my $statustag = ''; my $sectag = ''; + my $grptag = ''; my $userpicktag = ''; my $qrystr = ''; my $prevtag = ''; &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; - &dewrapper(\$feedurl); if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' }; if ($previous > 0) { @@ -2181,6 +2354,20 @@ sub redirect_back { $feedurl .= '§ionpick='.$sectionpick; $sectag = ''; } + if (ref($grouppick) eq 'ARRAY') { + $feedurl .= '&grouppick='; + $sectag .= ''; + } else { + $feedurl .= '&grouppick='.$grouppick; + $grptag = ''; + } if (ref($rolefilter) eq 'ARRAY') { $feedurl .= '&rolefilter='; $roletag .= ''; } } + my $grouptag; + if ($group ne '') { + $grouptag = ''; my $refarg; + if (exists($env{'form.ref'})) { + $refarg = '&ref='.$env{'form.ref'}; + $grouptag .= ''; + } + if ($feedurl =~ /\?/) { + $feedurl .= '&group='.$group.$refarg; + } else { + $feedurl .= '?group='.$group.$refarg; + } + } $feedurl=&Apache::lonenc::check_encrypt($feedurl); my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif'); - my $onload = 'onLoad=\'if (window.name!="loncapaclient") { this.document.reldt.submit(); self.window.close(); }\''; + my %onload; + if ($env{'environment.remote'} ne 'off') { + $onload{'onload'} = + "if (window.name!='loncapaclient') { this.document.reldt.submit(); self.window.close(); }"; + } my $start_page= - &Apache::loncommon::start_page('New posts marked as read',undef, - {'redirect' => [2,$feedurl], + &Apache::loncommon::start_page('Feedback sent',undef, + {'redirect' => [0,$feedurl], 'only_body' => 1, - 'add_entries' => $onload}); + 'add_entries' => \%onload}); my $end_page = &Apache::loncommon::end_page(); - $r->print(< @@ -2222,7 +2425,9 @@ $sorttag $statustag $roletag $sectag +$grptag $userpicktag +$grouptag $end_page ENDREDIR @@ -2232,8 +2437,15 @@ sub no_redirect_back { my ($r,$feedurl) = @_; my $nofeed=&mt('Sorry, no feedback possible on this resource ...'); + my %onload; + if ($env{'environment.remote'} ne 'off') { + $onload{'onload'} = + "if (window.name!='loncapaclient') { self.window.close(); }"; + } + my %body_options = ('only_body' => 1, - 'add_entries' => 'onLoad=\'if (window.name!="loncapaclient") { self.window.close(); }\''); + 'bgcolor' => '#FFFFFF', + 'add_entries' => \%onload,); if ($feedurl !~ m{^/adm/feedback}) { $body_options{'rediect'} = [2,$feedurl]; @@ -2247,8 +2459,7 @@ sub no_redirect_back { $feedurl=&Apache::lonenc::check_encrypt($feedurl); my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif'); $r->print (< - +$start_page $nofeed
@@ -2263,36 +2474,35 @@ sub screen_header { unless (($env{'form.replydisc'}) || ($env{'form.editdisc'})) { if (($feedurl=~/^\/res\//) && ($feedurl!~/^\/res\/adm/) && ($env{'user.adv'})) { $msgoptions= - '

'; } if (&feedback_available(1)) { $msgoptions.= - '

'; } if (&feedback_available(0,1)) { $msgoptions.= - '

'; } if (&feedback_available(0,0,1)) { $msgoptions.= - '

'; } } - if ($env{'request.course.id'}) { + if (($env{'request.course.id'}) && (!$env{'form.sendmessageonly'})) { if (&discussion_open(undef,$symb) && &Apache::lonnet::allowed('pch', $env{'request.course.id'}. ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { - $discussoptions='