refactored user manager to use new profile backend

This commit is contained in:
JT Smith 2005-12-07 17:36:08 +00:00
parent 5941f6d3f8
commit a20aa5f587
5 changed files with 23 additions and 55 deletions

View file

@ -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

View file

@ -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();

View file

@ -275,46 +275,12 @@ sub www_editUser {
my $style = '" style="display: none;' unless ($_ eq $u->authMethod);
$tabform->getTab("account")->raw('<tr id="'.$_.$style.'"><td colspan="2" align="center"><table>'.$authInstance->editUserForm.'<tr><td width="170">&nbsp;</td><td>&nbsp;</td></tr></table></td></tr>');
}
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('<tr><td colspan="2" class="tableHeader">'.$category.'</td></tr>');
}
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('<tr><td colspan="2" class="tableHeader">'.$category->getLabel.'</td></tr>');
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");

View file

@ -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");
}
#-------------------------------------------------------------------

View file

@ -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;