From 8047fd264da9e26d87b991d1e7ed481da932ee8b Mon Sep 17 00:00:00 2001 From: Roy Johnson Date: Wed, 8 Jun 2005 20:04:10 +0000 Subject: [PATCH] fix - [ 1203834 ] accounts created by anon. reg. disobey def. userprofile settings --- lib/WebGUI/FormProcessor.pm | 13 ++++++++++--- lib/WebGUI/Operation/Profile.pm | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/WebGUI/FormProcessor.pm b/lib/WebGUI/FormProcessor.pm index 6a06f99d1..172121e10 100644 --- a/lib/WebGUI/FormProcessor.pm +++ b/lib/WebGUI/FormProcessor.pm @@ -486,16 +486,19 @@ The default value for this variable. If the variable is undefined then the defau =cut sub process { + my ($name, $type, $default) = @_; my $value; $type = "text" if ($type eq ""); $value = &$type($name); + unless (defined $value) { return $default; } if ($value =~ /^[\s]+$/) { return undef; } + return $value; } @@ -631,7 +634,6 @@ sub timeField { Returns a URL. =head3 name - The name of the form variable to retrieve. =cut @@ -652,7 +654,7 @@ sub url { =head2 yesNo ( name ) -Returns either a 1 or 0 representing yes and no. Defaults to "0". +Returns either a 1 or 0 or undef representing yes, no, and undefined. Defaults to "0". =head3 name @@ -664,7 +666,12 @@ sub yesNo { if ($session{form}{$_[0]} > 0) { return 1; } - return 0; + elsif ($session{form}{$_[0]} eq "") { + return undef; + } + else { + return 0; + } } diff --git a/lib/WebGUI/Operation/Profile.pm b/lib/WebGUI/Operation/Profile.pm index 6e685959f..745f9c4d2 100644 --- a/lib/WebGUI/Operation/Profile.pm +++ b/lib/WebGUI/Operation/Profile.pm @@ -114,7 +114,7 @@ sub validateProfileData { $a = WebGUI::SQL->read("select * from userProfileField,userProfileCategory where userProfileField.profileCategoryId=userProfileCategory.profileCategoryId and userProfileCategory.editable=1 and userProfileField.editable=1 order by userProfileCategory.sequenceNumber,userProfileField.sequenceNumber"); while (%field = $a->hash) { - $data{$field{fieldName}} = WebGUI::Macro::negate(WebGUI::FormProcessor::process($field{fieldName},$field{dataType},"")); + $data{$field{fieldName}} = WebGUI::Macro::negate(WebGUI::FormProcessor::process($field{fieldName},$field{dataType}, $field{dataDefault})); if ($field{required} && $data{$field{fieldName}} eq "") { $error .= '
  • '.(eval $field{fieldLabel}).' '.WebGUI::International::get(451); }elsif($field{fieldName} eq "email" && isDuplicateEmail($data{$field{fieldName}})){