Do not notify non geocoded addresses if they are saved from a script.
authorStéphane Jacob <sj@m4x.org>
Sun, 23 Oct 2011 21:05:32 +0000 (23:05 +0200)
committerStéphane Jacob <sj@m4x.org>
Sun, 23 Oct 2011 21:10:24 +0000 (23:10 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
bin/formatAddresses.php
classes/address.php

index d207748..2e25835 100755 (executable)
@@ -116,7 +116,7 @@ while ($address = $it->next()) {
     $address->changed = ($geocoding_required ? 1 : 0);
     $address->format();
     if ($address->delete()) {
-        $address->save();
+        $address->save(false);
     } else {
         ++$skipped;
     }
index 915152f..af0e2f0 100644 (file)
@@ -685,7 +685,7 @@ class Address
         return (!$this->text || $this->text == '');
     }
 
-    public function save()
+    public function save($notify_ungeocoded = true)
     {
         if (!$this->isEmpty()) {
             XDB::execute('INSERT IGNORE INTO  profile_addresses (pid, jobid, groupid, type, id, flags, text, postalText, pub, comment,
@@ -704,7 +704,7 @@ class Address
                                               VALUES  ({?}, {?}, {?}, {?}, {?}, {?})',
                                  $this->pid, $this->jobid, $this->groupid, $this->type, $this->id, $component_id);
                 }
-            } else {
+            } elseif ($notify_ungeocoded) {
                 // If the address was not geocoded, notifies it to the appropriate ML.
                 $mailer = new PlMailer('profile/no_geocoding.mail.tpl');
                 $mailer->assign('text', $this->text);