Kill references to obsolete tables.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 21 Feb 2010 12:25:42 +0000 (13:25 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 21 Feb 2010 12:31:47 +0000 (13:31 +0100)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
classes/profile.php
classes/userfilter.php
include/reminder/profile_update.inc.php

index f1dc23d..3c782b6 100644 (file)
@@ -442,7 +442,9 @@ class Profile
                                       IF(pn_ul.name IS NULL, pn_l.name, pn_ul.name) AS lastname_ordinary,
                                       pd.promo AS promo, pd.short_name, pd.directory_name AS full_name,
                                       pd.directory_name, pp.display_tel AS mobile, pp.pub AS mobile_pub,
-                                      ph.pub AS photo_pub, ap.uid AS owner_id
+                                      ph.attach IS NOT NULL AS has_photo, ph.pub AS photo_pub,
+                                      p.last_change < DATE_SUB(NOW(), INTERVAL 365 DAY) AS is_old,
+                                      ap.uid AS owner_id
                                 FROM  profiles AS p
                           INNER JOIN  profile_display AS pd ON (pd.pid = p.pid)
                           INNER JOIN  profile_education AS pe ON (pe.uid = p.pid AND FIND_IN_SET(\'primary\', pe.flags))
index fa155f2..cd71249 100644 (file)
@@ -1730,12 +1730,12 @@ class UserFilter extends PlFilter
         if ($promo_min != 0) {
             $min = new UFC_Promo('>=', self::GRADE_ING, intval($promo_min));
         } else {
-            $min = new UFC_True();
+            $min = new PFC_True();
         }
         if ($promo_max != 0) {
             $max = new UFC_Promo('<=', self::GRADE_ING, intval($promo_max));
         } else {
-            $max = new UFC_True();
+            $max = new PFC_True();
         }
         return new UserFilter(new PFC_And($min, $max));
     }
index c853f5f..4efaffb 100644 (file)
@@ -48,23 +48,16 @@ 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', $is_profile_old);
-        $page->assign('profile_last_update', $profile_date);
-        $page->assign('photo_incitation', !$has_photo);
+        $page->assign('profile_incitation', $profile->is_old);
+        $page->assign('profile_last_update', $profile->last_change);
+        $page->assign('photo_incitation', !$profile->has_photo);
 
         $res = XDB::query('SELECT  COUNT(*)
                              FROM  profile_addresses
                             WHERE  pid = {?} AND accuracy = 0',
-                          $this->user->id());
+                          $profile->id());
         $page->assign('geocoding_incitation', $res->fetchOneCell());
     }
 
@@ -83,20 +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();
-
-        $res = XDB::query('SELECT  COUNT(*)
-                             FROM  profile_addresses
-                            WHERE  pid = {?} AND accuracy = 0',
-                          $user->id());
-
-        return ($res->fetchOneCell() || !$has_photo || $is_profile_old);
+        $profile = $user->profile();
+        if (!$profile) {
+            return false;
+        }
+        return !$profile->has_photo || $profile->is_old;
     }
 }