--- loncom/interface/lonfeedback.pm 2005/11/18 13:35:30 1.175 +++ loncom/interface/lonfeedback.pm 2006/08/16 19:32:54 1.216 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.175 2005/11/18 13:35:30 www Exp $ +# $Id: lonfeedback.pm,v 1.216 2006/08/16 19:32:54 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.='
'. + $discussion.=''. ''. - &mt('Post 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,16 +971,18 @@ 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($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.=" '; } } @@ -925,24 +992,26 @@ sub build_posting_display { unless ($studenthidden) { $sender.=' '.&mt('Make Visible').''; } } else { $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; } } @@ -1253,7 +1353,7 @@ END } } if ($type eq 'allversions') { - $discussion.=(''); + $discussion.=''; return $discussion; } else { return; @@ -1301,10 +1401,9 @@ 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 $bodytag=&Apache::loncommon::bodytag('Resource Feedback and Discussion', - '','onLoad="window.focus();setposttype();"'); + my $title=&Apache::lonnet::gettitle($feedurl); if (!$title) { $title = $feedurl; } my $quote=''; @@ -1324,12 +1423,15 @@ sub mail_screen { my $attachnum = 0; my $anonchk = (<print(< -The LearningOnline Network with CAPA - -$htmlheader + my $js= < // - -$bodytag +END + + my %onload = ('onload' => 'window.focus();setposttype();'); + my $start_page= + &Apache::loncommon::start_page('Resource Feedback and Discussion',$js, + {'add_entries' => \%onload}); + + $r->print(<$title
@@ -1559,6 +1643,12 @@ Attachment (128 KB max size): END } + if (exists($env{'form.group'})) { + $r->print(''); + } + if (exists($env{'form.ref'})) { + $r->print(''); + } $r->print(< @@ -1579,7 +1669,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) { @@ -1593,7 +1683,7 @@ END } } if ($attachmsg) { - $r->print("Retained attachments:$attachmsg
    \n"); + $r->print("
    Retained attachments:$attachmsg
    \n"); } if ($newattachmsg) { $r->print("$newattachmsg
    "); @@ -1602,7 +1692,8 @@ END } $r->print(&generate_preview_button(). &Apache::lonhtmlcommon::htmlareaselectactive('comment'). - ''); + &Apache::loncommon::end_page()); + } sub print_display_options { @@ -1613,11 +1704,8 @@ sub print_display_options { my $function = &Apache::loncommon::get_users_function(); my $tabcolor = &Apache::loncommon::designparm($function.'.tabbg', $env{'user.domain'}); - my $bodytag=&Apache::loncommon::bodytag('Discussion options', - '',''); my %lt = &Apache::lonlocal::texthash( - 'dido' => 'Discussion display options', 'pref' => 'Display Preference', 'curr' => 'Current setting ', 'actn' => 'Action', @@ -1675,13 +1763,9 @@ sub print_display_options { $currtogg = $lt{'toggon'}; $disctogg = 'toggon'; } - my $html=&Apache::lonxml::xmlbegin(); - $r->print(< -$lt{'dido'} - - - -$bodytag - +END + + + my $start_page = + &Apache::loncommon::start_page('Discussion display options',$js); + my $end_page = + &Apache::loncommon::end_page(); + $r->print(< $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(<
    @@ -1797,12 +1888,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 +$end_page + "); return; } @@ -1813,35 +1911,59 @@ 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'}); - my $bodytag=&Apache::loncommon::bodytag('Discussion options', - '',''); my %lt = &Apache::lonlocal::texthash( - 'diso' => 'Discussion sorting and filtering options', 'diop' => 'Display Options', 'curr' => 'Current setting ', 'actn' => 'Action', @@ -1850,6 +1972,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' ); @@ -1858,12 +1981,8 @@ sub print_sortfilter_options { my %role_types = (); my %status_types = (); &sort_filter_names(\%sort_types,\%role_types,\%status_types); - my $html=&Apache::lonxml::xmlbegin(); - $r->print(< -$lt{'diso'} - + + my $js = < function verifyFilter() { var rolenum = 0 @@ -1885,12 +2004,30 @@ function verifyFilter() { if (secnum == 0) { document.modifyshown.sectionpick.options[0].selected = true } + + var grpnum = 0 + for (var i=0; i - -$bodytag -
      +END + + my $start_page= + &Apache::loncommon::start_page('Discussion options',$js); + my $end_page= + &Apache::loncommon::end_page(); + + $r->print(< $lt{'diso'}
      $lt{'prca'}

      @@ -1903,48 +2040,56 @@ $bodytag + + - - - - - + + +
        $lt{'spse'}  $lt{'spgr'}  $lt{'psub'}
      +   +   +   +   + +  

      @@ -1952,12 +2097,19 @@ $bodytag +END + if (exists($env{'form.group'})) { + $r->print(''); + } + if (exists($env{'form.ref'})) { + $r->print(''); + } + $r->print("

      - - -END +$end_page +"); } sub print_showposters { @@ -1972,23 +2124,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( - 'diso' => 'Discussion filtering options', - ); - my $bodytag=&Apache::loncommon::bodytag('Discussion options', - '',''); + + 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'}; @@ -2014,24 +2179,19 @@ sub print_showposters { } } } - my $html=&Apache::lonxml::xmlbegin(); + + my $start_page = &Apache::loncommon::start_page('Discussion options'); + my $table_start =&Apache::loncommon::start_data_table(); $r->print(< -$lt{'diso'} - - -$bodytag +$start_page
      - - -
      - - - - - - +
      + $table_start + + + + + END my $count = 0; @@ -2043,23 +2203,25 @@ 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{$_}.'

      - - +$end_page END } @@ -2067,7 +2229,8 @@ sub get_post_versions { my ($versions,$incoming,$htmldecode,$numver) = @_; if ($incoming =~ /^/) { my $p = HTML::LCParser->new(\$incoming); - my $done = 0; + my $done = 0; + while ( (my $token = $p->get_tag("version")) && (!$done)) { my $num = $token->[1]{num}; my $text = $p->get_text("/version"); @@ -2128,36 +2291,29 @@ sub fail_redirect { my ($r,$feedurl) = @_; if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' }; my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif'); - my $html=&Apache::lonxml::xmlbegin(); - $r->print (< -Feedback not sent - - - - + $r->print(&Apache::loncommon::start_page('Feedback not sent',undef, + {'redirect' => [2,$feedurl], + 'only_body' => 1,})); + $r->print(< Sorry, no recipients ... -
      Continue - - ENDFAILREDIR + $r->print(&Apache::loncommon::end_page()); } 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) { @@ -2196,6 +2352,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 $html=&Apache::lonxml::xmlbegin(); - $r->print (< -Feedback sent - - - - + 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('Feedback sent',undef, + {'redirect' => [0,$feedurl], + 'only_body' => 1, + 'add_entries' => \%onload}); + my $end_page = &Apache::loncommon::end_page(); + $r->print(< $typestyle Sent $sendsomething message(s), and $sendposts post(s). @@ -2236,40 +2423,45 @@ $sorttag $statustag $roletag $sectag +$grptag $userpicktag +$grouptag -
      Continue - - +$end_page ENDREDIR } sub no_redirect_back { my ($r,$feedurl) = @_; my $nofeed=&mt('Sorry, no feedback possible on this resource ...'); - my $continue=&mt('Continue'); - my $html=&Apache::lonxml::xmlbegin(); - $r->print (< -Feedback not sent - -ENDNOREDIR - - if ($feedurl!~/^\/adm\/feedback/) { - $r->print(''); - } + + my %onload; + if ($env{'environment.remote'} ne 'off') { + $onload{'onload'} = + "if (window.name!='loncapaclient') { self.window.close(); }"; + } + + my %body_options = ('only_body' => 1, + 'bgcolor' => '#FFFFFF', + 'add_entries' => \%onload,); + + if ($feedurl !~ m{^/adm/feedback}) { + $body_options{'rediect'} = [2,$feedurl]; + } + my $start_page= + &Apache::loncommon::start_page('Feedback not sent',undef, + \%body_options); + + my $end_page = &Apache::loncommon::end_page(); + $feedurl=&Apache::lonenc::check_encrypt($feedurl); my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif'); $r->print (< - +$start_page $nofeed -
      $continue - - +
      +$end_page ENDNOREDIRTWO } @@ -2280,42 +2472,41 @@ 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=''; } if ($msgoptions) { $msgoptions='

      '.&mt('Sending Messages').'

      '.$msgoptions; } if ($discussoptions) { @@ -2337,8 +2528,9 @@ sub resource_output { } sub clear_out_html { - my ($message,$override)=@_; - unless (&Apache::lonhtmlcommon::htmlareablocked()) { return $message; } + my ($message,$override,$ignore_htmlarea)=@_; + if (!$ignore_htmlarea + && !&Apache::lonhtmlcommon::htmlareablocked()) { return $message; } # Always allow the -tag my %html=(M=>1); # Check if more is allowed @@ -2432,13 +2624,13 @@ sub decide_receiver { my ($feedurl,$author,$question,$course,$policy,$defaultflag) = @_; my $typestyle=''; my %to=(); - if ($env{'form.author'}||$author) { + if ($env{'form.discuss'} eq 'author' ||$author) { $typestyle.='Submitting as Author Feedback
      '; $feedurl=~/^\/res\/(\w+)\/(\w+)\//; $to{$2.':'.$1}=1; } - if ($env{'form.question'}||$question) { - $typestyle.='Submitting as Question
      '; + if ($env{'form.discuss'} eq 'question' ||$question) { + $typestyle.=&mt('Submitting as Question').'
      '; foreach (split(/\,/, $env{'course.'.$env{'request.course.id'}.'.question.email'}) ) { @@ -2446,8 +2638,8 @@ sub decide_receiver { if ($rec) { $to{$rec}=1; } } } - if ($env{'form.course'}||$course) { - $typestyle.='Submitting as Comment
      '; + if ($env{'form.discuss'} eq 'course' ||$course) { + $typestyle.=&mt('Submitting as Comment').'
      '; foreach (split(/\,/, $env{'course.'.$env{'request.course.id'}.'.comment.email'}) ) { @@ -2455,8 +2647,8 @@ sub decide_receiver { if ($rec) { $to{$rec}=1; } } } - if ($env{'form.policy'}||$policy) { - $typestyle.='Submitting as Policy Feedback
      '; + if ($env{'form.discuss'} eq 'policy' ||$policy) { + $typestyle.=&mt('Submitting as Policy Feedback').'
      '; foreach (split(/\,/, $env{'course.'.$env{'request.course.id'}.'.policy.email'}) ) { @@ -2478,14 +2670,16 @@ sub feedback_available { } sub send_msg { - my ($feedurl,$email,$citations,$attachmenturl,%to)=@_; + my ($title,$feedurl,$email,$citations,$attachmenturl,%to)=@_; my $status=''; my $sendsomething=0; + if ($title=~/^Error/) { $title=&mt('Feedback').': '.$title; } + unless ($title=~/\w/) { $title=&mt('Feedback'); } foreach (keys %to) { if ($_) { my $declutter=&Apache::lonnet::declutter($feedurl); unless (&Apache::lonmsg::user_normal_msg(split(/\:/,$_), - 'Feedback ['.$declutter.']',$email,$citations,$feedurl, + $title.' ['.$declutter.']',$email,$citations,$feedurl, $attachmenturl)=~/ok/) { $status.='
      '.&mt('Error sending message to').' '.$_.'
      '; } else { @@ -2539,7 +2733,6 @@ sub adddiscuss { } if (($symb) && ($email)) { if ($env{'form.editdisc'}) { - my %newcontrib = (); $contrib{'ip'}=$ENV{'REMOTE_ADDR'}; $contrib{'host'}=$Apache::lonnet::perlvar{'lonHostID'}; $contrib{'timestamp'} = time; @@ -2582,12 +2775,8 @@ sub adddiscuss { } } $contrib{'history'} .= $oldcontrib{$oldidx.':timestamp'}; - foreach (keys %contrib) { - my $key = $oldidx.':'.&Apache::lonnet::escape($oldsymb).':'.$_; - $newcontrib{$key} = $contrib{$_}; - } my $put_reply = &Apache::lonnet::putstore($env{'request.course.id'}, - \%newcontrib, + $oldsymb,$oldidx,\%contrib, $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}); $status='Editing class discussion'.($anon?' (anonymous)':''); @@ -2621,21 +2810,25 @@ sub adddiscuss { # ----------------------------------------------------------- Preview function sub show_preview { - my $r=shift; + my ($r) = @_; &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; my $message=&clear_out_html($env{'form.comment'}); &newline_to_br(\$message); $message=&Apache::lonspeller::markeduptext($message); $message=&Apache::lontexconvert::msgtexconverted($message); - my $subject=&clear_out_html($env{'form.subject'}); + my $subject=&clear_out_html($env{'form.subject'},undef,1); $subject=~s/\n/\
      /g; $subject=&Apache::lontexconvert::msgtexconverted($subject); - my $html=&Apache::lonxml::xmlbegin(); - $r->print($html.''. - '
      '. + my $start_page= + &Apache::loncommon::start_page('Preview',undef, + {'only_body' => 1,}); + + my $end_page = &Apache::loncommon::end_page(); + + $r->print($start_page.'
      '. 'Subject: '.$subject.'

      '. - $message.'
      '); + $message.'
      '.$end_page); } @@ -2666,6 +2859,7 @@ sub generate_preview_button { unless ($fieldname) { $fieldname='comment'; } my $pre=&mt("Show Preview and Check Spelling"); return(<
      @@ -2677,14 +2871,13 @@ ENDPREVIEW sub modify_attachments { my ($r,$currnewattach,$currdelold,$symb,$idx,$attachmenturls)=@_; - my $orig_subject = &Apache::lonnet::unescape($env{'form.subject'}); - my $subject=&clear_out_html($orig_subject); + my $orig_subject = &unescape($env{'form.subject'}); + my $subject=&clear_out_html($orig_subject,undef,1); $subject=~s/\n/\
      /g; $subject=&Apache::lontexconvert::msgtexconverted($subject); my $timestamp=$env{'form.timestamp'}; my $numoldver=$env{'form.numoldver'}; - my $bodytag=&Apache::loncommon::bodytag('Discussion Post Attachments', - '',''); + my $msg = ''; my %attachments = (); my %currattach = (); @@ -2692,19 +2885,22 @@ sub modify_attachments { &extract_attachments($attachmenturls,$idx,$numoldver,\$msg,\%attachments,\%currattach,$currdelold); } &Apache::lonenc::check_encrypt(\$symb); - my $html=&Apache::lonxml::xmlbegin(); - $r->print(< -Managing Attachments - - -$bodytag +END + + my $start_page = + &Apache::loncommon::start_page('Discussion Post Attachments',$js); + my $end_page = + &Apache::loncommon::end_page(); + + $r->print(< @@ -2725,7 +2921,7 @@ END } } } - if (@{$currnewattach} > 0) { + if ((ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)) { $r->print("The following attachments have been uploaded for inclusion with this posting.
      Check the checkboxes for any you wish to remove
      \n"); foreach (@{$currnewattach}) { $_ =~ m#/([^/]+)$#; @@ -2744,7 +2940,6 @@ END - END @@ -2757,8 +2952,7 @@ END $r->print(< - - +$end_page END return; } @@ -2796,6 +2990,7 @@ sub generate_attachments_button { my $origpage = $ENV{'REQUEST_URI'}; my $att=$attachnum.' '.&mt("attachments"); my $response = (<
      Click to add/remove attachments:  - ENDATTACH @@ -2975,8 +3169,9 @@ sub sort_filter_names { ); %{$status_types} = ( all => 'Roles of any status', - Active => 'Only active roles', - Expired => 'Only inactive roles' + Active => 'Only active roles', + Expired => 'Only past roles', + Future => 'Only future roles', ); } @@ -2991,8 +3186,18 @@ sub handler { # --------------------------- Get query string for limited number of parameters &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, - ['hide','unhide','deldisc','postdata','preview','replydisc','editdisc','cmd','symb','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navtime','navmaps','navurl','sortposts','applysort','rolefilter','statusfilter','sectionpick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export']); - + ['hide','unhide','deldisc','postdata','preview','replydisc','editdisc','cmd','symb','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navtime','navmaps','navurl','sortposts','applysort','rolefilter','statusfilter','sectionpick','groupick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export','sendmessageonly','group','ref']); + my $group = $env{'form.group'}; + if ($env{'form.editdisc'}) { + if (!(&editing_allowed($env{'form.editdisc'},$env{'form.group'}))) { + my $symb=(split(/\:\:\:/,$env{'form.editdisc'}))[0]; + my ($map,$id,$url)=&Apache::lonnet::decode_symb($symb); + my $feedurl=&Apache::lonnet::clutter($url); + &redirect_back($r,$feedurl,&mt('Editing not permitted').'
      ', '0','0','','',$env{'form.previous'},undef,undef,undef, + undef,undef,undef,$group); + return OK; + } + } if ($env{'form.discsymb'}) { my ($symb,$feedurl) = &get_feedurl_and_clean_symb($env{'form.discsymb'}); my $readkey = $symb.'_read'; @@ -3016,30 +3221,36 @@ sub handler { \%readinghash,$env{'user.domain'},$env{'user.name'}); } &redirect_back($r,$feedurl,&mt('Marked postings read/unread').'
      ', - '0','0','','',$env{'form.previous'},'','','',); + '0','0','','',$env{'form.previous'},'','','', + undef,undef,undef,$group); return OK; } if ($env{'form.allversions'}) { &Apache::loncommon::content_type($r,'text/html'); + &Apache::loncommon::no_cache($r); $r->send_http_header; - my $html=&Apache::lonxml::xmlbegin(); - my $bodytag=&Apache::loncommon::bodytag('Discussion Post Versions'); - $r->print(< -Post Versions - - -$bodytag -END + + $r->print(&Apache::loncommon::start_page('Discussion Post Versions')); + my $crs='/'.$env{'request.course.id'}; if ($env{'request.course.sec'}) { $crs.='_'.$env{'request.course.sec'}; } $crs=~s|_|/|g; - my $seeid=&Apache::lonnet::allowed('rin',$crs); + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; my ($symb,$idx)=split(/\:\:\:/,$env{'form.allversions'}); ($symb)=&get_feedurl_and_clean_symb($symb); + my $ressymb = &wrap_symb($symb); + my $group = $env{'form.group'}; + my $seeid; + 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); + } if ($idx > 0) { my %messages = (); my %subjects = (); @@ -3052,6 +3263,7 @@ END $env{'course.'.$env{'request.course.id'}.'.num'}); $r->print(&get_post_contents(\%contrib,$idx,$seeid,'allversions',\%messages,\%subjects,\%allattachments,\%attachmsgs,\%imsfiles,\$screenname,\$plainname)); } + $r->print(&Apache::loncommon::end_page()); return OK; } if ($env{'form.posterlist'}) { @@ -3070,7 +3282,7 @@ END \%discinfo,$env{'user.domain'},$env{'user.name'}); &redirect_back($r,$feedurl,&mt('Changed sort/filter').'
      ','0','0','', '',$env{'form.previous'},$env{'form.sortposts'},'','','', - $numpicks); + '',$numpicks,$group); return OK; } if ($env{'form.applysort'}) { @@ -3078,7 +3290,8 @@ END &redirect_back($r,$feedurl,&mt('Changed sort/filter').'
      ','0','0','', '',$env{'form.previous'},$env{'form.sortposts'}, $env{'form.rolefilter'},$env{'form.statusfilter'}, - $env{'form.sectionpick'}); + $env{'form.sectionpick'},$env{'form.grouppick'}, + undef,$group); return OK; } elsif ($env{'form.cmd'} eq 'sortfilter') { my ($symb,$feedurl)=&get_feedurl_and_clean_symb($env{'form.symb'}); @@ -3120,22 +3333,26 @@ END &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif'); - my $html=&Apache::lonxml::xmlbegin(); + 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], + 'only_body' => 1, + 'add_entries' => \%onload}); + my $end_page = &Apache::loncommon::end_page(); $r->print (< -New posts marked as read - - - - +$start_page $textline -
      Continue - - +
      +$end_page ENDREDIR return OK; } elsif ($env{'form.modifydisp'}) { @@ -3179,7 +3396,7 @@ ENDREDIR my $previous=$env{'form.previous'}; if ($env{'form.markondisp'}) { $previous=undef; } &redirect_back($r,$feedurl,&mt('Changed display status').'
      ', - '0','0','','',$previous); + '0','0','','',$previous,'','','','','','',$group); return OK; } elsif (($env{'form.hide'}) || ($env{'form.unhide'})) { # ----------------------------------------------------------------- Hide/unhide @@ -3187,6 +3404,19 @@ ENDREDIR my ($symb,$idx)=split(/\:\:\:/,$entry); ($symb,my $feedurl)=&get_feedurl_and_clean_symb($symb); + my $crs='/'.$env{'request.course.id'}; + if ($env{'request.course.sec'}) { + $crs.='_'.$env{'request.course.sec'}; + } + $crs=~s/\_/\//g; + my $seeid=&Apache::lonnet::allowed('rin',$crs); + + if ($env{'form.hide'} && !$seeid && !(&editing_allowed($env{'form.hide'},$env{'form.group'}))) { + &redirect_back($r,$feedurl,&mt('Deletion not permitted').'
      ', '0','0','','',$env{'form.previous'},'','','','', + undef,undef,$group,); + return OK; + } + my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'}, $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}); @@ -3194,13 +3424,6 @@ ENDREDIR my $currenthidden=$contrib{'hidden'}; my $currentstudenthidden=$contrib{'studenthidden'}; - my $crs='/'.$env{'request.course.id'}; - if ($env{'request.course.sec'}) { - $crs.='_'.$env{'request.course.sec'}; - } - $crs=~s/\_/\//g; - my $seeid=&Apache::lonnet::allowed('rin',$crs); - if ($env{'form.hide'}) { $currenthidden.='.'.$idx.'.'; unless ($seeid) { @@ -3219,7 +3442,8 @@ ENDREDIR $env{'course.'.$env{'request.course.id'}.'.num'}); &redirect_back($r,$feedurl,&mt('Changed discussion status').'
      ', - '0','0','','',$env{'form.previous'}); + '0','0','','',$env{'form.previous'},undef,undef,undef, + undef,undef,undef,$group); return OK; } elsif ($env{'form.cmd'}=~/^(threadedoff|threadedon)$/) { my ($symb,$feedurl)=&get_feedurl_and_clean_symb($env{'form.symb'}); @@ -3231,7 +3455,8 @@ ENDREDIR &Apache::lonnet::delenv('environment\.threadeddiscussion'); } &redirect_back($r,$feedurl,&mt('Changed discussion view mode').'
      ', - '0','0','','',$env{'form.previous'}); + '0','0','','',$env{'form.previous'},undef,undef,undef, + undef,undef,undef,$group); return OK; } elsif ($env{'form.deldisc'}) { # --------------------------------------------------------------- Hide for good @@ -3245,7 +3470,8 @@ ENDREDIR $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}); &redirect_back($r,$feedurl,&mt('Changed discussion status').'
      ', - '0','0','','',$env{'form.previous'}); + '0','0','','',$env{'form.previous'},undef,undef,undef, + undef,undef,undef,$group); return OK; } elsif ($env{'form.preview'}) { # -------------------------------------------------------- User wants a preview @@ -3255,7 +3481,7 @@ ENDREDIR # -------------------------------------------------------- Work on attachments &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','addnewattach','delnewattach','timestamp','numoldver','idx','anondiscuss','discuss','blog']); + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','addnewattach','delnewattach','timestamp','numoldver','idx','discuss','blog']); my (@currnewattach,@currdelold,@keepold); &process_attachments(\@currnewattach,\@currdelold,\@keepold); if (exists($env{'form.addnewattach.filename'})) { @@ -3289,8 +3515,11 @@ ENDREDIR $status=$Apache::inputtags::status[-1]; } my $discussion = &list_discussion($mode,$status,$symb); - my $bodytag=&Apache::loncommon::bodytag('Resource Feedback and Discussion'); - $r->print($bodytag.$discussion); + my $start_page = + &Apache::loncommon::start_page('Resource Feedback and Discussion'); + my $end_page = + &Apache::loncommon::end_page(); + $r->print($start_page.$discussion.$end_page); return OK; } else { # ------------------------------------------------------------- Normal feedback @@ -3347,6 +3576,7 @@ ENDREDIR $r->send_http_header; # Unable to give feedback &no_redirect_back($r,$feedurl); + return OK; } # --------------------------------------------------- Print login screen header unless ($env{'form.sendit'}) { @@ -3410,15 +3640,18 @@ ENDREDIR my ($typestyle,%to) = &decide_receiver($feedurl); # Actually send mail - my ($status,$numsent)=&send_msg($feedurl,$email,$citations, + my ($status,$numsent)=&send_msg(&clear_out_html($env{'form.subject'}, + undef,1), + $feedurl,$email,$citations, $attachmenturl,%to); # Discussion? Store that. - my $numpost=0; - if ($env{'form.discuss'} || $env{'form.anondiscuss'}) { - my $subject = &clear_out_html($env{'form.subject'}); - my $anonmode=(defined($env{'form.anondiscuss'})); + if ( ($env{'form.discuss'} ne '' + && $env{'form.discuss'} !~ /^(?:author|question|course|policy)/) + || $env{'form.anondiscuss'} ne '') { + my $subject = &clear_out_html($env{'form.subject'},undef,1); + my $anonmode=($env{'form.discuss'} eq 'anon' || $env{'form.anondiscuss'} ); $typestyle.=&adddiscuss($symb,$message,$anonmode,$attachmenturl, $subject); $numpost++; @@ -3428,7 +3661,7 @@ ENDREDIR my $blog=''; if ($env{'form.blog'}) { - my $subject = &clear_out_html($env{'form.subject'}); + my $subject = &clear_out_html($env{'form.subject'},undef,1); $status.=&Apache::lonrss::addentry($env{'user.name'}, $env{'user.domain'}, 'CourseBlog_'.$env{'request.course.id'}, @@ -3437,7 +3670,7 @@ ENDREDIR } # Receipt screen and redirect back to where came from - &redirect_back($r,$feedurl,$typestyle,$numsent,$numpost,$blog,$status,$env{'form.previous'}); + &redirect_back($r,$feedurl,$typestyle,$numsent,$numpost,$blog,$status,$env{'form.previous'},undef,undef,undef,undef,undef,undef,$group); } return OK; } @@ -3476,5 +3709,73 @@ sub get_feedurl_and_clean_symb { my $feedurl = &get_feedurl($symb); return ($symb,$feedurl); } + +sub editing_allowed { + my ($postid,$group) = @_; + $postid = &unescape($postid); + my $can_edit = 0; + if ($group ne '') { + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + if ($postid =~ m|^bulletin___\d+___adm/wrapper(/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard)|) { + if (&check_group_priv($group,'egp') eq 'ok') { + $can_edit = 1; + } + return $can_edit; + } + } + my $cid = $env{'request.course.id'}; + my $role = (split(/\./,$env{'request.role'}))[0]; + my $section = $env{'request.course.sec'}; + my $allow_editing_config = + $env{'course.'.$cid.'.allow_discussion_post_editing'}; + if ($allow_editing_config =~ m/^\s*yes\s*$/i) { + $can_edit = 1; + } else { + foreach my $editor (split(/,/,$allow_editing_config)) { + my ($editor_role,$editor_sec) = split(/:/,$editor); + if ($editor_role eq $role + && defined($editor_sec) + && defined($section) + && $editor_sec eq $section) { + $can_edit = 1; + last; + } + if ($editor_role eq $role + && !defined($editor_sec)) { + $can_edit = 1; + } + } + } + return $can_edit; +} + +sub check_group_priv { + my ($group,$grp_priv) = @_; + foreach my $priv ('mdg','vcg') { + my $checkcourse = $env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''); + if (&Apache::lonnet::allowed($priv,$checkcourse)) { + return 'ok'; + } + } + if ($grp_priv && $group ne '') { + if (&Apache::lonnet::allowed($grp_priv,$env{'request.course.id'}.'/'.$group)) { + return 'ok'; + } + } + return ''; +} + +sub group_args { + my ($group) = @_; + if ($group eq '') { return ''; } + my $extra_args = '&group='.$group; + if (exists($env{'form.ref'})) { + $extra_args .= '&ref='.$env{'form.ref'}; + } + return $extra_args; +} + 1; __END__