Also displays entreprise name on profile, minifiche... when awaiting validation.
[platal.git] / include / reminder / profile_update.inc.php
index 8ab7bc1..4efaffb 100644 (file)
@@ -48,22 +48,17 @@ class ReminderProfileUpdate extends Reminder
     public function Prepare(&$page)
     {
         parent::Prepare($page);
+        $profile = $this->user->profile();
 
-        $res = XDB::query('SELECT  date < DATE_SUB(NOW(), INTERVAL 365 DAY) AS is_profile_old,
-                                   date AS profile_date, LENGTH(p.attach) > 0 AS has_photo
-                             FROM  auth_user_md5 AS u
-                        LEFT JOIN  photo         AS p ON (u.user_id = p.uid)
-                            WHERE  user_id = {?}',
-                          $this->user->id());
-        list($is_profile_old, $profile_date, $has_photo) = $res->fetchOneRow();
+        $page->assign('profile_incitation', $profile->is_old);
+        $page->assign('profile_last_update', $profile->last_change);
+        $page->assign('photo_incitation', !$profile->has_photo);
 
-        $page->assign('profile_incitation', $is_profile_old);
-        $page->assign('profile_last_update', $profile_date);
-        $page->assign('photo_incitation', !$has_photo);
-
-        require_once 'geoloc.inc.php';
-        $res = localize_addresses($this->user->id());
-        $page->assign('geocoding_incitation', count($res));
+        $res = XDB::query('SELECT  COUNT(*)
+                             FROM  profile_addresses
+                            WHERE  pid = {?} AND accuracy = 0',
+                          $profile->id());
+        $page->assign('geocoding_incitation', $res->fetchOneCell());
     }
 
     public function template()
@@ -81,17 +76,11 @@ class ReminderProfileUpdate extends Reminder
 
     public static function IsCandidate(User &$user, $candidate)
     {
-        $res = XDB::query('SELECT  date < DATE_SUB(NOW(), INTERVAL 365 DAY) AS is_profile_old,
-                                   p.attach AS photo
-                             FROM  auth_user_md5 AS u
-                        LEFT JOIN  photo         AS p ON (u.user_id = p.uid)
-                            WHERE  user_id = {?}',
-                          $user->id());
-        list($is_profile_old, $has_photo) = $res->fetchOneRow();
-        require_once 'geoloc.inc.php';
-        $res = localize_addresses($user->id());
-
-        return (count($res) || !$has_photo || $is_profile_old);
+        $profile = $user->profile();
+        if (!$profile) {
+            return false;
+        }
+        return !$profile->has_photo || $profile->is_old;
     }
 }