Adds specific function to build homonyms hrmid.
authorStéphane Jacob <sj@m4x.org>
Sun, 6 Mar 2011 17:16:47 +0000 (18:16 +0100)
committerStéphane Jacob <sj@m4x.org>
Sun, 6 Mar 2011 19:07:31 +0000 (20:07 +0100)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
bin/cron/homonyms.php
classes/user.php
include/validations/homonymes.inc.php
modules/admin.php
modules/register/register.inc.php

index cfc5b0d..f70ee30 100755 (executable)
@@ -33,8 +33,8 @@ while ($old = $resRobot->next()) {
     $res = XDB::query('SELECT  a.hruid
                          FROM  homonyms_list AS h
                    INNER JOIN  accounts      AS a ON (h.uid = a.uid)
-                        WHERE  hrmid = {?}',
-                      'h.' . $old['email'] . '.' . Platal::globals()->mail->domain);
+                        WHERE  h.hrmid = {?}',
+                      User::makeHomonymHrmid($old['email']);
     $hruids = $res->fetchColumn();
 
     $homonym = User::getSilent($old['uid']);
index 1eaa12f..039fec6 100644 (file)
@@ -824,6 +824,11 @@ class User extends PlUser
         }
     }
 
+    public static function makeHomonymHrmid($alias)
+    {
+        return 'h.' . $alias . '.' . Platal::globals()->mail->domain;
+    }
+
     public static function isMainMailDomain($domain)
     {
         global $globals;
index 14a6f49..7256112 100644 (file)
@@ -124,8 +124,7 @@ est ambigu pour des raisons d'homonymie et signalera ton email exact.";
                                SELECT  {?}, {?}, id, \'homonym\', NOW()
                                  FROM  email_virtual_domains
                                 WHERE  name = {?}',
-                         'h.' . $this->loginbis . '.' . Platal::globals()->mail->domain,
-                         $this->loginbis, $this->user->mainEmailDomain());
+                         User::makeHomonymHrmid($this->loginbis), $this->loginbis, $this->user->mainEmailDomain());
             fix_bestalias($this->user);
         }
 
index d063d71..f97f83a 100644 (file)
@@ -979,8 +979,7 @@ class AdminModule extends PLModule
                                        SELECT  {?}, {?}, id, \'homonym\', NOW()
                                          FROM  email_virtual_domains
                                         WHERE  name = {?}',
-                                 'h.' . $loginbis . '.' . Platal::globals()->mail->domain,
-                                 $loginbis, $user->mainEmailDomain());
+                                 User::makeHomonymHrmid($loginbis), $loginbis, $user->mainEmailDomain());
                     fix_bestalias($user);
                     send_robot_homonyme($user, $loginbis);
                     $op = 'list';
index 7a8b21f..83f5ea2 100644 (file)
@@ -163,7 +163,7 @@ function createAliases($subState)
                              SET  expire = ADDDATE(NOW(), INTERVAL 1 MONTH)
                            WHERE  email = {?} AND type != \'alias_aux\'',
                          $emailXorg);
-            $hrmid = 'h.' . $emailXorg . '.' . $globals->mail->domain;
+            $hrmid = User::makeHomonymHrmid($emailXorg);
             XDB::execute('INSERT IGNORE INTO  homonyms_list (hrmid, uid)
                                       VALUES  ({?}, {?}), ({?}, {?})',
                          $hrmid, $h_id, $hrmid, $subState->i('uid'));