--- loncom/interface/lonfeedback.pm 2004/08/31 22:27:10 1.122 +++ loncom/interface/lonfeedback.pm 2004/11/14 07:54:41 1.132 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.122 2004/08/31 22:27:10 raeburn Exp $ +# $Id: lonfeedback.pm,v 1.132 2004/11/14 07:54:41 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; @@ -98,7 +100,7 @@ sub list_discussion { $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|; } } - + $ressymb=&Apache::lonenc::check_encrypt($ressymb); # Get discussion display settings for this discussion my $lastkey = $ressymb.'_lastread'; my $showkey = $ressymb.'_showonlyunread'; @@ -165,34 +167,39 @@ sub list_discussion { } # Get discussion display default settings for user - my %userenv = &Apache::lonnet::get('environment',['discdisplay','discmarkread'],$ENV{'user.domain'},$ENV{'user.name'}); - my $discdisplay=$userenv{'discdisplay'}; - if ($discdisplay eq 'unread') { + if ($ENV{'environment.discdisplay'} eq 'unread') { $showonlyunread = 1; } - my $discmarkread=$userenv{'discmarkread'}; - if ($discmarkread eq 'ondisp') { + if ($ENV{'environment.discmarkread'} eq 'ondisp') { $markondisp = 1; } # Override user's default if user specified display setting for this discussion if (defined($dischash{$ondispkey})) { - $markondisp = $dischash{$ondispkey}; + unless ($dischash{$ondispkey} eq '') { + $markondisp = $dischash{$ondispkey}; + } } if ($markondisp) { $discinfo{$lastkey} = time; } if (defined($dischash{$showkey})) { - $showonlyunread = $dischash{$showkey}; + unless ($dischash{$showkey} eq '') { + $showonlyunread = $dischash{$showkey}; + } } if (defined($dischash{$markkey})) { - $showunmark = $dischash{$markkey}; + unless ($dischash{$markkey} eq '') { + $showunmark = $dischash{$markkey}; + } } if (defined($dischash{$visitkey})) { - $visit = $dischash{$visitkey}; + unless ($dischash{$visitkey} eq '') { + $visit = $dischash{$visitkey}; + } } $visit ++; @@ -324,7 +331,6 @@ sub list_discussion { # open manifest file my $manifest = '/imsmanifest.xml'; my $manifestfilename = $tempexport.$manifest; - print STDERR "manifestfilename is $manifestfilename\n"; if ($manifestfile = Apache::File->new('>'.$manifestfilename)) { $manifestok=1; print $manifestfile qq| @@ -355,7 +361,7 @@ imscp_v1p1.xsd http://www.imsglobal.org/ } |; - $discussion.='
'; + $discussion.='
'; $discussion .='
'. ''; if ($visible>2) { @@ -474,7 +480,6 @@ imscp_v1p1.xsd http://www.imsglobal.org/ my $postfilename = $alldiscussion{$_}.'-'.$imsitems{$alldiscussion{$_}}{'timestamp'}.'.html'; if ($manifestok) { if (($depth[$alldiscussion{$_}] <= $currdepth) && ($alldiscussion{$_} != $firstidx)) { - print STDERR "depth is $depth[$alldiscussion{$_}], currdepth is $currdepth, idx is $alldiscussion{$_}, firstidx is $firstidx\n"; print $manifestfile ' '."\n"; } $currdepth = $depth[$alldiscussion{$_}]; @@ -600,7 +605,7 @@ END undef(%oldENV); $discussion .= 'Download the zip file from Discussion Posting Archive
'; if ($copyresult) { - $discussion .= 'The following errors occurred during export - '.$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.
'; @@ -618,8 +623,8 @@ END my $subject = ''; if ($ENV{'form.origpage'}) { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['addnewattach','deloldattach','delnewattach','timestamp','idx','subject','comment']); - $subject = &HTML::Entities::encode($ENV{'form.subject'},'<>&"'); - $comment = &HTML::Entities::encode($ENV{'form.comment'},'<>&"'); + $subject = &Apache::lonnet::unescape($ENV{'form.subject'}); + $comment = &Apache::lonnet::unescape($ENV{'form.comment'}); my @keepold = (); &process_attachments(\@currnewattach,\@currdelold,\@keepold); if (@currnewattach > 0) { @@ -674,7 +679,7 @@ ENDDISCUSS ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) { if ($outputtarget ne 'tex') { $discussion.='
'. + $ressymb.':::" '.$target.'>'. ''. &mt('Post Discussion').'
'; } @@ -1048,12 +1053,14 @@ sub get_post_contents { return $discussion; } } - $$screenname=&Apache::loncommon::screenname( - $$contrib{$idx.':sendername'}, - $$contrib{$idx.':senderdomain'}); - $$plainname=&Apache::loncommon::nickname( - $$contrib{$idx.':sendername'}, - $$contrib{$idx.':senderdomain'}); +# $$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'}); my $sender=&Apache::loncommon::aboutmewrapper( $$plainname, $$contrib{$idx.':sendername'}, @@ -1151,22 +1158,23 @@ sub replicate_attachments { $i ++; } my ($content,$rtncode); - print STDERR "File to replicate is $$attachrefs{$id}{'filename'} in $1,$2\n"; my $uploadreply = &Apache::lonnet::getuploaded('GET',$$attachrefs{$id}{'filename'},$1,$2,$content,$rtncode); if ($uploadreply eq 'ok') { - my $attachcopy; - if ($attachcopy = Apache::File->new('>'.$destination)) { - print $attachcopy $content; - close($attachcopy); - } else { - $response .= 'Error copying a file attachment to IMS package: '.$!.'
'."\n"; - } + my $attachcopy; + if ($attachcopy = Apache::File->new('>'.$destination)) { + print $attachcopy $content; + close($attachcopy); + } else { + $response .= 'Error copying file attachment - '.$5.' to IMS package: '.$!.'
'."\n"; + } } else { - print STDERR "return code from lonnet was $rtncode\n"; + &Apache::lonnet::logthis("Replication of attachment failed when building IMS export of discussion posts - domain: $1, course: $2, file: $$attachrefs{$id}{'filename'} -error: $rtncode"); + $response .= 'Error copying file attachment - '.$5.' to IMS package: '.$rtncode.'
'."\n"; } } } } + return $response; } sub mail_screen { @@ -1308,8 +1316,8 @@ END } if ($ENV{'form.origpage'}) { - $subject = $ENV{'form.subject'}; - $comment = $ENV{'form.comment'}; + $subject = &Apache::lonnet::unescape($ENV{'form.subject'}); + $comment = &Apache::lonnet::unescape($ENV{'form.comment'}); &process_attachments(\@currnewattach,\@currdelold,\@keepold); } my $latexHelp=&Apache::loncommon::helpLatexCheatsheet(); @@ -2042,6 +2050,7 @@ sub redirect_back { $sectag = ''; } } + $feedurl=&Apache::lonenc::check_encrypt($feedurl); $r->print (< @@ -2079,9 +2088,10 @@ sub no_redirect_back { ENDNOREDIR if ($feedurl!~/^\/adm\/feedback/) { - $r->print(''); + $r->print(''); } - + $feedurl=&Apache::lonenc::check_encrypt($feedurl); $r->print (< @@ -2179,8 +2189,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"; @@ -2332,6 +2340,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'}, @@ -2433,7 +2442,8 @@ ENDPREVIEW sub modify_attachments { my ($r,$currnewattach,$currdelold,$symb,$idx,$attachmenturls)=@_; - my $subject=&clear_out_html($ENV{'form.subject'}); + my $orig_subject = &Apache::lonnet::unescape($ENV{'form.subject'}); + my $subject=&clear_out_html($orig_subject); $subject=~s/\n/\
/g; $subject=&Apache::lontexconvert::msgtexconverted($subject); my $timestamp=$ENV{'form.timestamp'}; @@ -2462,7 +2472,7 @@ $bodytag
- Subject:$subject

+ Subject: $subject

END if ($idx) { if ($attachmenturls) { @@ -2569,7 +2579,7 @@ sub generate_attachments_button { my $response = (< Click to add/remove attachments: new(); + my @allres=$navmap->retrieveResources(); + foreach my $resource (@allres) { + if ($resource->hasDiscussion()) { + my $ressymb; + if ($resource->symb() =~ m-(___adm/\w+/\w+)/(\d+)/bulletinboard$-) { + $ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard'; + } else { + $ressymb = $resource->symb(); + } + push @{$resourcesref}, $ressymb; + } + } + return; +} sub handler { my $r = shift; @@ -2721,7 +2749,7 @@ 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','threadedon','threadedoff','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navmaps','navurl','sortfilter','sortposts','applysort','rolefilter','statusfilter','sectionpick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export']); + ['hide','unhide','deldisc','postdata','preview','replydisc','editdisc','threadedon','threadedoff','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navtime','navmaps','navurl','sortfilter','sortposts','applysort','rolefilter','statusfilter','sectionpick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export']); if ($ENV{'form.discsymb'}) { my $symb = $ENV{'form.discsymb'}; my $readkey = $symb.'_read'; @@ -2773,6 +2801,7 @@ END my $seeid=&Apache::lonnet::allowed('rin',$crs); my ($symb,$idx)=split(/\:\:\:/,$ENV{'form.allversions'}); my $ressymb=$symb; + &Apache::lonenc::check_decrypt(\$ressymb); unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) { $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|; } @@ -2814,6 +2843,7 @@ END my $previous=$ENV{'form.previous'}; # backward compatibility (bulletin boards used to be 'wrapped') my $ressymb=$symb; + &Apache::lonenc::check_decrypt(\$ressymb); unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) { $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|; } @@ -2868,13 +2898,17 @@ END } &print_sortfilter_options($r,$symb,$previous,$feedurl); return OK; - } elsif ($ENV{'form.navmaps'}) { + } elsif ($ENV{'form.navtime'}) { my %discinfo = (); my @resources = (); - if ($ENV{'form.navmaps'} =~ /:/) { - @resources = split/:/,$ENV{'form.navmaps'}; + if (defined($ENV{'form.navmaps'})) { + if ($ENV{'form.navmaps'} =~ /:/) { + @resources = split/:/,$ENV{'form.navmaps'}; + } else { + @resources = ("$ENV{'form.navmaps'}"); + } } else { - @resources = ("$ENV{'form.navmaps'}"); + &has_discussion(\@resources); } my $numitems = @resources; my $feedurl = '/adm/navmaps'; @@ -2883,20 +2917,27 @@ END } my %lt = &Apache::lonlocal::texthash( 'mnpa' => 'Marked "New" posts as read in a total of', - 'robb' => 'resources/bulletin boards.' + 'robb' => 'resources/bulletin boards.', + 'twnp' => 'There are currently no resources or bulletin boards with unread discussion postings.' ); foreach (@resources) { # backward compatibility (bulletin boards used to be 'wrapped') my $ressymb=$_; + &Apache::lonenc::check_decrypt(\$ressymb); if ($ressymb =~ m/bulletin___\d+___/) { unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) { $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper/|; } } my $lastkey = $ressymb.'_lastread'; - $discinfo{$lastkey} = time; + $discinfo{$lastkey} = $ENV{'form.navtime'}; + } + my $textline = "$lt{'mnpa'} $numitems $lt{'robb'}"; + if ($numitems > 0) { + &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'}); + } else { + $textline = "$lt{'twnp'}"; } - &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'}); &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; $r->print (< -$lt{'mnpa'} $numitems $lt{'robb'} +$textline
Continue @@ -2940,6 +2981,7 @@ ENDREDIR my $symb=$ENV{'form.toggoff'}?$ENV{'form.toggoff'}:$ENV{'form.toggon'}; my $ressymb = $symb; ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb); + &Apache::lonenc::check_decrypt(\$ressymb); unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) { $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|; } @@ -2957,6 +2999,7 @@ ENDREDIR my $symb=$ENV{'form.markondisp'}?$ENV{'form.markondisp'}:$ENV{'form.markonread'}; my $ressymb = $symb; ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb); + &Apache::lonenc::check_decrypt(\$ressymb); unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) { $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|; } @@ -2986,6 +3029,7 @@ ENDREDIR } my $ressymb = $symb; ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb); + &Apache::lonenc::check_decrypt(\$ressymb); unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) { $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|; } @@ -3013,6 +3057,7 @@ ENDREDIR my $symb=$ENV{'form.markread'}; my $ressymb = $symb; my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb); + &Apache::lonenc::check_decrypt(\$ressymb); unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) { $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|; } @@ -3195,6 +3240,7 @@ ENDREDIR $feedurl=&Apache::lonnet::clutter($url); } } + &Apache::lonenc::check_decrypt(\$symb); my $goahead=1; if ($feedurl=~/\.(problem|exam|quiz|assess|survey|form)$/) { unless ($symb) { $goahead=0; } @@ -3252,6 +3298,7 @@ ENDREDIR } elsif ($ENV{'form.origpage'}) { $symb = $ENV{'form.symb'}; } + &Apache::lonenc::check_decrypt(\$symb); my @currnewattach = (); my @deloldattach = (); my @keepold = ();