--- loncom/interface/lonfeedback.pm 2006/03/19 21:43:21 1.186 +++ loncom/interface/lonfeedback.pm 2006/04/23 03:50:54 1.194 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.186 2006/03/19 21:43:21 albertel Exp $ +# $Id: lonfeedback.pm,v 1.194 2006/04/23 03:50:54 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -744,17 +744,22 @@ ENDDISCUSS } } } 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.='
'. ''. - &mt('Post Discussion').'
'; - } + &mt('Post Discussion').'
'; + } } + $discussion.=''. + &mt('Send Message').'
'; } return $discussion; } @@ -1253,7 +1258,7 @@ END } } if ($type eq 'allversions') { - $discussion.=(''); + $discussion.=''; return $discussion; } else { return; @@ -1498,10 +1503,10 @@ END END - my $onload = 'onLoad="window.focus();setposttype();"'; + my %onload = ('onload' => 'window.focus();setposttype();'); my $start_page= &Apache::loncommon::start_page('Resource Feedback and Discussion',$js, - {'add_entries' => $onload}); + {'add_entries' => \%onload}); $r->print(< 'Discussion display options', 'pref' => 'Display Preference', 'curr' => 'Current setting ', 'actn' => 'Action', @@ -1675,13 +1677,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'}

@@ -1800,8 +1805,7 @@ $lt{'sdpf'}
$lt{'prca'}
  1. $l

    - - +$end_page END return; } @@ -1838,10 +1842,7 @@ sub print_sortfilter_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( - 'diso' => 'Discussion sorting and filtering options', 'diop' => 'Display Options', 'curr' => 'Current setting ', 'actn' => 'Action', @@ -1858,12 +1859,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 @@ -1888,9 +1885,16 @@ function verifyFilter() { document.modifyshown.submit(); } - -$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'}

@@ -1955,8 +1959,7 @@ $bodytag

- - +$end_page END } @@ -2129,7 +2132,6 @@ sub fail_redirect { $r->print(< Sorry, no recipients ... -
Continue ENDFAILREDIR $r->print(&Apache::loncommon::end_page()); } @@ -2205,12 +2207,12 @@ sub redirect_back { } $feedurl=&Apache::lonenc::check_encrypt($feedurl); my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif'); - my $onload = 'onLoad=\'if (window.name!="loncapaclient") { this.document.reldt.submit(); self.window.close(); }\''; + my %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}); + 'add_entries' => \%onload}); my $end_page = &Apache::loncommon::end_page(); $r->print(< -
Continue $end_page ENDREDIR } @@ -2236,29 +2237,28 @@ 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 %body_options = ('only_body' => 1, + 'bgcolor' => '#FFFFFF', + 'add_entries' => {'onload' => "if (window.name!='loncapaclient') { self.window.close(); }"}); + + 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 } @@ -2290,7 +2290,7 @@ sub screen_header { '

'; } } - 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'}. @@ -2326,8 +2326,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 @@ -2343,9 +2344,9 @@ sub clear_out_html { H1=>1, H2=>1, H3=>1, H4=>1, H5=>1); } # Do the substitution of everything that is not explicitly allowed - $message =~ s/\<(\/?\s*(\w+)[^\>\<]*)/ + $message =~ s/\<(\/?\s*(\w*)[^\>\<]*)/ {($html{uc($2)}&&(length($1)<1000))?"\<$1":"\<$1"}/ge; - $message =~ s/(\]*)\>/ + $message =~ s/(\]*)\>/ {($html{uc($2)}&&(length($1)<1000))?"$1\>":"$1\>"}/ge; return $message; } @@ -2607,21 +2608,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); } @@ -2664,13 +2669,12 @@ 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 $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 = (); @@ -2678,19 +2682,21 @@ 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(< @@ -2743,8 +2749,7 @@ END $r->print(< - - +$end_page END return; } @@ -2977,7 +2982,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','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','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export','sendmessageonly']); if ($env{'form.editdisc'}) { if (!(&editing_allowed())) { my $symb=(split(/\:\:\:/,$env{'form.editdisc'}))[0]; @@ -3015,17 +3020,11 @@ sub handler { } 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'}; @@ -3046,6 +3045,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'}) { @@ -3114,12 +3114,12 @@ END &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif'); - my $onload = 'onLoad=\'if (window.name!="loncapaclient") { this.document.reldt.submit(); self.window.close(); }\''; + my %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}); + 'add_entries' => \%onload}); my $end_page = &Apache::loncommon::end_page(); $r->print (< -
Continue +
$end_page ENDREDIR return OK; @@ -3287,8 +3287,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 @@ -3409,14 +3412,16 @@ ENDREDIR my ($typestyle,%to) = &decide_receiver($feedurl); # Actually send mail - my ($status,$numsent)=&send_msg(&clear_out_html($env{'form.subject'}),$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 $subject = &clear_out_html($env{'form.subject'},undef,1); my $anonmode=(defined($env{'form.anondiscuss'})); $typestyle.=&adddiscuss($symb,$message,$anonmode,$attachmenturl, $subject); @@ -3427,7 +3432,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'},