--- loncom/interface/lonfeedback.pm 2005/02/17 03:42:29 1.150 +++ loncom/interface/lonfeedback.pm 2006/07/18 17:42:15 1.211 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.150 2005/02/17 03:42:29 albertel Exp $ +# $Id: lonfeedback.pm,v 1.211 2006/07/18 17:42:15 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -35,15 +35,21 @@ use Apache::lonmsg(); use Apache::loncommon(); use Apache::lontexconvert(); use Apache::lonlocal; # must not have () +use Apache::lonnet; use Apache::lonhtmlcommon(); use Apache::lonnavmaps; 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)=@_; + if ($env{'request.role.adv'}) { return 1; } if (defined($status) && !($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER' || $status eq 'OPEN')) { @@ -61,17 +67,17 @@ sub discussion_visible { if (not &discussion_open($status)) { my $hidden=&Apache::lonnet::EXT('resource.0.discusshide'); if (lc($hidden) eq 'yes' or $hidden eq '' or !defined($hidden)) { - if (!$ENV{'request.role.adv'}) { return 0; } + if (!$env{'request.role.adv'}) { return 0; } } } return 1; } sub list_discussion { - my ($mode,$status,$ressymb,$imsextras)=@_; - my $outputtarget=$ENV{'form.grade_target'}; - if (defined($ENV{'form.export'})) { - if($ENV{'form.export'}) { + my ($mode,$status,$ressymb,$imsextras,$group)=@_; + my $outputtarget=$env{'form.grade_target'}; + if (defined($env{'form.export'})) { + if($env{'form.export'}) { $outputtarget = 'export'; } } @@ -81,14 +87,19 @@ 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; } - unless ($ENV{'request.course.id'}) { return ''; } - my $crs='/'.$ENV{'request.course.id'}; - my $cid=$ENV{'request.course.id'}; - if ($ENV{'request.course.sec'}) { - $crs.='_'.$ENV{'request.course.sec'}; + unless ($env{'request.course.id'}) { return ''; } + my $crs='/'.$env{'request.course.id'}; + my $cid=$env{'request.course.id'}; + if ($env{'request.course.sec'}) { + $crs.='_'.$env{'request.course.sec'}; } $crs=~s/\_/\//g; unless ($ressymb) { $ressymb=&Apache::lonnet::symbread(); } @@ -96,7 +107,7 @@ sub list_discussion { $ressymb=&wrap_symb($ressymb); my $encsymb=&Apache::lonenc::check_encrypt($ressymb); my $viewgrades=(&Apache::lonnet::allowed('vgr',$crs) - && ($ressymb=~/\.(problem|exam|quiz|assess|survey|form)$/)); + && ($ressymb=~/\.(problem|exam|quiz|assess|survey|form|task)$/)); my %usernamesort = (); my %namesort =(); @@ -112,7 +123,7 @@ sub list_discussion { my $toggkey = $ressymb.'_readtoggle'; my $readkey = $ressymb.'_read'; $ressymb=$encsymb; - my %dischash = &Apache::lonnet::get('nohist_'.$ENV{'request.course.id'}.'_discuss',[$lastkey,$showkey,$markkey,$visitkey,$ondispkey,$userpickkey,$toggkey,$readkey],$ENV{'user.domain'},$ENV{'user.name'}); + my %dischash = &Apache::lonnet::get('nohist_'.$cid.'_discuss',[$lastkey,$showkey,$markkey,$visitkey,$ondispkey,$userpickkey,$toggkey,$readkey],$env{'user.domain'},$env{'user.name'}); my %discinfo = (); my $showonlyunread = 0; my $showunmark = 0; @@ -124,23 +135,15 @@ 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']); - 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 $totposters = $ENV{'form.totposters'}; - $previous = $ENV{'form.previous'}; + &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 = 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) { $prevread = $previous; } elsif (defined($dischash{$lastkey})) { @@ -149,11 +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 = (); - if ($ENV{'form.rolefilter'}) { - %roleshash = &Apache::lonnet::dump('nohist_userroles',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},$ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + my ($classgroups,$studentgroups); + if ($env{'form.rolefilter'}) { + %roleshash = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum); foreach (keys %roleshash) { my ($role,$uname,$udom,$sec) = split/:/,$_; if ($role =~ /^cr/) { @@ -169,10 +176,8 @@ sub list_discussion { push @{$roleinfo{$uname.':'.$udom}}, $role.':'.$sec.':'.$status; } } - my ($classlist) = &Apache::loncoursedata::get_classlist( - $ENV{'request.course.id'}, - $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, - $ENV{'course.'.$ENV{'request.course.id'}.'.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) { @@ -180,13 +185,16 @@ 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 - if ($ENV{'environment.discdisplay'} eq 'unread') { + if ($env{'environment.discdisplay'} eq 'unread') { $showonlyunread = 1; } - if ($ENV{'environment.discmarkread'} eq 'ondisp') { + if ($env{'environment.discmarkread'} eq 'ondisp') { $markondisp = 1; } @@ -219,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=(); @@ -234,18 +250,19 @@ sub list_discussion { my %notshown = (); my %newitem = (); my $maxdepth=0; - + my %anonhash=(); + my $anoncnt=0; my $target=''; - unless ($ENV{'browser.interface'} eq 'textual' || - $ENV{'environment.remote'} eq 'off' ) { + unless ($env{'browser.interface'} eq 'textual' || + $env{'environment.remote'} eq 'off' ) { $target='target="LONcom"'; } my $now = time; $discinfo{$visitkey} = $visit; - &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_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); + &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,\@grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,\%anonhash,$anoncnt,$group); my $discussion=''; my $manifestfile; @@ -256,7 +273,7 @@ sub list_discussion { my $function = &Apache::loncommon::get_users_function(); my $color = &Apache::loncommon::designparm($function.'.tabbg', - $ENV{'user.domain'}); + $env{'user.domain'}); my %lt = &Apache::lonlocal::texthash( 'cuse' => 'Current discussion settings', 'allposts' => 'All posts', @@ -318,15 +335,16 @@ sub list_discussion { if ($newpostsflag) { $chglink .= '&previous='.$prevread; } + $chglink.=&group_args($group); if ($visible) { # Print the discusssion if ($outputtarget eq 'tex') { - $discussion.='\vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}'. + $discussion.='{\tiny \vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}'. '\textbf{DISCUSSIONS}\makebox[2 cm][b]{\hrulefill}'. '\vskip 0 mm\noindent\textbf{'.$lt{'cuse'}.'}:\vskip 0 mm'. '\noindent\textbf{'.$lt{'disa'}.'}: \textit{'.$currdisp.'}\vskip 0 mm'. - '\noindent\textbf{'.$lt{'npce'}.'}: \textit{'.$currmark.'}'; + '\noindent\textbf{'.$lt{'npce'}.'}: \textit{'.$currmark.'}}'; } elsif ($outputtarget eq 'export') { # Create temporary directory if this is an export my $now = time; @@ -348,7 +366,7 @@ sub list_discussion { if (!-e $tempexport) { mkdir($tempexport,0700); } - $tempexport .= '/'.$ENV{'user.domain'}.'_'.$ENV{'user.name'}; + $tempexport .= '/'.$env{'user.domain'}.'_'.$env{'user.name'}; } if (!-e $tempexport) { mkdir($tempexport,0700); @@ -389,34 +407,45 @@ imscp_v1p1.xsd http://www.imsglobal.org/ $discussion.='
'; $discussion .='
'. ''; + my $escsymb=&escape($ressymb); if ($visible>2) { $discussion.=''; if ($newpostsflag) { if (!$markondisp) { - $discussion .=''; } @@ -429,10 +458,11 @@ imscp_v1p1.xsd http://www.imsglobal.org/ if ($numhidden > 0) { my $colspan = $maxdepth+1; $discussion.="\n".' +END + $r->print(&Apache::loncommon::end_data_table_row()); + $r->print(&Apache::loncommon::end_data_table()); + $r->print(<
@@ -1782,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("

    - - -END +$end_page + "); return; } @@ -1798,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 = (); + my @groups; + my $group_sel = ''; + my $numgroupvis = 5; + my %sectioncount = &Apache::loncommon::get_sections(); - $numsections = &Apache::loncommon::get_sections($ENV{'course.'.$ENV{'request.course.id'}.'.domain'},$ENV{'course.'.$ENV{'request.course.id'}.'.num'},\%sectioncount); - - if ($ENV{'request.course.sec'} !~ /^\s*$/) { #Restrict section choice to current section - @sections = ('all',$ENV{'request.course.sec'}); + 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); - unshift(@sections,'all'); # Put 'all' at the front of the list - if ($numsections < 4) { - $numvisible = $numsections + 1; + if (scalar(@sections) < 4) { + $numvisible = scalar(@sections) + 1; } + unshift(@sections,'all'); # Put 'all' at the front of the list + } foreach (@sections) { $section_sel .= "
'. - '  '. - '   -   '; } else { $discussion .= ''; } - $discussion .=''.&mt('Export').'?  '.&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 .= '
 
'. - ' '.&mt('to display').' '. $numhidden.' '; if ($showunmark) { @@ -472,7 +502,7 @@ imscp_v1p1.xsd http://www.imsglobal.org/ my $currdepth = 0; my $firstidx = $alldiscussion{$showposts[0]}; foreach (@showposts) { - unless (($sortposts eq 'thread') || (($sortposts eq '') && ($ENV{'environment.threadeddiscussion'})) || ($outputtarget eq 'export')) { + unless (($sortposts eq 'thread') || (($sortposts eq '') && ($env{'environment.threadeddiscussion'})) || ($outputtarget eq 'export')) { $alldiscussion{$_} = $_; } unless ( ($notshown{$alldiscussion{$_}} eq '1') || ($shown{$alldiscussion{$_}} == 0) ) { @@ -584,7 +614,7 @@ END &sort_filter_names(\%sort_types,\%role_types,\%status_types); $discussion .= ''.&mt('Sorted by').': '.$sort_types{$sortposts}.'
'; - if (defined($ENV{'form.totposters'})) { + if (defined($env{'form.totposters'})) { $discussion .= &mt('Posts by').':'; if ($totposters > 0) { foreach my $poster (@posters) { @@ -598,7 +628,11 @@ END } else { my $filterchoice =''; if (@sectionpick > 0) { - $filterchoice = ''.&mt('sections').'- '.$ENV{'form.sectionpick'}; + $filterchoice = ''.&mt('sections').'- '.$env{'form.sectionpick'}; + $filterchoice .= '    '; + } + if (@grouppick > 0) { + $filterchoice = ''.&mt('groups').'- '.$env{'form.grouppick'}; $filterchoice .= '    '; } if (@rolefilter > 0) { @@ -657,20 +691,14 @@ END #Create zip file in prtspool my $imszipfile = '/prtspool/'. - $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'. + $env{'user.name'}.'_'.$env{'user.domain'}.'_'. time.'_'.rand(1000000000).'.zip'; - # zip can cause an sh launch which can pass along all of %ENV - # which can be too large for /bin/sh to handle - my %oldENV=%ENV; - undef(%ENV); my $cwd = &getcwd(); my $imszip = '/home/httpd/'.$imszipfile; chdir $tempexport; open(OUTPUT, "zip -r $imszip * 2> /dev/null |"); close(OUTPUT); chdir $cwd; - %ENV=%oldENV; - undef(%oldENV); $discussion .= 'Download the zip file from Discussion Posting Archive
'; if ($copyresult) { $discussion .= 'The following errors occurred during export -
'.$copyresult; @@ -685,87 +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'}) { + 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.='
'; if (&discussion_open($status) && &Apache::lonnet::allowed('pch', - $ENV{'request.course.id'}. - ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) { + $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) = @_; + 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 %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'}, - $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, - $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + 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') { @@ -773,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++) { @@ -788,7 +856,7 @@ sub build_posting_display { my $origindex='0.'; my $numoldver=0; if ($contrib{$idx.':replyto'}) { - if ( (($ENV{'environment.threadeddiscussion'}) && ($sortposts eq '')) || ($sortposts eq 'thread') || ($outputtarget eq 'export')) { + if ( (($env{'environment.threadeddiscussion'}) && ($sortposts eq '')) || ($sortposts eq 'thread') || ($outputtarget eq 'export')) { # this is a follow-up message $original[$idx]=$original[$contrib{$idx.':replyto'}]; $$depth[$idx]=$$depth[$contrib{$idx.':replyto'}]+1; @@ -825,6 +893,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); @@ -855,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'}, @@ -863,7 +938,7 @@ sub build_posting_display { $contrib{$idx.':sendername'}.' at '. $contrib{$idx.':senderdomain'}.')'; if ($contrib{$idx.':anonymous'}) { - $sender.=' ['.&mt('anonymous').'] '. + $sender.=' ['.$$anonhash{$key}.'] '. $screenname; } @@ -896,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 (($ENV{'user.domain'} eq $contrib{$idx.':senderdomain'}) && ($ENV{'user.name'} eq $contrib{$idx.':sendername'})) { + 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.=" '; } } @@ -914,30 +991,34 @@ sub build_posting_display { if ($hidden) { unless ($studenthidden) { $sender.=' '.&mt('Make Visible').''; } } else { $sender.=' '.&mt('Hide').''; } $sender.=' '.&mt('Delete').''; } } else { if ($screenname) { $sender=''.$screenname.''; + } else { + $sender=''.$$anonhash{$key}.''; } # Set up for sorting by domain, then username for anonymous unless (defined($$usernamesort{'__anon'})) { @@ -958,32 +1039,43 @@ 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', $contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$ressymb); } if ($$dischash{$readkey}=~/\.$idx\./) { - $ctlink = ''.&mt('Mark unread').'? '; + $ctlink = ''; } else { - $ctlink = ''.&mt('Mark read').'? '; + $ctlink = ''; } } #figure out at what position this needs to print } if ($outputtarget eq 'export' || $message) { my $thisindex=$idx; - if ( (($ENV{'environment.threadeddiscussion'}) && ($sortposts eq '')) || ($sortposts eq 'thread') || ($outputtarget eq 'export')) { + if ( (($env{'environment.threadeddiscussion'}) && ($sortposts eq '')) || ($sortposts eq 'thread') || ($outputtarget eq 'export')) { $thisindex=$origindex.substr('00'.$$replies[$$depth[$idx]],-2,2); } $$alldiscussion{$thisindex}=$idx; @@ -1024,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) { @@ -1049,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; } @@ -1079,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/:/) { @@ -1142,6 +1253,7 @@ sub filter_regexp { $secregexp .= '[^:]*'; } } + if (defined($statusfilter) && $statusfilter ne '') { if ($statusfilter eq 'all') { $statusregexp = '[^:]+'; @@ -1162,18 +1274,18 @@ 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; } } # $$screenname=&Apache::loncommon::screenname( # $$contrib{$idx.':sendername'}, # $$contrib{$idx.':senderdomain'}); -# $$plainname=&Apache::loncommon::nickname( -# $$contrib{$idx.':sendername'}, -# $$contrib{$idx.':senderdomain'}); - ($$screenname,$$plainname)=($$contrib{$idx.':screenname'}, - $$contrib{$idx.':plainname'}); + $$plainname=&Apache::loncommon::nickname( + $$contrib{$idx.':sendername'}, + $$contrib{$idx.':senderdomain'}); + $$screenname=$$contrib{$idx.':screenname'}; + my $sender=&Apache::loncommon::aboutmewrapper( $$plainname, $$contrib{$idx.':sendername'}, @@ -1185,11 +1297,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); @@ -1210,7 +1318,7 @@ sub get_post_contents { my ($timesent,$attachmsg); my %currattach = (); $timesent = &Apache::lonlocal::locallocaltime($postversions[$i]); - $$messages{$i}=~s/\n/\
/g; + &newline_to_br(\$messages->{$i}); $$messages{$i}=&Apache::lontexconvert::msgtexconverted($$messages{$i}); $$subjects{$i}=~s/\n/\
/g; $$subjects{$i}=&Apache::lontexconvert::msgtexconverted($$subjects{$i}); @@ -1245,7 +1353,7 @@ END } } if ($type eq 'allversions') { - $discussion.=(''); + $discussion.=''; return $discussion; } else { return; @@ -1292,11 +1400,10 @@ 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']); + if (exists($env{'form.origpage'})) { + &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=''; @@ -1316,26 +1423,31 @@ sub mail_screen { my $attachnum = 0; my $anonchk = (</g; + &newline_to_br(\$message); $quote='
'.&Apache::lontexconvert::msgtexconverted($message).'
'; if ($idx > 0) { my %subversions = (); @@ -1401,21 +1513,18 @@ END if (defined($contrib{$idx.':replyto'})) { $parentmsg = $contrib{$idx.':replyto'}; } - unless (exists($ENV{'form.origpage'})) { - my $anonflag = 0; + unless (exists($env{'form.origpage'})) { + my $anonflag = 'nonanon'; if ($contrib{$idx.':anonymous'}) { - $anonflag = 1; + $anonflag = 'anon'; } $anonscript = (<'; + if ($env{'form.previous'}) { + $prevtag = ''; } } - if ($ENV{'form.origpage'}) { - $subject = &Apache::lonnet::unescape($ENV{'form.subject'}); - $comment = &Apache::lonnet::unescape($ENV{'form.comment'}); + if ($env{'form.origpage'}) { + $subject = &unescape($env{'form.subject'}); + $comment = &unescape($env{'form.comment'}); &process_attachments(\@currnewattach,\@currdelold,\@keepold); } my $latexHelp=&Apache::loncommon::helpLatexCheatsheet(); - my $htmlheader=&Apache::lonhtmlcommon::htmlareaheaders(); my $send=&mt('Send'); - $r->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
$prevtag END - if ($ENV{'form.replydisc'}) { + if ($env{'form.replydisc'}) { $r->print(< + END - } elsif ($ENV{'form.editdisc'}) { + } elsif ($env{'form.editdisc'}) { $r->print(< + END } @@ -1521,8 +1619,8 @@ Title:

END - if ( ($ENV{'form.editdisc'}) || ($ENV{'form.replydisc'}) ) { - if ($ENV{'form.origpage'}) { + if ( ($env{'form.editdisc'}) || ($env{'form.replydisc'}) ) { + if ($env{'form.origpage'}) { foreach (@currnewattach) { $r->print(''."\n"); } @@ -1530,7 +1628,7 @@ END $r->print(''."\n"); } } - if ($ENV{'form.editdisc'}) { + if ($env{'form.editdisc'}) { if ($attachmenturls) { &extract_attachments($attachmenturls,$idx,$numoldver,\$attachmsg,\%attachments,\%currattach,\@currdelold); $attachnum = scalar(keys %currattach); @@ -1545,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(< @@ -1552,11 +1656,11 @@ END

END - if ($ENV{'form.editdisc'} || $ENV{'form.replydisc'}) { + if ($env{'form.editdisc'} || $env{'form.replydisc'}) { my $now = time; my $ressymb = $symb; my $postidx = ''; - if ($ENV{'form.editdisc'}) { + if ($env{'form.editdisc'}) { $postidx = $idx; } if (@currnewattach > 0) { @@ -1565,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) { @@ -1588,7 +1692,8 @@ END } $r->print(&generate_preview_button(). &Apache::lonhtmlcommon::htmlareaselectactive('comment'). - ''); + &Apache::loncommon::end_page()); + } sub print_display_options { @@ -1598,12 +1703,9 @@ 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', - '',''); + $env{'user.domain'}); my %lt = &Apache::lonlocal::texthash( - 'dido' => 'Discussion display options', 'pref' => 'Display Preference', 'curr' => 'Current setting ', 'actn' => 'Action', @@ -1661,12 +1763,9 @@ sub print_display_options { $currtogg = $lt{'toggon'}; $disctogg = 'toggon'; } - $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{'chgt'} "$dispchangeA" +
    -  $lt{'chgt'} "$dispchangeB" +
    $lt{$discmark}$lt{'chgt'} "$markchange"
    $lt{$disctogg}$lt{'chgt'} "$toggchange"
    -
    -
    +
@@ -1888,10 +2040,12 @@ $bodytag + + - - - - - + + +
  $lt{'spse'}  $lt{'spgr'}  $lt{'psub'}
+   +   +   +  $lt{'shal'} + +  

@@ -1937,40 +2096,63 @@ $bodytag +END + if (exists($env{'form.group'})) { + $r->print(''); + } + if (exists($env{'form.ref'})) { + $r->print(''); + } + $r->print("

- - -END +$end_page +"); } sub print_showposters { my ($r,$symb,$previous,$feedurl,$sortposts) = @_; + &Apache::loncommon::content_type($r,'text/html'); + $r->send_http_header; + &Apache::lonenc::check_encrypt(\$symb); - my $crs='/'.$ENV{'request.course.id'}; - if ($ENV{'request.course.sec'}) { - $crs.='_'.$ENV{'request.course.sec'}; + 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 %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'}, - $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, - $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + 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'}, + $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'}; @@ -1996,23 +2178,19 @@ sub print_showposters { } } } + + 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; @@ -2024,23 +2202,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 } @@ -2048,7 +2228,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"); @@ -2109,34 +2290,29 @@ sub fail_redirect { my ($r,$feedurl) = @_; if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' }; my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif'); - $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,$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) { @@ -2175,6 +2351,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'); - $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). +$blog $status
$prevtag @@ -2213,38 +2422,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'); - $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 } @@ -2252,40 +2468,44 @@ sub screen_header { my ($feedurl,$symb) = @_; my $msgoptions=''; my $discussoptions=''; - unless (($ENV{'form.replydisc'}) || ($ENV{'form.editdisc'})) { - if (($feedurl=~/^\/res\//) && ($feedurl!~/^\/res\/adm/)) { + unless (($env{'form.replydisc'}) || ($env{'form.editdisc'})) { + if (($feedurl=~/^\/res\//) && ($feedurl!~/^\/res\/adm/) && ($env{'user.adv'})) { $msgoptions= - '

'. - &mt('Feedback to resource author').'

'; + '

'; } if (&feedback_available(1)) { $msgoptions.= - '
'. - &mt('Question about resource content'); + '

'; } if (&feedback_available(0,1)) { $msgoptions.= - '
'. - &mt('Question/Comment/Feedback about course content'); + '

'; } if (&feedback_available(0,0,1)) { $msgoptions.= - '
'. - &mt('Question/Comment/Feedback about course policy'); + '

'; } } - 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=' '. + $env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { + $discussoptions='
'. + ''.&mt('Change Screenname').''; } + $discussoptions.='
'; } if ($msgoptions) { $msgoptions='

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

'.$msgoptions; } if ($discussoptions) { @@ -2307,26 +2527,27 @@ 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 - my $cid=$ENV{'request.course.id'}; - if (($ENV{"course.$cid.allow_limited_html_in_feedback"} =~ m/yes/i) || + my $cid=$env{'request.course.id'}; + if (($env{"course.$cid.allow_limited_html_in_feedback"} =~ m/yes/i) || ($override)) { # allows