--- loncom/interface/lonfeedback.pm 2005/04/11 01:07:26 1.159 +++ loncom/interface/lonfeedback.pm 2005/06/06 02:16:09 1.165 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.159 2005/04/11 01:07:26 raeburn Exp $ +# $Id: lonfeedback.pm,v 1.165 2005/06/06 02:16:09 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1205,7 +1205,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}); @@ -1375,7 +1375,7 @@ END &get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver); $message = $msgversions{$numoldver}; } - $message=~s/\n/\
/g; + &newline_to_br(\$message); $quote='
'.&Apache::lontexconvert::msgtexconverted($message).'
'; if ($idx > 0) { my %subversions = (); @@ -2375,17 +2375,48 @@ sub secapply { return ''; } +=pod + +=over 4 + +=item * + +decide_receiver($feedurl,$author,$question,$course,$policy,$defaultflag); + +Arguments + $feedurl - /res/ url of resource (only need if $author is true) + $author,$question,$course,$policy - all true/false parameters + if true will attempt to find the addresses of user that should receive + this type of feedback (author - feedback to author of resource $feedurl, + $question 'Resource Content Questions', $course 'Course Content Question', + $policy 'Course Policy') + (Additionally it also checks $env for whether the corresponding form. + element exists, for ease of use in a html response context) + + $defaultflag - (internal should be left blank) if true gather addresses + that aren't for a section even if I have a section + (used for reccursion internally, first we look for + addresses for our specific section then we recurse + and look for non section addresses) + +Returns + $typestyle - string of html text, describing what addresses were found + %to - a hash, which keys are addresses of users to send messages to + the keys will look like name:domain + +=cut + sub decide_receiver { my ($feedurl,$author,$question,$course,$policy,$defaultflag) = @_; my $typestyle=''; my %to=(); if ($env{'form.author'}||$author) { - $typestyle.='Submitting as Author Feedback
'; + $typestyle.='Submitting as Author Feedback
'; $feedurl=~/^\/res\/(\w+)\/(\w+)\//; $to{$2.':'.$1}=1; } if ($env{'form.question'}||$question) { - $typestyle.='Submitting as Question
'; + $typestyle.='Submitting as Question
'; foreach (split(/\,/, $env{'course.'.$env{'request.course.id'}.'.question.email'}) ) { @@ -2572,7 +2603,7 @@ sub show_preview { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; my $message=&clear_out_html($env{'form.comment'}); - $message=~s/\n/\
/g; + &newline_to_br(\$message); $message=&Apache::lonspeller::markeduptext($message); $message=&Apache::lontexconvert::msgtexconverted($message); my $subject=&clear_out_html($env{'form.subject'}); @@ -2585,6 +2616,28 @@ sub show_preview { $message.''); } + +sub newline_to_br { + my ($message)=@_; + my $newmessage; + my $parser=HTML::LCParser->new($message); + while (my $token=$parser->get_token()) { + if ($token->[0] eq 'T') { + my $text=$token->[1]; + $text=~s/\n/\
/g; + $newmessage.=$text; + } elsif ($token->[0] eq 'D' || $token->[0] eq 'C') { + $newmessage.=$token->[1]; + } elsif ($token->[0] eq 'PI' || $token->[0] eq 'E') { + $newmessage.=$token->[2]; + } elsif ($token->[0] eq 'S') { + $newmessage.=$token->[4]; + } + + } + $$message=$newmessage; +} + sub generate_preview_button { my $pre=&mt("Show Preview and Check Spelling"); return(< - + ENDATTACH if (defined($deloldattach)) { @@ -2866,12 +2919,7 @@ sub has_discussion { my @allres=$navmap->retrieveResources(); foreach my $resource (@allres) { if ($resource->hasDiscussion()) { - my $ressymb = $resource->symb(); - if ($resource->symb() =~ m-(___adm/\w+/\w+/)(\d+)(/bulletinboard)$-) { - $ressymb = 'bulletin___'.$2.$1.$2.$3; - } else { - $ressymb = $resource->symb(); - } + my $ressymb = $resource->wrap_symb(); push @{$resourcesref}, $ressymb; } } @@ -3032,10 +3080,6 @@ END foreach (@resources) { my $ressymb=$_; &Apache::lonenc::check_decrypt(\$ressymb); -# backward compatibility (bulletin boards used to be 'wrapped') - if ($ressymb =~ m/bulletin___\d+___/) { - $ressymb = &wrap_symb($ressymb); - } my $lastkey = $ressymb.'_lastread'; $discinfo{$lastkey} = $env{'form.navtime'}; }