Associate the proper best_domain to a user.
authorStéphane Jacob <sj@m4x.org>
Mon, 2 May 2011 15:15:18 +0000 (17:15 +0200)
committerStéphane Jacob <sj@m4x.org>
Mon, 2 May 2011 15:15:18 +0000 (17:15 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
modules/email.php

index 41d4bf9..7648515 100644 (file)
@@ -72,9 +72,10 @@ class EmailModule extends PLModule
                            WHERE  uid = {?} AND email = {?}", $user->id(), $email);
             XDB::execute('UPDATE  accounts              AS a
                       INNER JOIN  email_virtual_domains AS d ON (d.name = {?})
+                      INNER JOIN  email_virtual_domains AS m ON (d.aliasing = m.id)
                              SET  a.best_domain = d.id
-                           WHERE  a.uid = {?}',
-                         $domain, $user->id());
+                           WHERE  a.uid = {?} AND m.name = {?}',
+                         $domain, $user->id(), $user->mainEmailDomain());
 
             // As having a non-null bestalias value is critical in
             // plat/al's code, we do an a posteriori check on the