--- /dev/null
+<?php
+/***************************************************************************
+ * 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 *
+ ***************************************************************************/
+
+class ReminderProfileUpdate extends Reminder
+{
+ public function HandleAction($action)
+ {
+ switch ($action) {
+ case 'dismiss':
+ $this->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:
+?>
$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()) {
{$reminder|smarty:nodefaults}
{/if}
-{if $fiche_incitation || $photo_incitation || ($geoloc_incitation > 0)}
-<div class="warnings">
- <ul>
-{if $fiche_incitation}
- <li>
- La dernière mise à jour de ta
- <a href="profile/{$smarty.session.hruid}" class="popup2">fiche</a>
- date du {$fiche_incitation|date_format}.
- Il est possible qu'elle ne soit pas à jour.
- Si tu souhaites la modifier, <a href="profile/edit">clique ici !</a>
- </li>
-{/if}
-
-{if $photo_incitation}
- <li>
- Tu n'as pas mis de photo de toi sur ta fiche, c'est dommage.
- Clique <a href="photo/change">ici</a> si tu souhaites en ajouter une.
- </li>
-{/if}
-
-{if $geoloc_incitation > 0}
- <li>
- Parmi tes adresses, il y en a {$geoloc_incitation} que nous n'avons pas pu localiser.
- Clique <a href="profile/edit/adresses">ici</a> pour rectifier.
- </li>
-{/if}
- </ul>
-</div>
-{/if}
-
{include file="include/tips.tpl" full=true}
<table class="tinybicol" id="menu-evts">
--- /dev/null
+{**************************************************************************}
+{* *}
+{* 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 *}
+{* *}
+{**************************************************************************}
+
+<div class="warnings reminder">
+ <span style="float: right">
+ <a href="" onclick="Ajax.update_html('reminder', '{$baseurl}/dismiss')">
+ {icon name=cross title="Cacher cet avertissement."}
+ </a>
+ </span>
+ <ul>
+ {if $profile_date}
+ <li>
+ La dernière mise à jour de ta <a href="profile/{$smarty.session.hruid}" class="popup2">fiche</a>
+ date du {$fiche_incitation|date_format}. Il est possible qu'elle ne soit pas à jour.
+ Si tu souhaites la modifier,
+ {if $incitations_count > 1}
+ <a href="profile/edit">
+ {else}
+ <a href="" onclick="Ajax.update_html('reminder', '{$baseurl}/profile')">
+ {/if}
+ clique ici !</a>
+ </li>
+ {/if}
+ {if $photo_incitation}
+ <li>
+ Tu n'as pas mis de photo de toi sur ta fiche, c'est dommage. Clique
+ {if $incitations_count > 1}
+ <a href="photo/change">
+ {else}
+ <a href="" onclick="Ajax.update_html('reminder', '{$baseurl}/photo')">
+ {/if}
+ ici</a> si tu souhaites en ajouter une.
+ </li>
+ {/if}
+ {if $geoloc_incitation > 0}
+ <li>
+ Parmi tes adresses, il y en a {$geoloc_incitation} que nous n'avons pas pu localiser. Clique
+ {if $incitations_count > 1}
+ <a href="profile/edit/adresses">
+ {else}
+ <a href="" onclick="Ajax.update_html('reminder', '{$baseurl}/geoloc')">
+ {/if}
+ ici</a> pour rectifier.
+ </li>
+ {/if}
+ </ul>
+</div>
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}