diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 2720936c1..6bdcd26a6 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -29,6 +29,7 @@ and to allow the dashboard to use user profile fields as preferences rather than having a seperate asset type for it. This mechanism is more efficient, and thusly increases the performance of the dashboard. + - Removed some debug code that was spewing garbage into apache log file. 6.8.0 - Switched Date::Manip to DateTime for better performance and more diff --git a/lib/WebGUI/Operation/Profile.pm b/lib/WebGUI/Operation/Profile.pm index 450d751eb..8bb58a292 100644 --- a/lib/WebGUI/Operation/Profile.pm +++ b/lib/WebGUI/Operation/Profile.pm @@ -136,7 +136,7 @@ sub www_editProfileSave { $u = WebGUI::User->new($session{user}{userId}); foreach $fieldName (keys %{$profile}) { - $u->profileField($fieldName,WebGUI::HTML::filter(${$profile}{$fieldName},"javascript")); + $u->profileField($fieldName,$profile->{$fieldName}); } WebGUI::Session::refreshUserInfo($session{user}{userId}); return WebGUI::Operation::Auth::www_auth(); diff --git a/lib/WebGUI/Operation/User.pm b/lib/WebGUI/Operation/User.pm index 20a561c3b..783381169 100644 --- a/lib/WebGUI/Operation/User.pm +++ b/lib/WebGUI/Operation/User.pm @@ -275,46 +275,12 @@ sub www_editUser { my $style = '" style="display: none;' unless ($_ eq $u->authMethod); $tabform->getTab("account")->raw(''.$authInstance->editUserForm.'
  
'); } - my $a = WebGUI::SQL->read("select * from userProfileField,userProfileCategory - where userProfileField.profileCategoryId=userProfileCategory.profileCategoryId - order by userProfileCategory.sequenceNumber,userProfileField.sequenceNumber"); - my $previousCategory; - while(my $data = $a->hashRef) { - my $category = WebGUI::Operation::Shared::secureEval($data->{categoryName}); - if ($category ne $previousCategory) { - $tabform->getTab("profile")->raw(''.$category.''); - } - my $values = WebGUI::Operation::Shared::secureEval($data->{dataValues}); - my $method = $data->{dataType}; - my $label = WebGUI::Operation::Shared::secureEval($data->{fieldLabel}); - my $default; - my $orderedValues = {}; - tie %{$orderedValues}, 'Tie::IxHash'; - foreach my $ov (sort keys %{$values}) { - $orderedValues->{$ov} = $values->{$ov}; + foreach my $category (@{WebGUI::ProfileCategory->getCategories}) { + $tabform->getTab("profile")->raw(''.$category->getLabel.''); + foreach my $field (@{$category->getFields}) { + $tabform->getTab("profile")->raw($field->formField(undef,1)); } - if ($session{form}{$data->{fieldName}}) { - $default = $session{form}{$data->{fieldName}}; - } - elsif ($u->profileField($data->{fieldName})) { - $default = $u->profileField($data->{fieldName}); - } - else { - $default = WebGUI::Operation::Shared::secureEval($data->{dataDefault}); - } - - my $form = WebGUI::Form::DynamicField->new( - name => $data->{fieldName}, - label => $label, - value => $default, - options => $orderedValues, - fieldType => $method, - ); - - $tabform->getTab("profile")->raw($form->displayFormWithWrapper()); - $previousCategory = $category; - } - $a->finish; + } my @groupsToAdd = WebGUI::FormProcessor::group("groupsToAdd"); my @exclude = WebGUI::SQL->buildArray("select groupId from groupings where userId=".quote($u->userId)); @exclude = (@exclude,"1","2","7"); @@ -370,13 +336,9 @@ sub www_editUserSave { my $authInstance = WebGUI::Operation::Auth::getInstance($_,$u->userId); $authInstance->editUserFormSave; } - my %field; - tie %field, 'Tie::CPHash'; - my $a = WebGUI::SQL->read("select fieldName,dataType from userProfileField"); - while (%field = $a->hash) { - $u->profileField($field{fieldName},WebGUI::FormProcessor::process($field{fieldName},$field{dataType})); - } - $a->finish; + foreach my $field (@{WebGUI::ProfileField->getFields}) { + $u->profileField($field->getId,$field->formProcess); + } my @groups = WebGUI::FormProcessor::group("groupsToAdd"); $u->addToGroups(\@groups); @groups = WebGUI::FormProcessor::group("groupsToDelete"); diff --git a/lib/WebGUI/ProfileField.pm b/lib/WebGUI/ProfileField.pm index cef17c4db..ccfa8a73b 100644 --- a/lib/WebGUI/ProfileField.pm +++ b/lib/WebGUI/ProfileField.pm @@ -22,7 +22,7 @@ use WebGUI::SQL; use WebGUI::Form; use WebGUI::FormProcessor; use WebGUI::Operation::Shared; -use WebGUI::Macro; +use WebGUI::HTML; =head1 NAME @@ -105,7 +105,7 @@ sub delete { #------------------------------------------------------------------- -=head2 formField ( formProperties ) +=head2 formField ( [ formProperties, withWrapper] ) Returns an HTMLified form field element. @@ -113,11 +113,16 @@ Returns an HTMLified form field element. Optionally pass in a list of properties to override the default properties of any form element. You cannot override the pieces specified as part of the form field like field type, label, options, etc. +=head3 withWrapper + +A boolean indicating whether to return just the field, or the field with a table label wrapper. + =cut sub formField { my $self = shift; my $properties = shift; + my $withWrapper = shift; $properties->{label} = $self->getLabel; $properties->{fieldType} = $self->get("fieldType"); $properties->{name} = $self->getId; @@ -137,7 +142,11 @@ sub formField { $default = WebGUI::Operation::Shared::secureEval($properties->{dataDefault}); } $properties->{value} = $default; - return WebGUI::Form::DynamicField->new($properties)->displayForm; + if ($withWrapper) { + return WebGUI::Form::DynamicField->new($properties)->displayFormWithWrapper; + } else { + return WebGUI::Form::DynamicField->new($properties)->displayForm; + } } @@ -151,7 +160,7 @@ Returns the value retrieved from a form post. sub formProcess { my $self = shift; - return WebGUI::Macro::negate(WebGUI::FormProcessor::process($self->getId,$self->get("fieldType"),WebGUI::Operation::Shared::secureEval($self->get("possibleValues")))); + return WebGUI::HTML::filter(WebGUI::FormProcessor::process($self->getId,$self->get("fieldType"),WebGUI::Operation::Shared::secureEval($self->get("possibleValues"))), "javascript"); } #------------------------------------------------------------------- diff --git a/lib/WebGUI/User.pm b/lib/WebGUI/User.pm index 0148a9326..f5efe32de 100644 --- a/lib/WebGUI/User.pm +++ b/lib/WebGUI/User.pm @@ -17,7 +17,6 @@ package WebGUI::User; use strict; use WebGUI::Cache; use WebGUI::Id; -use WebGUI::Macro; use WebGUI::Session; use WebGUI::SQL; @@ -307,9 +306,6 @@ sub profileField { $self = shift; $fieldName = shift; $value = shift; - warn "value 0: $value\n"; - WebGUI::Macro::negate(\$value); - warn "value 1: $value\n"; if (defined $value) { warn "storing: $value\n"; $self->uncache;