[LON-CAPA-cvs] cvs: loncom /interface lonfeedback.pm /lonnet/perl lonnet.pm /xml lonxml.pm
www
lon-capa-cvs@mail.lon-capa.org
Thu, 03 Oct 2002 15:04:30 -0000
www Thu Oct 3 11:04:30 2002 EDT
Modified files:
/loncom/interface lonfeedback.pm
/loncom/lonnet/perl lonnet.pm
/loncom/xml lonxml.pm
Log:
Bug 781
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.32 loncom/interface/lonfeedback.pm:1.33
--- loncom/interface/lonfeedback.pm:1.32 Mon Sep 16 15:54:01 2002
+++ loncom/interface/lonfeedback.pm Thu Oct 3 11:04:29 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.32 2002/09/16 19:54:01 albertel Exp $
+# $Id: lonfeedback.pm,v 1.33 2002/10/03 15:04:29 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -50,6 +50,7 @@
use Apache::Constants qw(:common);
use Apache::lonmsg();
use Apache::loncommon();
+use Apache::lontexconvert();
sub mail_screen {
my ($r,$feedurl,$options) = @_;
@@ -114,9 +115,8 @@
<input type=hidden name=sendit value=1>
<input type=button value="Send Feedback" onClick='gosubmit();'></input>
</form>
-</body>
-</html>
ENDDOCUMENT
+$r->print(&generate_preview_button().'</body></html>');
}
sub fail_redirect {
@@ -227,6 +227,7 @@
sub clear_out_html {
my $message=$ENV{'form.comment'};
+ $message=~s/\<\/*m\s*\>//g;
$message=~s/\</\<\;/g;
$message=~s/\>/\>\;/g;
return $message;
@@ -358,6 +359,26 @@
return $status.'<br>';
}
+# ----------------------------------------------------------- Preview function
+
+sub show_preview {
+ my $r=shift;
+ my $message=&clear_out_html($ENV{'form.comment'});
+ $message=~s/\n/\<br \/\>/g;
+ $message=&Apache::lontexconvert::msgtexconverted($message);
+ $r->print('<table border="2"><tr><td>'.
+ $message.'</td></tr></table>');
+}
+
+sub generate_preview_button {
+ return(<<ENDPREVIEW);
+<form name="preview" action="/adm/feedback?preview=1" method="post" target="preview">
+<input type="hidden" name="comment" />
+<input type="button" value="Show Preview"
+onClick="this.form.comment.value=document.mailform.comment.value;this.form.submit();" />
+</form>
+ENDPREVIEW
+}
sub handler {
my $r = shift;
if ($r->header_only) {
@@ -369,7 +390,7 @@
# --------------------------- Get query string for limited number of parameters
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['hide','unhide','postdata']);
+ ['hide','unhide','postdata','preview']);
if (($ENV{'form.hide'}) || ($ENV{'form.unhide'})) {
# ----------------------------------------------------------------- Hide/unhide
@@ -401,6 +422,9 @@
&redirect_back($r,&Apache::lonnet::clutter($url),
'Changed discussion status<p>','0','0');
+ } elsif ($ENV{'form.preview'}) {
+# -------------------------------------------------------- User wants a preview
+ &show_preview($r);
} else {
# ------------------------------------------------------------- Normal feedback
my $feedurl=$ENV{'form.postdata'};
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.289 loncom/lonnet/perl/lonnet.pm:1.290
--- loncom/lonnet/perl/lonnet.pm:1.289 Tue Oct 1 15:09:27 2002
+++ loncom/lonnet/perl/lonnet.pm Thu Oct 3 11:04:29 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.289 2002/10/01 19:09:27 bowersj2 Exp $
+# $Id: lonnet.pm,v 1.290 2002/10/03 15:04:29 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -652,7 +652,7 @@
$author=~s/\/home\/httpd\/html\/res\/([^\/]*)\/([^\/]*).*/$1\/$2/;
my ($udom,$uname)=split(/\//,$author);
my $home=homeserver($uname,$udom);
- if (($home eq 'no_host') || ($home eq $perlvar{'lonHostID'})) {
+ if ($home eq 'no_host') {
return 'not_found';
}
my $answer=reply("sub:$fname",$home);
@@ -683,6 +683,11 @@
} elsif ($remoteurl eq 'directory') {
return OK;
} else {
+ my $author=$filename;
+ $author=~s/\/home\/httpd\/html\/res\/([^\/]*)\/([^\/]*).*/$1\/$2/;
+ my ($udom,$uname)=split(/\//,$author);
+ my $home=homeserver($uname,$udom);
+ unless ($home eq $perlvar{'lonHostID'}) {
my @parts=split(/\//,$filename);
my $path="/$parts[1]/$parts[2]/$parts[3]/$parts[4]";
if ($path ne "$perlvar{'lonDocRoot'}/res") {
@@ -718,6 +723,7 @@
rename($transname,$filename);
return OK;
}
+ }
}
}
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.197 loncom/xml/lonxml.pm:1.198
--- loncom/xml/lonxml.pm:1.197 Thu Oct 3 09:34:10 2002
+++ loncom/xml/lonxml.pm Thu Oct 3 11:04:29 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.197 2002/10/03 13:34:10 sakharuk Exp $
+# $Id: lonxml.pm,v 1.198 2002/10/03 15:04:29 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -99,6 +99,7 @@
use Apache::lonnet();
use Apache::File();
use Apache::loncommon();
+use Apache::lonfeedback();
#================================================== Main subroutine: xmlparse
#debugging control, to turn on debugging modify the correct handler
@@ -232,7 +233,7 @@
}
if ($discussiononly) {
$discussion.=(<<ENDDISCUSS);
-<form action="/adm/feedback" method="post">
+<form action="/adm/feedback" method="post" name="mailform">
<input type="submit" name="discuss" value="Post Discussion" />
<input type="submit" name="anondiscuss" value="Post Anonymous Discussion" />
<input type="hidden" name="symb" value="$symb" />
@@ -243,6 +244,7 @@
<textarea name=comment cols=60 rows=10 wrap=hard></textarea>
</form>
ENDDISCUSS
+ $discussion.=&Apache::lonfeedback::generate_preview_button();
}
}
}