--- loncom/interface/lonfeedback.pm 2004/09/15 06:17:11 1.126 +++ loncom/interface/lonfeedback.pm 2005/03/01 03:21:04 1.155 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.126 2004/09/15 06:17:11 albertel Exp $ +# $Id: lonfeedback.pm,v 1.155 2005/03/01 03:21:04 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,6 +36,8 @@ use Apache::loncommon(); use Apache::lontexconvert(); use Apache::lonlocal; # must not have () use Apache::lonhtmlcommon(); +use Apache::lonnavmaps; +use Apache::lonenc(); use HTML::LCParser(); use Apache::lonspeller(); use Cwd; @@ -66,13 +68,18 @@ sub discussion_visible { } sub list_discussion { - my ($mode,$status,$symb)=@_; + my ($mode,$status,$ressymb,$imsextras)=@_; my $outputtarget=$ENV{'form.grade_target'}; if (defined($ENV{'form.export'})) { if($ENV{'form.export'}) { $outputtarget = 'export'; } - } + } + if (defined($imsextras)) { + if ($$imsextras{'caller'} eq 'imsexport') { + $outputtarget = 'export'; + } + } if (not &discussion_visible($status)) { return ''; } my @bgcols = ("#cccccc","#eeeeee"); my $discussiononly=0; @@ -82,22 +89,18 @@ sub list_discussion { my $cid=$ENV{'request.course.id'}; if ($ENV{'request.course.sec'}) { $crs.='_'.$ENV{'request.course.sec'}; - } - $crs=~s/\_/\//g; - unless ($symb) { - $symb=&Apache::lonnet::symbread(); } - unless ($symb) { return ''; } + $crs=~s/\_/\//g; + unless ($ressymb) { $ressymb=&Apache::lonnet::symbread(); } + unless ($ressymb) { return ''; } + $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)$/)); + my %usernamesort = (); my %namesort =(); my %subjectsort = (); -# backward compatibility (bulletin boards used to be 'wrapped') - my $ressymb=$symb; - if ($mode eq 'board') { - unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) { - $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|; - } - } # Get discussion display settings for this discussion my $lastkey = $ressymb.'_lastread'; @@ -108,7 +111,7 @@ sub list_discussion { my $userpickkey = $ressymb.'_userpick'; 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 %discinfo = (); my $showonlyunread = 0; @@ -123,9 +126,19 @@ sub list_discussion { # 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 $rolefilter = $ENV{'form.rolefilter'}; my $statusfilter = $ENV{'form.statusfilter'}; - my $sectionpick = $ENV{'form.sectionpick'}; + 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'}; if ($previous > 0) { @@ -139,17 +152,22 @@ sub list_discussion { # Get information about students and non-students in course for filtering display of posts my %roleshash = (); my %roleinfo = (); - if ($rolefilter) { + if ($ENV{'form.rolefilter'}) { %roleshash = &Apache::lonnet::dump('nohist_userroles',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},$ENV{'course.'.$ENV{'request.course.id'}.'.num'}); foreach (keys %roleshash) { my ($role,$uname,$udom,$sec) = split/:/,$_; + if ($role =~ /^cr/) { + $role = 'cr'; + } my ($end,$start) = split/:/,$roleshash{$_}; my $now = time; my $status = 'Active'; if (($now < $start) || ($end > 0 && $now > $end)) { $status = 'Expired'; } - push @{$roleinfo{$uname.':'.$udom}}, $role.':'.$sec.':'.$status; + if ($uname && $udom) { + push @{$roleinfo{$uname.':'.$udom}}, $role.':'.$sec.':'.$status; + } } my ($classlist) = &Apache::loncoursedata::get_classlist( $ENV{'request.course.id'}, @@ -202,8 +220,6 @@ sub list_discussion { $visit ++; my $seeid=&Apache::lonnet::allowed('rin',$crs); - my $viewgrades=(&Apache::lonnet::allowed('vgr',$crs) - && ($symb=~/\.(problem|exam|quiz|assess|survey|form)$/)); my @discussionitems=(); my %shown = (); my @posteridentity=(); @@ -229,7 +245,7 @@ sub list_discussion { $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,$ressymb,$target,$readkey,$showunmark,$showonlyunread,$totposters,$rolefilter,$sectionpick,$statusfilter,$toggkey,$outputtarget); + &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); my $discussion=''; my $manifestfile; @@ -314,15 +330,26 @@ sub list_discussion { } elsif ($outputtarget eq 'export') { # Create temporary directory if this is an export my $now = time; - $tempexport = $Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/ims_exports'; - if (!-e $tempexport) { - mkdir($tempexport,0700); - } - $tempexport .= '/'.$now; - if (!-e $tempexport) { - mkdir($tempexport,0700); + if ((defined($imsextras)) && ($$imsextras{'caller'} eq 'imsexport')) { + $tempexport = $$imsextras{'tempexport'}; + if (!-e $tempexport) { + mkdir($tempexport,0700); + } + $tempexport .= '/'.$$imsextras{'count'}; + if (!-e $tempexport) { + mkdir($tempexport,0700); + } + } else { + $tempexport = $Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/ims_exports'; + if (!-e $tempexport) { + mkdir($tempexport,0700); + } + $tempexport .= '/'.$now; + 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); } @@ -359,22 +386,22 @@ imscp_v1p1.xsd http://www.imsglobal.org/ } |; - $discussion.='
'; + $discussion.='
'; $discussion .=' END + if ($sortposts) { + my %sort_types = (); + my %role_types = (); + my %status_types = (); + &sort_filter_names(\%sort_types,\%role_types,\%status_types); + + $discussion .= ''; + } + } if ($dischash{$toggkey}) { my $storebutton = &mt('Store read/unread changes'); $discussion.=' - - + - +
'. ''; if ($visible>2) { $discussion.=''; if ($newpostsflag) { if (!$markondisp) { - $discussion .=''; } @@ -402,7 +429,7 @@ imscp_v1p1.xsd http://www.imsglobal.org/ if ($numhidden > 0) { my $colspan = $maxdepth+1; $discussion.="\n".' -
'. - '  '. - '   -   '.&mt('Mark NEW posts no longer new').'  '; + $discussion .=''.&mt('Mark NEW posts no longer new').'  '; } else { $discussion .= ' 
'. - ' $b } keys %alldiscussion); } my $currdepth = 0; my $firstidx = $alldiscussion{$showposts[0]}; foreach (@showposts) { - unless (($sortposts eq 'thread') || ($sortposts eq 'ascdate' && $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) ) { @@ -486,8 +512,8 @@ imscp_v1p1.xsd http://www.imsglobal.org/ $imsitems{$alldiscussion{$_}}{'isvisible'}.'" identifieref="RES-'.$ressymb.'-'.$alldiscussion{$_}.'">'. ''.$imsitems{$alldiscussion{$_}}{'title'}.''; $imsresources .= "\n". - ''. - ''."\n". + ''."\n". + ''."\n". $imsfiles{$alldiscussion{$_}}{$imsitems{$alldiscussion{$_}}{'currversion'}}."\n". ''; } @@ -544,13 +570,54 @@ END $discussion .= <   + $lt{'chgt'}?
'.&mt('Sorted by').': '.$sort_types{$sortposts}.'
'; + if (defined($ENV{'form.totposters'})) { + $discussion .= &mt('Posts by').':'; + if ($totposters > 0) { + foreach my $poster (@posters) { + $poster =~ s/:/\@/; + $discussion .= ' '.$poster.','; + } + $discussion =~ s/,$//; + } else { + $discussion .= &mt('None selected'); + } + } else { + my $filterchoice =''; + if (@sectionpick > 0) { + $filterchoice = ''.&mt('sections').'- '.$ENV{'form.sectionpick'}; + $filterchoice .= '    '; + } + if (@rolefilter > 0) { + $filterchoice .= ''.&mt('roles').'-'; + foreach (@rolefilter) { + $filterchoice .= ' '.$role_types{$_}.','; + } + $filterchoice =~ s/,$//; + $filterchoice .= '
        '; + } + if ($statusfilter) { + $filterchoice .= ''.&mt('status').'- '.$status_types{$statusfilter}; + } + if ($filterchoice) { + $discussion .= ''.&mt('Filters').': '.$filterchoice; + } + $discussion .= '
'. @@ -583,27 +650,31 @@ END |; close($manifestfile); + if ((defined($imsextras)) && ($$imsextras{'caller'} eq 'imsexport')) { + $discussion = $copyresult; + } else { #Create zip file in prtspool - my $imszipfile = '/prtspool/'. - $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'. - time.'_'.rand(1000000000).'.zip'; + my $imszipfile = '/prtspool/'. + $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; + 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; + } } } else { $discussion .= '
Unfortunately you will not be able to retrieve an archive of the discussion posts at this time, because there was a problem creating a manifest file.
'; @@ -643,42 +714,42 @@ 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"; + 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"; } - $newattachmsg .= '
'."\n"; - } else { - $currnewattach[0] =~ m#.*/([^/]+)$#; - $newattachmsg .= ''.$1.'
'."\n"; } - } - $discussion.=$newattachmsg; - $discussion.=&generate_preview_button(); - } + $discussion.=$newattachmsg; + $discussion.=&generate_preview_button(); + } } - } else { - if (&discussion_open($status) && - &Apache::lonnet::allowed('pch', - $ENV{'request.course.id'}. - ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) { + } else { + if (&discussion_open($status) && + &Apache::lonnet::allowed('pch', + $ENV{'request.course.id'}. + ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) { if ($outputtarget ne 'tex') { $discussion.='
'. - ''. + $ressymb.':::" '.$target.'>'. + ''. &mt('Post Discussion').'
'; } } @@ -688,11 +759,10 @@ ENDDISCUSS sub build_posting_display { my ($usernamesort,$subjectsort,$namesort,$notshown,$newitem,$dischash,$shown,$alldiscussion,$imsitems,$imsfiles,$roleinfo,$discussionitems,$replies,$depth,$posters,$maxdepth,$visible,$newpostsflag,$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$ressymb,$target,$readkey,$showunmark,$showonlyunread,$totposters,$rolefilter,$sectionpick,$statusfilter,$toggkey,$outputtarget) = @_; - my @original=(); my @index=(); - - my %contrib=&Apache::lonnet::restore($ressymb,$ENV{'request.course.id'}, + my $symb=&Apache::lonenc::check_decrypt($ressymb); + my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'}, $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); @@ -701,6 +771,11 @@ sub build_posting_display { if ($prevread eq '0') { $prevread = $oldest-1; } + my ($skiptest,$rolematch,$roleregexp,$secregexp,$statusregexp); + if ($sortposts) { + ($skiptest,$roleregexp,$secregexp,$statusregexp) = &filter_regexp($rolefilter,$sectionpick,$statusfilter); + $rolematch = $roleregexp.':'.$secregexp.':'.$statusregexp; + } for (my $id=1;$id<=$contrib{'version'};$id++) { my $idx=$id; my $posttime = $contrib{$idx.':timestamp'}; @@ -713,7 +788,7 @@ sub build_posting_display { my $origindex='0.'; my $numoldver=0; if ($contrib{$idx.':replyto'}) { - if ( (($ENV{'environment.threadeddiscussion'}) && (($sortposts eq '') || ($sortposts eq 'ascdate'))) || ($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; @@ -899,16 +974,16 @@ sub build_posting_display { $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 'ascdate'))) || ($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; @@ -949,47 +1024,33 @@ sub build_posting_display { my $uname = $contrib{$idx.':sendername'}; my $udom = $contrib{$idx.':senderdomain'}; my $poster = $uname.':'.$udom; - my $rolematch = ''; - my $skiptest = 1; - if ($totposters > 0) { - if (grep/^$poster$/,@{$posters}) { - $$shown{$idx} = 1; - } - } else { - if ($rolefilter) { - if ($rolefilter eq 'all') { - $rolematch = '([^:]+)'; - } else { - $rolematch = $rolefilter; - $skiptest = 0; - } - } - if ($sectionpick) { - if ($sectionpick eq 'all') { - $rolematch .= ':([^:]*)'; - } else { - $rolematch .= ':'.$sectionpick; - $skiptest = 0; - } - } - if ($statusfilter) { - if ($statusfilter eq 'all') { - $rolematch .= ':([^:]+)'; - } else { - $rolematch .= ':'.$statusfilter; - $skiptest = 0; + if (defined($ENV{'form.totposters'})) { + if ($totposters == 0) { + $$shown{$idx} = 0; + } elsif ($totposters > 0) { + if (grep/^$poster$/,@{$posters}) { + $$shown{$idx} = 1; } } + } elsif ($sortposts) { if ($skiptest) { $$shown{$idx} = 1; } else { foreach my $role (@{$$roleinfo{$poster}}) { - if ($role =~ m/^$rolematch$/) { + if ($role =~ /^cc:/) { + my $cc_regexp = $roleregexp.':[^:]*:'.$statusregexp; + if ($role =~ /$cc_regexp/) { + $$shown{$idx} = 1; + last; + } + } elsif ($role =~ /^$rolematch$/) { $$shown{$idx} = 1; last; } } } + } else { + $$shown{$idx} = 1; } } unless ($$notshown{$idx} == 1) { @@ -1039,6 +1100,60 @@ sub build_posting_display { } } +sub filter_regexp { + my ($rolefilter,$sectionpick,$statusfilter) = @_; + my ($roleregexp,$secregexp,$statusregexp); + my $skiptest = 1; + if (@{$rolefilter} > 0) { + my @okrolefilter = (); + foreach (@{$rolefilter}) { + unless ($_ eq '') { + push @okrolefilter, $_; + } + } + if (@okrolefilter > 0) { + if (grep/^all$/,@okrolefilter) { + $roleregexp='[^:]+'; + } else { + if (@okrolefilter == 1) { + $roleregexp=$okrolefilter[0]; + } else { + $roleregexp='('.join('|',@okrolefilter).')'; + } + $skiptest = 0; + } + } + } + if (@{$sectionpick} > 0) { + my @oksectionpick = (); + foreach (@{$sectionpick}) { + unless ($_ eq '') { + push @oksectionpick, $_; + } + } + if ((@oksectionpick > 0) && (!grep/^all$/,@oksectionpick)) { + if (@oksectionpick == 1) { + $secregexp = $oksectionpick[0]; + } else { + $secregexp .= '('.join('|',@oksectionpick).')'; + } + $skiptest = 0; + } else { + $secregexp .= '[^:]*'; + } + } + if (defined($statusfilter) && $statusfilter ne '') { + if ($statusfilter eq 'all') { + $statusregexp = '[^:]+'; + } else { + $statusregexp = $statusfilter; + $skiptest = 0; + } + } + return ($skiptest,$roleregexp,$secregexp,$statusregexp); +} + + sub get_post_contents { my ($contrib,$idx,$seeid,$type,$messages,$subjects,$allattachments,$attachtxt,$imsfiles,$screenname,$plainname,$numver) = @_; my $discussion = ''; @@ -1321,8 +1436,9 @@ END my $latexHelp=&Apache::loncommon::helpLatexCheatsheet(); my $htmlheader=&Apache::lonhtmlcommon::htmlareaheaders(); my $send=&mt('Send'); + my $html=&Apache::lonxml::xmlbegin(); $r->print(< +$html The LearningOnline Network with CAPA @@ -1478,10 +1594,8 @@ END sub print_display_options { my ($r,$symb,$previous,$dispchgA,$dispchgB,$markchg,$toggchg,$feedurl) = @_; - # backward compatibility (bulletin boards used to be 'wrapped') - if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) { - $feedurl=~s|^/adm/wrapper||; - } + &Apache::loncommon::content_type($r,'text/html'); + $r->send_http_header; my $function = &Apache::loncommon::get_users_function(); my $tabcolor = &Apache::loncommon::designparm($function.'.tabbg', @@ -1548,8 +1662,9 @@ sub print_display_options { $currtogg = $lt{'toggon'}; $disctogg = 'toggon'; } + my $html=&Apache::lonxml::xmlbegin(); $r->print(< +$html $lt{'dido'} @@ -1640,18 +1755,18 @@ $lt{'sdpf'}
$lt{'prca'}
  1. $l
$lt{'disa'} $lt{$discdisp} $lt{'chgt'} "$dispchangeA" +
-  $lt{'chgt'} "$dispchangeB" +
$lt{'npmr'} $lt{$discmark}$lt{'chgt'} "$markchange"
$lt{'dotm'} $lt{$disctogg}$lt{'chgt'} "$toggchange"
@@ -1662,6 +1777,7 @@ $lt{'sdpf'}
$lt{'prca'}
  1. $l

    + @@ -1679,38 +1795,22 @@ END sub print_sortfilter_options { my ($r,$symb,$previous,$feedurl) = @_; - # backward compatibility (bulletin boards used to be 'wrapped') - if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) { - $feedurl=~s|^/adm/wrapper||; - } + + &Apache::loncommon::content_type($r,'text/html'); + $r->send_http_header; + + &Apache::lonenc::check_encrypt(\$symb); my @sections = (); my $section_sel = ''; my $numsections = 0; my $numvisible = 5; - 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 $sec_index = &Apache::loncoursedata::CL_SECTION(); - my $status_index = &Apache::loncoursedata::CL_STATUS(); my %sectioncount = (); - while (my ($student,$data) = each %$classlist) { - my ($section,$status) = ($data->[$sec_index], - $data->[$status_index]); - unless ($section eq '' || $section =~ /^\s*$/) { - if (!defined($sectioncount{$section})) { - $sectioncount{$section} = 1; - $numsections ++; - } else { - $sectioncount{$section} ++; - } - } - } - - if ($ENV{'request.course.sec'} !~ /^\s*$/) { - @sections = ($ENV{'request.course.sec'}); - $numvisible = 1; + + $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'}); + $numvisible = 2; } else { @sections = sort {$a cmp $b} keys(%sectioncount); unshift(@sections,'all'); # Put 'all' at the front of the list @@ -1732,19 +1832,49 @@ sub print_sortfilter_options { 'diop' => 'Display Options', 'curr' => 'Current setting ', 'actn' => 'Action', - 'prca' => 'Options can be set that control the sort order of the posts, in addition to which posts are displayed.', + 'prca' => 'Set options that control the sort order of posts, and/or which posts are displayed.', 'soor' => 'Sort order', - 'disp' => 'Specific user roles', - 'actv' => 'Specific role status', + 'spur' => 'Specific user roles', + 'sprs' => 'Specific role status', 'spse' => 'Specific sections', 'psub' => 'Pick specific users (by name)', 'shal' => 'Show a list of current posters' ); + + my %sort_types = (); + my %role_types = (); + my %status_types = (); + &sort_filter_names(\%sort_types,\%role_types,\%status_types); + my $html=&Apache::lonxml::xmlbegin(); $r->print(< +$html $lt{'diso'} + $bodytag
    @@ -1754,60 +1884,61 @@ $bodytag $lt{'soor'}   - $lt{'disp'} + $lt{'sprs'}   - $lt{'actv'} + $lt{'spur'}   $lt{'spse'}   $lt{'psub'} - +   - - +
    @@ -1818,24 +1949,18 @@ END sub print_showposters { my ($r,$symb,$previous,$feedurl,$sortposts) = @_; - # backward compatibility (bulletin boards used to be 'wrapped') - if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) { - $feedurl=~s|^/adm/wrapper||; - } -# backward compatibility (bulletin boards used to be 'wrapped') - my $ressymb=$symb; - if ($ressymb =~ /bulletin___\d+___/) { - unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) { - $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|; - } - } + + &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'}; } $crs=~s/\_/\//g; my $seeid=&Apache::lonnet::allowed('rin',$crs); - my %contrib=&Apache::lonnet::restore($ressymb,$ENV{'request.course.id'}, + 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 %namesort = (); @@ -1876,8 +2001,9 @@ sub print_showposters { } } } + my $html=&Apache::lonxml::xmlbegin(); $r->print(< +$html $lt{'diso'} @@ -1904,7 +2030,7 @@ END next; } else { $count ++; - $r->print(''.$count.''.$last.', '.$first.' ('.$uname.','.$udom.')'.$postcounts{$_}.''); + $r->print(''.$count.''.$postcounts{$_}.''); } } } @@ -1985,17 +2111,20 @@ sub get_post_attachments { return; } -sub fail_redirect {; +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 +$html + +Feedback not sent - + Sorry, no recipients ...
    Continue @@ -2004,7 +2133,7 @@ ENDFAILREDIR } sub redirect_back { - my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$status,$previous,$sort,$rolefilter,$statusfilter,$secpick,$numpicks) = @_; + my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$status,$previous,$sort,$rolefilter,$statusfilter,$sectionpick,$numpicks) = @_; my $sorttag = ''; my $roletag = ''; my $statustag = ''; @@ -2012,10 +2141,11 @@ sub redirect_back { my $userpicktag = ''; my $qrystr = ''; my $prevtag = ''; - # backward compatibility (bulletin boards used to be 'wrapped') - if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) { - $feedurl=~s|^/adm/wrapper||; - } + + &Apache::loncommon::content_type($r,'text/html'); + $r->send_http_header; + + &dewrapper(\$feedurl); if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' }; if ($previous > 0) { $qrystr = 'previous='.$previous; @@ -2034,29 +2164,55 @@ sub redirect_back { $feedurl .= '?'.$sortqry; } $sorttag = ''; - if ( (defined($numpicks)) && ($numpicks > 0) ) { + if (defined($numpicks)) { my $userpickqry = 'totposters='.$numpicks; $feedurl .= '&'.$userpickqry; $userpicktag = ''; } else { - my $roleqry = 'rolefilter='.$rolefilter; - $feedurl .= '&'.$roleqry; - $roletag = ''; + if (ref($sectionpick) eq 'ARRAY') { + $feedurl .= '§ionpick='; + $sectag .= ''; + } else { + $feedurl .= '§ionpick='.$sectionpick; + $sectag = ''; + } + if (ref($rolefilter) eq 'ARRAY') { + $feedurl .= '&rolefilter='; + $roletag .= ''; + } else { + $feedurl .= '&rolefilter='.$rolefilter; + $roletag = ''; + } $feedurl .= '&statusfilter='.$statusfilter; $statustag =''; - $feedurl .= '§ionpick='.$secpick; - $sectag = ''; } } + $feedurl=&Apache::lonenc::check_encrypt($feedurl); + my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif'); + my $html=&Apache::lonxml::xmlbegin(); $r->print (< +$html Feedback sent - + $typestyle Sent $sendsomething message(s), and $sendposts post(s). $status @@ -2078,20 +2234,24 @@ 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 +$html + +Feedback not sent ENDNOREDIR if ($feedurl!~/^\/adm\/feedback/) { - $r->print(''); + $r->print(''); } - + $feedurl=&Apache::lonenc::check_encrypt($feedurl); + my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif'); $r->print (< - + $nofeed
    $continue @@ -2100,47 +2260,49 @@ ENDNOREDIRTWO } sub screen_header { - my ($feedurl) = @_; + my ($feedurl,$symb) = @_; my $msgoptions=''; my $discussoptions=''; unless (($ENV{'form.replydisc'}) || ($ENV{'form.editdisc'})) { if (($feedurl=~/^\/res\//) && ($feedurl!~/^\/res\/adm/)) { $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 (&discussion_open() && + if (&discussion_open(undef,$symb) && &Apache::lonnet::allowed('pch', $ENV{'request.course.id'}. ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) { - $discussoptions=' '. &mt('Contribution to course discussion of resource'); - $discussoptions.='
    '. + $discussoptions.='
    '; + } } - if ($msgoptions) { $msgoptions='

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

    '.$msgoptions; } + if ($msgoptions) { $msgoptions='

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

    '.$msgoptions; } if ($discussoptions) { - $discussoptions='

    '.&mt('Discussion Contributions').'

    '.$discussoptions; } + $discussoptions='

    '.&mt('Discussion Contributions').'

    '.$discussoptions; } return $msgoptions.$discussoptions; } @@ -2171,7 +2333,7 @@ sub clear_out_html { # %html=(B=>1, I=>1, P=>1, A=>1, LI=>1, OL=>1, UL=>1, EM=>1, BR=>1, TT=>1, STRONG=>1, BLOCKQUOTE=>1, DIV=>1, IMG=>1, - M=>1, SUB=>1, SUP=>1, SPAN=>1, + M=>1, ALGEBRA=>1, SUB=>1, SUP=>1, SPAN=>1, H1=>1, H2=>1, H3=>1, H4=>1, H5=>1); } # Do the substitution of everything that is not explicitly allowed @@ -2185,8 +2347,6 @@ sub clear_out_html { sub assemble_email { my ($feedurl,$message,$prevattempts,$usersaw,$useranswer)=@_; my $email=<<"ENDEMAIL"; -Refers to $feedurl - $message ENDEMAIL my $citations=<<"ENDCITE"; @@ -2338,6 +2498,7 @@ sub adddiscuss { $contrib{'history'} = ''; my $numoldver = 0; my ($oldsymb,$oldidx)=split(/\:\:\:/,$ENV{'form.editdisc'}); + &Apache::lonenc::check_decrypt(\$oldsymb); $oldsymb=~s|(bulletin___\d+___)adm/wrapper/|$1|; # get timestamp for last post and history my %oldcontrib=&Apache::lonnet::restore($oldsymb,$ENV{'request.course.id'}, @@ -2413,6 +2574,8 @@ sub adddiscuss { sub show_preview { my $r=shift; + &Apache::loncommon::content_type($r,'text/html'); + $r->send_http_header; my $message=&clear_out_html($ENV{'form.comment'}); $message=~s/\n/\
    /g; $message=&Apache::lonspeller::markeduptext($message); @@ -2420,9 +2583,11 @@ sub show_preview { my $subject=&clear_out_html($ENV{'form.subject'}); $subject=~s/\n/\
    /g; $subject=&Apache::lontexconvert::msgtexconverted($subject); - $r->print('
    '. - 'Subject: '.$subject.'

    '. - $message.'
    '); + my $html=&Apache::lonxml::xmlbegin(); + $r->print($html.''. + '
    '. + 'Subject: '.$subject.'

    '. + $message.'
    '); } sub generate_preview_button { @@ -2453,8 +2618,10 @@ sub modify_attachments { if ($idx) { &extract_attachments($attachmenturls,$idx,$numoldver,\$msg,\%attachments,\%currattach,$currdelold); } + &Apache::lonenc::check_encrypt(\$symb); + my $html=&Apache::lonxml::xmlbegin(); $r->print(< +$html Managing Attachments