From 18dd11345c8dd21611325fc60b6ed6ade81687ec Mon Sep 17 00:00:00 2001 From: Frank Dillon Date: Tue, 23 Dec 2008 03:35:58 +0000 Subject: [PATCH] Fixed a bug that wouldn't allow admins to save a user profile if email address is required --- lib/WebGUI/ProfileField.pm | 9 +++++++-- lib/WebGUI/User.pm | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/WebGUI/ProfileField.pm b/lib/WebGUI/ProfileField.pm index 958818f7a..ad1317a84 100644 --- a/lib/WebGUI/ProfileField.pm +++ b/lib/WebGUI/ProfileField.pm @@ -505,7 +505,7 @@ sub getPasswordRecoveryFields { #------------------------------------------------------------------- -=head2 isDuplicate( fieldValue ) +=head2 isDuplicate( fieldValue, userId ) Checks the value of the field to see if it is duplicated in the system. Returns true of false. @@ -513,6 +513,10 @@ Checks the value of the field to see if it is duplicated in the system. Returns value to check for duplicates against +=head3 userId + +userId to check for duplicates againts + =cut sub isDuplicate { @@ -520,9 +524,10 @@ sub isDuplicate { my $session = $self->session; my $fieldId = $self->getId; my $value = shift; + my $userId = shift || $session->user->userId; my $sql = qq{select count(*) from userProfileData where $fieldId = ? and userId <> ?}; - my $duplicate = $session->db->quickScalar($sql,[$value, $session->user->userId]); + my $duplicate = $session->db->quickScalar($sql,[$value, $userId]); return ($duplicate > 0); } diff --git a/lib/WebGUI/User.pm b/lib/WebGUI/User.pm index 09ae412ca..a2444622e 100644 --- a/lib/WebGUI/User.pm +++ b/lib/WebGUI/User.pm @@ -1190,7 +1190,7 @@ sub validateProfileDataFromForm { push(@{$errorFields},$fieldId); } #Duplicate emails throw warnings - elsif($fieldId eq "email" && $field->isDuplicate($fieldValue)) { + elsif($fieldId eq "email" && $field->isDuplicate($fieldValue,$self->userId)) { $errorCat = $field->get("profileCategoryId") unless (defined $errorCat); push (@{$warnings},$i18n->get(1072)); push(@{$warnFields},$fieldId);