[LON-CAPA-cvs] cvs: modules /raeburn/register register.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Wed, 27 Apr 2005 17:01:02 -0000
raeburn Wed Apr 27 13:01:02 2005 EDT
Modified files:
/modules/raeburn/register register.pm
Log:
Convert line feeds in textarea submissions to \n. Escape \n in javascript used to populate form fields when modifying existing registration.
Index: modules/raeburn/register/register.pm
diff -u modules/raeburn/register/register.pm:1.5 modules/raeburn/register/register.pm:1.6
--- modules/raeburn/register/register.pm:1.5 Mon Apr 4 20:03:37 2005
+++ modules/raeburn/register/register.pm Wed Apr 27 13:01:02 2005
@@ -389,8 +389,10 @@
if (exists ($$items{'textarea'}) ) {
foreach (@{$$items{'textarea'}}) {
+ my $value = $curr{$_};
+ $value =~ s/\n/\\n/g;
$set_func .= qq|
- formName.$_.value = "$curr{$_}"
+ formName.$_.value = "$value"
\n|;
}
}
@@ -433,7 +435,7 @@
if ($$form_elements{$_}{'required'} eq 'Y') {
if ($$form_elements{$_}{type} eq 'selectbox') {
$verify_func .= qq|
- if (document.regForm.$_.options[document.regForm.$_.selectedIndex].value == -1) {
+ if (document.regForm.$_.options[document.regForm.$_.selectedIndex].value == "") {
msg = msg + "Select an option for the $$form_elements{$_}{title} field that is not 'Please select'.\\n"
checkok = 0
}
@@ -681,7 +683,7 @@
$multiple = "multiple";
}
$r->print('<select name="'.$$rowitems[$i][$j].
- '"'.$multiple.'><option value="-1">Please select'."\n"
+ '"'.$multiple.'><option value="">Please select'."\n"
);
foreach (@items) {
my ($value,$name) = split/=/,$_;
@@ -791,6 +793,16 @@
}
my @workshops = ();
+# Get form field types.
+ my $sth = $dbh->prepare("SELECT name,type FROM event_formfields WHERE event_id = '$event_id'");
+ $sth->execute();
+ while (my ($name,$type) = $sth->fetchrow_array) {
+ if ($type eq 'textarea') {
+ $$params{$name} =~ s/[\n\r\f]/\n/g;
+ }
+ }
+ $sth->finish;
+
# Is there already conference data for this user?
my $status = $dbh->selectrow_array("SELECT status FROM event_registration WHERE user_id = $quoted_user AND event_id = '$event_id'");
if ($status eq 'enroll') {
@@ -1077,7 +1089,7 @@
}
my $mailcopy = "To: helen\@lon-capa.org\n".
"From: $contact_email\n".
- "Subject: LON-CAPA conference change\n".
+ "Subject: LON-CAPA conference/workshop change\n".
"The following transaction occurred for $user in the LON-CAPA events registration system: \n".
"$msg\n"."$statusmsg{mail}\n";
if (open(MAIL, "|/usr/lib/sendmail -oi -t -odb")) {