Updates merge scripts.
authorStéphane Jacob <sj@m4x.org>
Sat, 10 Dec 2011 20:50:04 +0000 (21:50 +0100)
committerStéphane Jacob <sj@m4x.org>
Sat, 10 Dec 2011 20:50:04 +0000 (21:50 +0100)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
upgrade/1.0.1/merge.php
upgrade/1.0.1/merge_issues.php

index c451d2d..dc5e678 100755 (executable)
@@ -130,17 +130,17 @@ XDB::rawExecute("INSERT IGNORE INTO  profile_merge_issues (pid, issues, entry_ye
 XDB::rawExecute('ALTER TABLE geoloc_countries ADD INDEX (licensePlate)');
 XDB::rawExecute('UPDATE  profiles         AS p
              INNER JOIN  fusionax_anciens AS f ON (p.pid = f.pid)
-             INNER JOIN  geoloc_countries AS g ON (g.licensePlate = f.Code_nationalite AND g.nationalityFR IS NOT NULL)
+             INNER JOIN  geoloc_countries AS g ON (g.licensePlate = f.Code_nationalite AND g.nationality IS NOT NULL)
                     SET  p.nationality1 = g.iso_3166_1_a2
                   WHERE  p.nationality1 IS NULL');
 XDB::rawExecute('UPDATE  profiles         AS p
              INNER JOIN  fusionax_anciens AS f ON (p.pid = f.pid)
-             INNER JOIN  geoloc_countries AS g ON (g.licensePlate = f.Code_nationalite AND g.nationalityFR IS NOT NULL)
+             INNER JOIN  geoloc_countries AS g ON (g.licensePlate = f.Code_nationalite AND g.nationality IS NOT NULL)
                     SET  p.nationality2 = g.iso_3166_1_a2
                   WHERE  p.nationality1 != g.iso_3166_1_a2 AND p.nationality2 IS NULL');
 XDB::rawExecute('UPDATE  profiles         AS p
              INNER JOIN  fusionax_anciens AS f ON (p.pid = f.pid)
-             INNER JOIN  geoloc_countries AS g ON (g.licensePlate = f.Code_nationalite AND g.nationalityFR IS NOT NULL)
+             INNER JOIN  geoloc_countries AS g ON (g.licensePlate = f.Code_nationalite AND g.nationality IS NOT NULL)
                     SET  p.nationality3 = g.iso_3166_1_a2
                   WHERE  p.nationality1 != g.iso_3166_1_a2 AND p.nationality2 != g.iso_3166_1_a2 AND p.nationality3 IS NULL');
 XDB::rawExecute('ALTER TABLE geoloc_countries DROP INDEX licensePlate');
@@ -196,12 +196,12 @@ XDB::rawExecute("UPDATE  profiles         AS p
                   WHERE  f.Mel_publiable = 1 AND f.Mel_usage != '' AND p.email_directory IS NULL");
 XDB::rawExecute("INSERT IGNORE INTO  register_marketing (uid, email, type)
                              SELECT  ap.uid, f.Mel_usage, 'ax'
-                               FROM  fusionax_anciens AS f
-                         INNER JOIN  account_profiles AS ap ON (ap.pid = f.pid AND FIND_IN_SET('owner', perms))
-                          LEFT JOIN  emails           AS e  ON (e.uid = ap.uid AND e.flags = 'active')
+                               FROM  fusionax_anciens       AS f
+                         INNER JOIN  account_profiles       AS ap ON (ap.pid = f.pid AND FIND_IN_SET('owner', perms))
+                          LEFT JOIN  email_redirect_account AS e  ON (e.uid = ap.uid AND e.flags = 'active')
                               WHERE  f.Mel_usage != '' AND f.Mel_usage NOT LIKE '%@polytechnique.edu'
                                      AND f.Mel_usage NOT LIKE '%@polytechnique.org' AND f.Mel_usage NOT LIKE '%@m4x.org'
-                                     AND f.Mel_usage NOT LIKE '%@melix.%' AND e.email IS NULL");
+                                     AND f.Mel_usage NOT LIKE '%@melix.%' AND e.redirect IS NULL");
 
 // Retrieves different deathdates.
 XDB::rawExecute("UPDATE  profile_merge_issues AS pm
index 1e8fdbb..4c3fc88 100755 (executable)
@@ -5,6 +5,7 @@
 require_once 'connect.db.inc.php';
 require_once '../../classes/phone.php';
 require_once '../../classes/address.php';
+require_once '../../classes/visibility.php';
 
 $globals->debug = 0; // Do not store backtraces.
 
@@ -131,8 +132,7 @@ foreach ($pids as $pid) {
         for ($j = $i + 1; $j < $count; ++$j) {
             if (check($rawAddresses[$i], $rawAddresses[$j])) {
                 $duplicates[$j] = true;
-                $minPub = new ProfileVisibility($addresses[$j]->pub);
-                if ($minPub->isVisible($addresses[$i]->pub)) {
+                if (Visibility::isLessRestrictive($addresses[$i]->pub, $addresses[$j]->pub)) {
                     $addresses[$i]->pub = $addresses[$j]->pub;
                 }
                 if ($addresses[$j]->hasFlag('mail') && !$addresses[$i]->hasFlag('mail')) {
@@ -141,8 +141,10 @@ foreach ($pids as $pid) {
             }
         }
     }
-    foreach ($duplicates as $key => $bool) {
-        unset($addresses[$key]);
+    if (count($duplicates)) {
+        foreach ($duplicates as $key => $bool) {
+            unset($addresses[$key]);
+        }
     }
     if (count($addresses) != $count) {
         $deleted += ($count - count($addresses));
@@ -217,18 +219,18 @@ foreach ($pids as $pid) {
     }
     for ($i = 0; $i < $count; ++$i) {
         for ($j = $i + 1; $j < $count; ++$j) {
-            if ($phones[$i]->search() == $phones[$j]->search()) {
+            if ($phones[$i]->search == $phones[$j]->search) {
                 $duplicates[$j] = true;
-                $minPub = new ProfileVisibility($phones[$j]->pub);
-                if ($minPub->isVisible($phones[$i]->pub)) {
+                if (Visibility::isLessRestrictive($phones[$i]->pub, $phones[$j]->pub)) {
                     $phones[$i]->pub = $phones[$j]->pub;
                 }
-
             }
         }
     }
-    foreach ($duplicates as $key => $bool) {
-        unset($phones[$key]);
+    if (count($duplicates)) {
+        foreach ($duplicates as $key => $bool) {
+            unset($phones[$key]);
+        }
     }
     if (count($phones) != $count) {
         $deleted += ($count - count($phones));