From 894c18b291b9b203d04fb2e2569d2952ae55e5ef Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Sat, 9 May 2009 23:56:07 +0200 Subject: [PATCH] Adds profile_update reminder. --- include/reminder/profile_update.inc.php | 96 +++++++++++++++++++++++++++++++++ modules/events.php | 29 +++------- templates/events/index.tpl | 30 ----------- templates/reminder/profile_update.tpl | 68 +++++++++++++++++++++++ 4 files changed, 170 insertions(+), 53 deletions(-) create mode 100644 include/reminder/profile_update.inc.php create mode 100644 templates/reminder/profile_update.tpl diff --git a/include/reminder/profile_update.inc.php b/include/reminder/profile_update.inc.php new file mode 100644 index 0000000..2852707 --- /dev/null +++ b/include/reminder/profile_update.inc.php @@ -0,0 +1,96 @@ +UpdateOnDismiss(); + break; + + case 'profile': + $this->UpdateOnDismiss(); + pl_redirect('profile/edit'); + break; + + case 'photo': + $this->UpdateOnDismiss(); + pl_redirect('photo/change'); + break; + + case 'geoloc': + $this->UpdateOnDismiss(); + pl_redirect('profile/edit/adresses'); + break; + } + } + + protected function GetDisplayText() {} + + public function Display(&$page) + { + header('Content-Type: text/html; charset=utf-8'); + $page->changeTpl('reminder/profile_update.tpl', NO_SKIN); + $page->assign('baseurl', $this->GetBaseUrl()); + $user = S::user(); + + $res = XDB::query('SELECT date < DATE_SUB(NOW(), INTERVAL 365 DAY) AS is_profile_old, + date AS profile_date, 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, $profile_date, $has_photo) = $res->fetchOneRow(); + + $profile_date = $is_profile_old ? $profile_date : null; + $page->assign('profile_update', $profile_date); + $page->assign('needs_photo', $has_photo); + + require_once 'geoloc.inc.php'; + $res = localize_addresses($user->id()); + $page->assign('geocoding_incitation', count($res)); + + $page->assign('incitations_count', + ($is_profile_old ? 1 : 0) + + ($has_photo ? 1 : 0) + + (count($res) > 0 ? 1 : 0)); + } + + public static function IsCandidate(User &$user) + { + $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); + } +} + +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +?> diff --git a/modules/events.php b/modules/events.php index c614dc6..fffd4d2 100644 --- a/modules/events.php +++ b/modules/events.php @@ -112,31 +112,14 @@ class EventsModule extends PLModule $page->assign('reminder', $new_reminder->GetDisplayAsString()); } - // Profile update (appears when profile is > 400d old), and birthday - // oneboxes. + // Wishes "Happy birthday" when required $res = XDB::query( - "SELECT date < DATE_SUB(NOW(), INTERVAL 400 DAY) AS is_profile_old, - MONTH(naissance) = MONTH(NOW()) AND DAYOFMONTH(naissance) = DAYOFMONTH(NOW()) AS is_birthday, - date AS profile_date, YEAR(NOW()) - YEAR(naissance) AS age + 'SELECT MONTH(naissance) = MONTH(NOW()) + AND DAYOFMONTH(naissance) = DAYOFMONTH(NOW()) AS is_birthday FROM auth_user_md5 - WHERE user_id = {?}", S::user()->id()); - list($is_profile_old, $is_birthday, $profile_date, $age) = $res->fetchOneRow(); - - if ($is_profile_old) { - $page->assign('fiche_incitation', $profile_date); - } - if ($is_birthday) { - $page->assign('birthday', $age); - } - - // No-photo onebox. - $res = XDB::query("SELECT COUNT(*) FROM photo WHERE uid = {?}", S::user()->id()); - $page->assign('photo_incitation', $res->fetchOneCell() == 0); - - // Geo-location onebox. - require_once 'geoloc.inc.php'; - $res = localize_addresses(S::user()->id()); - $page->assign('geoloc_incitation', count($res)); + WHERE user_id = {?}', + $user->id()); + $page->assign('birthday', $res->fetchOneCell()); // Direct link to the RSS feed, when available. if (S::rssActivated()) { diff --git a/templates/events/index.tpl b/templates/events/index.tpl index 7381314..97418f8 100644 --- a/templates/events/index.tpl +++ b/templates/events/index.tpl @@ -45,36 +45,6 @@ Bienvenue {$smarty.session.prenom}{if $birthday} {$reminder|smarty:nodefaults} {/if} -{if $fiche_incitation || $photo_incitation || ($geoloc_incitation > 0)} -
- -
-{/if} - {include file="include/tips.tpl" full=true} diff --git a/templates/reminder/profile_update.tpl b/templates/reminder/profile_update.tpl new file mode 100644 index 0000000..3cbb91e --- /dev/null +++ b/templates/reminder/profile_update.tpl @@ -0,0 +1,68 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2009 Polytechnique.org *} +{* http://opensource.polytechnique.org/ *} +{* *} +{* This program is free software; you can redistribute it and/or modify *} +{* it under the terms of the GNU General Public License as published by *} +{* the Free Software Foundation; either version 2 of the License, or *} +{* (at your option) any later version. *} +{* *} +{* This program is distributed in the hope that it will be useful, *} +{* but WITHOUT ANY WARRANTY; without even the implied warranty of *} +{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *} +{* GNU General Public License for more details. *} +{* *} +{* You should have received a copy of the GNU General Public License *} +{* along with this program; if not, write to the Free Software *} +{* Foundation, Inc., *} +{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} +{* *} +{**************************************************************************} + +
+ + + {icon name=cross title="Cacher cet avertissement."} + + + +
+ +{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} -- 2.1.4