From 39eb753e7e60146bc595d7b4c7047920807058ff Mon Sep 17 00:00:00 2001 From: JT Smith Date: Wed, 7 Dec 2005 16:23:47 +0000 Subject: [PATCH] more profile updates --- docs/changelog/6.x.x.txt | 4 ++++ docs/upgrades/upgrade_6.8.0-6.8.1.pl | 11 ++++++++++ lib/WebGUI/ProfileField.pm | 32 +++++++++++++++++++++++++--- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index dd2d71be2..2720936c1 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -25,6 +25,10 @@ - fix [ 1373493 ] Upgrade script fails because parameters are not quoted - Upgrade now uses --results-file parameter on mysqldump because some operating system don't handle UTF-8 characters through their pipes. + - Added backend API for user profile schema to eliminate inconsistencies + 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. 6.8.0 - Switched Date::Manip to DateTime for better performance and more diff --git a/docs/upgrades/upgrade_6.8.0-6.8.1.pl b/docs/upgrades/upgrade_6.8.0-6.8.1.pl index db50498da..0369bb91c 100644 --- a/docs/upgrades/upgrade_6.8.0-6.8.1.pl +++ b/docs/upgrades/upgrade_6.8.0-6.8.1.pl @@ -24,11 +24,22 @@ start(); # this line required upgradeRichEditor(); fixCSFaqTemplateAnchors(); +updateProfileSystem(); convertDashboardPrefs(); finish(); # this line required +#------------------------------------------------- +sub updateProfileSystem { + print "\tUpdating user profile system.\n" unless ($quiet); + WebGUI::SQL->write("alter table userProfileField change fieldLabel label varchar(255) not null default 'Undefined'"); + WebGUI::SQL->write("alter table userProfileField change dataType fieldType varchar(128) not null default 'text'"); + WebGUI::SQL->write("alter table userProfileField change dataValues possibleValues text"); + WebGUI::SQL->write("alter table userProfileField change dataDefault defaultValues text"); + WebGUI::SQL->write("alter table userProfileCategory change categoryName label varchar(255) not null default 'Undefined'"); +} + #------------------------------------------------- sub upgradeRichEditor { print "\tUpgrade rich editor\n" unless ($quiet); diff --git a/lib/WebGUI/ProfileField.pm b/lib/WebGUI/ProfileField.pm index 721243050..db06d7b08 100644 --- a/lib/WebGUI/ProfileField.pm +++ b/lib/WebGUI/ProfileField.pm @@ -103,14 +103,39 @@ sub delete { #------------------------------------------------------------------- -=head2 formField () +=head2 formField ( formProperties ) Returns an HTMLified form field element. +=head3 formProperties + +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. + =cut sub formField { - + my $self = shift; + my $properties = shift; + $properties->{label} = WebGUI::Operation::Shared::secureEval($self->get("label")); + $properties->{fieldType} = $self->get("fieldType"); + $properties->{name} = $self->getId; + my $values = WebGUI::Operation::Shared::secureEval($self->get("possibleValues")); + my $orderedValues = {}; + tie %{$orderedValues}, 'Tie::IxHash'; + foreach my $ov (sort keys %{$values}) { + $orderedValues->{$ov} = $values->{$ov}; + } + $properties->{options} = $orderedValues; + my $default; + if ($session{form}{$data->{fieldName}}) { + $default = $session{form}{$data->{fieldName}}; + } elsif ($session{user}{$data->{fieldName}}) { + $default = $session{user}{$data->{fieldName}}; + } else { + $default = WebGUI::Operation::Shared::secureEval($data->{dataDefault}); + } + $properties->{value} = $default; + return WebGUI::Form::DynamicField->new($properties)->displayForm; } @@ -123,7 +148,8 @@ Returns the value retrieved from a form post. =cut sub formProcess { - + my $self = shift; + return WebGUI::FormProcessor::process($self->getId,$self->get("fieldType"),WebGUI::Operation::Shared::secureEval($self->get("possibleValues"))); } #-------------------------------------------------------------------