X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Freminder%2Fprofile_update.inc.php;h=c1ab4dfc22eca4aea5fda6bf261c904b36c2b67e;hb=97980d82cffb765e16502de2d1fb694d69631b25;hp=460997722c27c7d02ab2f867a52473b29b511cf8;hpb=d1e6167749fdad08c81e23d09e1bbbf76e3b989b;p=platal.git diff --git a/include/reminder/profile_update.inc.php b/include/reminder/profile_update.inc.php index 4609977..c1ab4df 100644 --- a/include/reminder/profile_update.inc.php +++ b/include/reminder/profile_update.inc.php @@ -1,6 +1,6 @@ UpdateOnDismiss(); - pl_redirect('profile/edit'); + pl_redirect('profile/edit/' . $this->user->profile()->hrpid); break; case 'photo': @@ -40,32 +40,33 @@ class ReminderProfileUpdate extends Reminder case 'geoloc': $this->UpdateOnDismiss(); - pl_redirect('profile/edit/adresses'); + pl_redirect('profile/edit/' . $this->user->profile()->hrpid . '/adresses'); + break; + + case 'merge': + $this->UpdateOnDismiss(); + $flags = self::ListMergeIssues($this->user->profile()); + if ($flags->hasFlag('job')) { + pl_redirect('profile/edit/' . $this->user->profile()->hrpid . '/emploi'); + } else if ($flags->hasFlag('address')) { + pl_redirect('profile/edit/' . $this->user->profile()->hrpid . '/adresses'); + } else { + pl_redirect('profile/edit/' . $this->user->profile()->hrpid); + } break; } } - public function Prepare(&$page) + 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); - - $res = XDB::query('SELECT COUNT(*) - FROM profile_addresses - WHERE pid = {?} AND accuracy = 0' - $this->user->id()); - $page->assign('geocoding_incitation', $res->fetchOneCell()); + $page->assign('profile_merge', self::ListMergeIssues($profile)); + $page->assign('profile_incitation', $profile->is_old); + $page->assign('profile_last_update', $profile->last_change); + $page->assign('photo_incitation', !$profile->has_photo); + $page->assign('geocoding_incitation', Geocoder::countNonGeocoded($profile->id())); } public function template() @@ -81,22 +82,28 @@ class ReminderProfileUpdate extends Reminder return true; } - public static function IsCandidate(User &$user, $candidate) + private static function ListMergeIssues(Profile $profile) { - $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' - $this->user->id()); + if (Platal::globals()->merge->state != 'done') { + return null; + } + $flags = XDB::fetchOneCell('SELECT issues + FROM profile_merge_issues + WHERE pid = {?}', $profile->id()); + if (!$flags) { + return null; + } + return new PlFlagSet($flags); + } - return ($res->fetchOneCell() || !$has_photo || $is_profile_old); + public static function IsCandidate(User $user, $candidate) + { + $profile = $user->profile(); + if (!$profile) { + return false; + } + return !$profile->has_photo || $profile->is_old + || !is_null(self::ListMergeIssues($profile)); } }