Activates geocoding reminder for new geocoding.
authorStéphane Jacob <sj@m4x.org>
Sun, 5 Jun 2011 18:50:04 +0000 (20:50 +0200)
committerStéphane Jacob <sj@m4x.org>
Sun, 5 Jun 2011 18:50:04 +0000 (20:50 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
classes/geocoder.php
include/reminder/profile_update.inc.php

index c5ff63e..01d5e3e 100644 (file)
@@ -73,6 +73,20 @@ abstract class Geocoder {
         }
         return $firstLines;
     }
+
+    // Returns the number of non geocoded addresses for a profile.
+    static public function countNonGeocoded($pid)
+    {
+        $count = XDB::fetchOneCell('SELECT  COUNT(*)
+                                      FROM  profile_addresses AS pa
+                                     WHERE  pid = {?} AND type = \'home\'
+                                            AND NOT EXISTS (SELECT  *
+                                                              FROM  profile_addresses_components AS pc
+                                                             WHERE  pa.pid = pc.pid AND pa.jobid = pc.jobid AND pa.groupid = pc.groupid
+                                                                    AND pa.type = pc.type AND pa.id = pc.id)',
+                                   $pid);
+        return $count;
+    }
 }
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
index c1ab4df..3785b6d 100644 (file)
@@ -103,7 +103,8 @@ class ReminderProfileUpdate extends Reminder
             return false;
         }
         return !$profile->has_photo || $profile->is_old
-            || !is_null(self::ListMergeIssues($profile));
+            || !is_null(self::ListMergeIssues($profile))
+            || Geocoder::countNonGeocoded($profile->id()) > 0;
     }
 }