Fixed a bug that wouldn't allow admins to save a user profile if email address is required
This commit is contained in:
parent
d05c0af5af
commit
18dd11345c
2 changed files with 8 additions and 3 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue