Fix alias overriding bug when changing names
authorNicolas Iooss <nicolas.iooss_git@polytechnique.org>
Thu, 2 Jan 2014 19:02:34 +0000 (20:02 +0100)
committerNicolas Iooss <nicolas.iooss_git@polytechnique.org>
Thu, 2 Jan 2014 19:02:34 +0000 (20:02 +0100)
When changing name (first name or last name), the new alias was tested against
existing aliases in email_source_account table but not against those in
email_source_other, where the homonyms are.

Signed-off-by: Nicolas Iooss <nicolas.iooss_git@polytechnique.org>
include/validations/names.inc.php

index d52a849..34e0567 100644 (file)
@@ -59,6 +59,13 @@ class NamesReq extends ProfileValidate
                                              FROM  email_source_account
                                             WHERE  email = {?} AND type != \'alias_aux\'',
                                           $this->new_alias);
+                if (!$used) {
+                    // Check against homonyms
+                    $used = XDB::fetchOneCell('SELECT  COUNT(email)
+                                                 FROM  email_source_other
+                                                WHERE  email = {?}',
+                                              $this->new_alias);
+                }
                 if ($used) {
                     $this->new_alias = null;
                 }