// method below).
abstract public function HandleAction($action);
- // Returns the content of the onebox reminder. Default implementation displays
- // a text and three links (yes, no, dismiss); it uses the text from method
- // GetDisplayText.
- public function Display(&$page)
+ // Displays the reminder as a standalone html snippet. It should be used
+ // when the reminder is the only output of a page.
+ public function DisplayStandalone(&$page)
{
header('Content-Type: text/html; charset=utf-8');
- $page->changeTpl('reminder/default.tpl', NO_SKIN);
- $page->assign('text', $this->GetDisplayText());
- $page->assign('baseurl', $this->GetBaseUrl());
+ $page->changeTpl('reminder/base.tpl', NO_SKIN);
+ $this->Prepare($page);
}
- // Helper for returning the content as a string, instead of using the existing
- // globale XorgPage instance.
- public function GetDisplayAsString()
+ // Prepares the display by assigning template variables.
+ public function Prepare(&$page)
{
- $page = new XorgPage();
- $this->Display($page);
- return $page->raw();
+ $page->assign_by_ref('reminder', $this);
}
- // Returns the text to display in the onebox.
- abstract protected function GetDisplayText();
+ // Returns the name of the inner template, or null if a simple text obtained
+ // from GetText should be printed.
+ public function template() { return null; }
+
+ // Returns the text to display in the onebox, or null if a
+ public function text() { return ''; }
+
+ // Returns the title of the onebox.
+ public function title() { return ''; }
+
+ // Should return true if this onebox needs to be considered as a warning and
+ // not just as a subscription offer.
+ public function warning() { return false; }
// Returns the base url for the reminder module.
- protected function GetBaseUrl()
+ public function baseurl()
{
return 'ajax/reminder/' . $this->name;
}
// the class.
private static function GetClassName($name)
{
- @include_once "reminder/$name.inc.php";
+ include_once "reminder/$name.inc.php";
$class = 'Reminder' . str_replace(' ', '', ucwords(str_replace('_', ' ', $name)));
return (class_exists($class) ? $class : null);
}
}
}
- protected function GetDisplayText()
+ public function text()
{
return "La lettre de l'AX te permet de recevoir régulièrement les
informations importantes de l'AX.";
}
+ public function title()
+ {
+ return "Inscription à la lettre de l'AX";
+ }
public static function IsCandidate(User &$user, $candidate)
{
{
if ($action == 'yes') {
require_once 'emails.inc.php';
- $user = S::user();
- $storage = new EmailStorage($user, 'imap');
+ $storage = new EmailStorage($this->user, 'imap');
$storage->activate();
$this->UpdateOnYes();
}
}
- protected function GetDisplayText()
+ public function text()
{
return "Tu peux bénéficier d'une sauvegarde des emails. Cela permet
d'avoir un accès de secours aux 30 derniers jours d'emails reçus
sur ton adresse Polytechnique.org.";
}
+ public function title()
+ {
+ return 'Sauvegarde de tes emails';
+ }
public static function IsCandidate(User &$user, $candidate)
{
}
}
- protected function GetDisplayText() {}
-
- public function Display(&$page)
+ public function template()
+ {
+ return 'reminder/email_warning.tpl';
+ }
+ public function title()
+ {
+ return "Problème avec ta redirections d'emails";
+ }
+ public function warning()
{
- header('Content-Type: text/html; charset=utf-8');
- $page->changeTpl('reminder/email_warning.tpl', NO_SKIN);
- $page->assign('baseurl', $this->GetBaseUrl());
+ return true;
}
public static function IsCandidate(User &$user, $candidate)
}
}
- protected function GetDisplayText()
+ public function text()
{
return "Polytechnique.org te fournit un compte Google Apps qui te permet
de disposer des applications web de Google (GMail, Google Calendar,
Google Docs, et bien d'autres) sur ton adresse Polytechnique.org
habituelle (en savoir plus).";
}
+ public function title()
+ {
+ return "Création d'un compte Google Apps";
+ }
public static function IsCandidate(User &$user, $candidate)
{
}
}
- protected function GetDisplayText() {}
-
- public function Display(&$page)
+ public function Prepare(&$page)
{
- header('Content-Type: text/html; charset=utf-8');
- $page->changeTpl('reminder/ml.tpl', NO_SKIN);
- $page->assign('baseurl', $this->GetBaseUrl());
+ parent::Prepare($page);
$res = XDB::iterRow("SELECT sub, domain
FROM register_subs
$page->assign_by_ref('lists', $lists);
}
+ public function template()
+ {
+ return 'reminder/ml.tpl';
+ }
+ public function title()
+ {
+ return "Inscription aux listes de diffusion";
+ }
+
public static function IsCandidate(User &$user, $candidate)
{
- $res = XDB::execute("SELECT COUNT(*) AS lists
- FROM register_subs
- WHERE uid = {?} AND type = 'list'",
- $user->id());
+ $res = XDB::query("SELECT COUNT(*) AS lists
+ FROM register_subs
+ WHERE uid = {?} AND type = 'list'",
+ $user->id());
$mlCount = $res->fetchOneCell();
if (!$mlCount) {
}
}
- protected function GetDisplayText()
+ public function text()
{
return "La lettre mensuelle de Polytechnique.org te permet de recevoir
chaque mois des informations sur les activités et nouvelles de la
communauté des X.";
}
+ public function title()
+ {
+ return "Inscription à la lettre mensuelle";
+ }
public static function IsCandidate(User &$user, $candidate)
{
}
}
- protected function GetDisplayText() {}
-
- public function Display(&$page)
+ public function template()
+ {
+ return 'reminder/no_redirection.tpl';
+ }
+ public function title()
+ {
+ return "Problème avec ta redirection d'emails";
+ }
+ public function warning()
{
- header('Content-Type: text/html; charset=utf-8');
- $page->changeTpl('reminder/no_redirection.tpl', NO_SKIN);
- $page->assign('baseurl', $this->GetBaseUrl());
+ return true;
}
public static function IsCandidate(User &$user, $candidate)
}
}
- protected function GetDisplayText() {}
-
- public function Display(&$page)
+ public function Prepare(&$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();
+ parent::Prepare($page);
$res = XDB::query('SELECT date < DATE_SUB(NOW(), INTERVAL 365 DAY) AS is_profile_old,
- date AS profile_date, p.attach AS photo
+ date AS profile_date, LENGTH(p.attach) > 0 AS photo
FROM auth_user_md5 AS u
LEFT JOIN photo AS p ON (u.user_id = p.uid)
WHERE user_id = {?}',
- $user->id());
+ $this->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);
+ $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($user->id());
+ $res = localize_addresses($this->user->id());
$page->assign('geocoding_incitation', count($res));
$page->assign('incitations_count',
($is_profile_old ? 1 : 0) +
- ($has_photo ? 1 : 0) +
+ ($has_photo ? 0 : 1) +
(count($res) > 0 ? 1 : 0));
}
+ public function template()
+ {
+ return 'reminder/profile_update.tpl';
+ }
+ public function title()
+ {
+ return "Mise à jour de ton profil";
+ }
+ public function warning()
+ {
+ return true;
+ }
+
public static function IsCandidate(User &$user, $candidate)
{
$res = XDB::query('SELECT date < DATE_SUB(NOW(), INTERVAL 365 DAY) AS is_profile_old,
}
}
- protected function GetDisplayText()
+ public function text()
{
return "La liste de diffusion de ta promotion permet de recevoir les
informations plus spécifiques de ta promotion pour pouvoir
participer plus facilement aux événements qu'elle organise. Tu
seras aussi inscrit dans le groupe de la promotion " .
- S::user()->promo() . '.';
+ $this->user->promo() . '.';
+ }
+ public function title()
+ {
+ return "Inscription à la liste de diffusion de ta promotion";
}
public static function IsCandidate(User &$user, $candidate)
if ($mlCount) {
Reminder::MarkCandidateAsAccepted($user->id(), $candidate);
}
- return ($mlCount > 0);
+ return ($mlCount == 0);
}
}
$page->addJsLink('ajax.js');
$page->assign('tips', $this->get_tips());
- require_once 'reminder.inc.php';
+ // Adds a reminder onebox to the page.
$user = S::user();
- if (($new_reminder = Reminder::GetCandidateReminder($user))) {
- $page->assign('reminder', $new_reminder->GetDisplayAsString());
+ require_once 'reminder.inc.php';
+ if (($reminder = Reminder::GetCandidateReminder($user))) {
+ $reminder->Prepare($page);
}
// Wishes "Happy birthday" when required
// displayed.
$reminder->HandleAction($action);
- if ($new_reminder = Reminder::GetCandidateReminder($user)) {
- $new_reminder->Display($page);
+ if (($new_reminder = Reminder::GetCandidateReminder($user))) {
+ $new_reminder->DisplayStandalone($page);
} else {
exit;
}
{/if}
{if $reminder}
-{$reminder|smarty:nodefaults}
-{/if}
-
+{include file="reminder/base.tpl"}
+{else}
{include file="include/tips.tpl" full=true}
+{/if}
<table class="tinybicol" id="menu-evts">
{foreach from=$events name=events key=category item=evenement}
{* *}
{**************************************************************************}
-<fieldset id="reminder" class="warnings">
- <legend>{icon name=information} Information : Titre !
- <a href="" onclick="Ajax.update_html('reminder', '{$baseurl}/dismiss')">
- {icon name=cross title="Cacher cette information."}
- </a>
- </legend>
+<div id="reminder">
+ <fieldset class="warnings">
+ <legend>
+ {if $reminder->warning()}{icon name=error}{else}{icon name=information}{/if}
+ {$reminder->title()}
+ </legend>
- {$text}
- <div class="center">
- <a href="" onclick="Ajax.update_html('reminder', '{$baseurl}/yes'); return false" style="text-decoration: none">
- {icon name=add} M'inscrire
- </a> -
- <a href="" onclick="Ajax.update_html('reminder', '{$baseurl}/no'); return false" style="text-decoration: none">
- {icon name=delete} Ne pas m'inscrire
- </a>
- </div>
-</fieldset>
+ {if $reminder->template()}
+ {include file=$reminder->template()}
+ {else}
+ <div style="margin-bottom: 0.5em">
+ {$reminder->text()}
+ </div>
+ <div class="center">
+ <a href="" onclick="Ajax.update_html('reminder', '{$reminder->baseurl()}/yes'); return false" style="text-decoration: none">
+ {icon name=add} M'inscrire
+ </a> -
+ <a href="" onclick="Ajax.update_html('reminder', '{$reminder->baseurl()}/no'); return false" style="text-decoration: none">
+ {icon name=delete} Ne pas m'inscrire
+ </a> -
+ <a href="" onclick="Ajax.update_html('reminder', '{$reminder->baseurl()}/dismiss'); return false" style="text-decoration: none">
+ {icon name=cross} Décider plus tard
+ </a>
+ </div>
+ {/if}
+ </fieldset>
+</div>
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
{* *}
{**************************************************************************}
-<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>
- {icon name=error} Des problèmes sont actuellement recontrés sur tes redirections suivantes :
- <ul>
- {foreach from=$smarty.session.mx_failures item=mail}
- <li>
- <span class="erreur">{$mail.mail}</span> :
- <span class="explication">{$mail.text}</span>
- </li>
- {/foreach}
- </ul>
- <div style="text-align: center"><a href="emails/redirect">Gérer mes adresses de redirection</a></div>
-</div>
+Des problèmes sont actuellement recontrés sur tes redirections suivantes :
+<ul>
+ {foreach from=$smarty.session.mx_failures item=mail}
+ <li>
+ <span class="erreur">{$mail.mail}</span> :
+ <span class="explication">{$mail.text}</span>
+ </li>
+ {/foreach}
+</ul>
+<div style="text-align: center"><a href="emails/redirect">Gérer mes adresses de redirection</a></div>
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
{* *}
{**************************************************************************}
-<div class="warnings reminder">
- <span style="float: right">
- <a href="" onclick="Ajax.update_html('reminder', '{$baseurl}/dismiss')">
- {icon name=cross title="Cacher cet avertissement."}
+<form action="{$reminder->baseurl()}/suscribe" method="post">
+ {xsrf_token_field}
+ Des camarades souhaitent que tu t'inscrives aux listes suivantes :
+ <dl>
+ {foreach from=$lists key=list item=details}
+ <dt>
+ <label>
+ <input type='checkbox' value='1' checked="checked" name="sub_ml[{$list}]" />
+ {$list}* : {$details.desc}
+ </label>
+ </dt>
+ {if $details.info}
+ <dd>
+ {$details.info|nl2br}
+ </dd>
+ {/if}
+ {/foreach}
+ </dl>
+
+ <div class="center">
+ <input type="submit" value="M'inscrire aux listes" /> -
+ <a href="" onclick="Ajax.update_html('reminder', '{$reminder->baseurl()}/no'); return false" style="text-decoration: none">
+ {icon name=delete} Ne pas m'inscrire
+ </a> -
+ <a href="" onclick="Ajax.update_html('reminder', '{$reminder->baseurl()}/dismiss'); return false" style="text-decoration: none">
+ {icon name=cross} Décider plus tard
</a>
- </span>
- <form action="{$baseurl}/suscribe" method="post">
- {xsrf_token_field}
- Des camarades souhaitent que tu t'inscrives aux listes suivantes :
- <dl>
- {foreach from=$lists key=list item=details}
- <dt>
- <label>
- <input type='checkbox' value='1' checked="checked" name="sub_ml[{$list}]" />
- {$list}* : {$details.desc}
- </label>
- </dt>
- {if $details.info}
- <dd>
- {$details.info|nl2br}
- </dd>
- {/if}
- {/foreach}
- </dl>
- <input type="submit" value="M'inscrire aux listes choisies." />
- </form>
- [<a href="" onclick="Ajax.update_html('reminder', '{$baseurl}/no')">
- {icon name=delete} Ne pas m'inscrire à ces listes de diffusion.
- </a>]
-</div>
+ </div>
+</form>
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
{* *}
{**************************************************************************}
-<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>
- {icon name=error} Tu n'as plus de redirection valide ce qui rend ton adresse Polytechnique.org
- inutilisable. Rends-toi au plus vite sur <a href="emails/redirect">la page de
- gestion des emails</a> pour corriger ce problème.
-</div>
+Tu n'as plus de redirection valide ce qui rend ton adresse Polytechnique.org
+inutilisable. Rends-toi au plus vite sur <a href="emails/redirect">la page de
+gestion des emails</a> pour corriger ce problème.
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
{* *}
{**************************************************************************}
-<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>
+{if $profile_incitation}
+ La dernière mise à jour de ta <a href="profile/{$smarty.session.hruid}" class="popup2">fiche</a>
+ date du {$profile_last_update|date_format}. Il est possible qu'elle ne soit pas à jour.
+ Si tu souhaites la modifier,
+ <a href="" onclick="Ajax.update_html('reminder', '{$reminder->baseurl()}/profile'); return false" style="text-decoration: none">
+ clique ici !</a>
+{elseif $photo_incitation}
+ Tu n'as pas mis de photo de toi sur ta fiche, c'est dommage. Clique
+ <a href="" onclick="Ajax.update_html('reminder', '{$reminder->baseurl()}/photo'); return false" style="text-decoration: none">
+ ici</a> si tu souhaites en ajouter une.
+{elseif $geocoding_incitation > 0}
+ Parmi tes adresses, il y en a {$geocoding_incitation} que nous n'avons pas pu localiser. Clique
+ <a href="" onclick="Ajax.update_html('reminder', '{$reminder->baseurl()}/geoloc'); return false" style="text-decoration: none">
+ ici</a> pour rectifier.
+{/if}
+
+<div class="right">
+ <a href="" onclick="Ajax.update_html('reminder', '{$reminder->baseurl()}/dismiss'); return false" style="text-decoration: none">
+ {icon name=cross} Mettre à jour plus tard
+ </a>
</div>
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}