From 4b0cb388b3b573048f35d1050c9c459c3090b16c Mon Sep 17 00:00:00 2001 From: Vincent Zanotti Date: Tue, 2 Jun 2009 00:54:48 +0200 Subject: [PATCH] Updates the look & design of the reminder oneboxes. Signed-off-by: Vincent Zanotti --- include/reminder.inc.php | 40 ++++++++++++--------- include/reminder/ax_letter.inc.php | 6 +++- include/reminder/email_backup.inc.php | 9 +++-- include/reminder/email_warning.inc.php | 16 +++++---- include/reminder/gapps.inc.php | 6 +++- include/reminder/ml.inc.php | 25 +++++++------ include/reminder/nl.inc.php | 6 +++- include/reminder/no_redirection.inc.php | 16 +++++---- include/reminder/profile_update.inc.php | 36 +++++++++++-------- include/reminder/promotion_ml.inc.php | 10 ++++-- modules/events.php | 7 ++-- modules/reminder.php | 4 +-- templates/events/index.tpl | 6 ++-- templates/reminder/base.tpl | 42 +++++++++++++--------- templates/reminder/email_warning.tpl | 27 ++++++-------- templates/reminder/ml.tpl | 57 +++++++++++++++-------------- templates/reminder/no_redirection.tpl | 13 ++----- templates/reminder/profile_update.tpl | 63 +++++++++++---------------------- 18 files changed, 204 insertions(+), 185 deletions(-) diff --git a/include/reminder.inc.php b/include/reminder.inc.php index 5143842..a28d839 100644 --- a/include/reminder.inc.php +++ b/include/reminder.inc.php @@ -101,31 +101,37 @@ abstract class Reminder // 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; } @@ -195,7 +201,7 @@ abstract class Reminder // 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); } diff --git a/include/reminder/ax_letter.inc.php b/include/reminder/ax_letter.inc.php index 3e0cdf2..b0b112e 100644 --- a/include/reminder/ax_letter.inc.php +++ b/include/reminder/ax_letter.inc.php @@ -38,11 +38,15 @@ class ReminderAxLetter extends Reminder } } - 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) { diff --git a/include/reminder/email_backup.inc.php b/include/reminder/email_backup.inc.php index dca3b0e..cdf266e 100644 --- a/include/reminder/email_backup.inc.php +++ b/include/reminder/email_backup.inc.php @@ -25,8 +25,7 @@ class ReminderEmailBackup extends Reminder { 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(); @@ -41,12 +40,16 @@ class ReminderEmailBackup extends Reminder } } - 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) { diff --git a/include/reminder/email_warning.inc.php b/include/reminder/email_warning.inc.php index f20cdb5..1b8f901 100644 --- a/include/reminder/email_warning.inc.php +++ b/include/reminder/email_warning.inc.php @@ -28,13 +28,17 @@ class ReminderEmailWarning extends Reminder } } - 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) diff --git a/include/reminder/gapps.inc.php b/include/reminder/gapps.inc.php index aa4921d..8df4c46 100644 --- a/include/reminder/gapps.inc.php +++ b/include/reminder/gapps.inc.php @@ -39,13 +39,17 @@ class ReminderGapps extends Reminder } } - 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) { diff --git a/include/reminder/ml.inc.php b/include/reminder/ml.inc.php index 7e4b297..9732bb2 100644 --- a/include/reminder/ml.inc.php +++ b/include/reminder/ml.inc.php @@ -59,13 +59,9 @@ class ReminderMl extends Reminder } } - 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 @@ -85,12 +81,21 @@ class ReminderMl extends Reminder $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) { diff --git a/include/reminder/nl.inc.php b/include/reminder/nl.inc.php index f5d38c8..ba924c4 100644 --- a/include/reminder/nl.inc.php +++ b/include/reminder/nl.inc.php @@ -38,12 +38,16 @@ class ReminderNl extends Reminder } } - 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) { diff --git a/include/reminder/no_redirection.inc.php b/include/reminder/no_redirection.inc.php index 9555959..706bfb2 100644 --- a/include/reminder/no_redirection.inc.php +++ b/include/reminder/no_redirection.inc.php @@ -28,13 +28,17 @@ class ReminderNoRedirection extends Reminder } } - 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) diff --git a/include/reminder/profile_update.inc.php b/include/reminder/profile_update.inc.php index 5327b6c..c07e741 100644 --- a/include/reminder/profile_update.inc.php +++ b/include/reminder/profile_update.inc.php @@ -45,37 +45,45 @@ class ReminderProfileUpdate extends Reminder } } - 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, diff --git a/include/reminder/promotion_ml.inc.php b/include/reminder/promotion_ml.inc.php index aee6747..4cac8e7 100644 --- a/include/reminder/promotion_ml.inc.php +++ b/include/reminder/promotion_ml.inc.php @@ -49,13 +49,17 @@ class ReminderPromotionMl extends Reminder } } - 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) @@ -73,7 +77,7 @@ class ReminderPromotionMl extends Reminder if ($mlCount) { Reminder::MarkCandidateAsAccepted($user->id(), $candidate); } - return ($mlCount > 0); + return ($mlCount == 0); } } diff --git a/modules/events.php b/modules/events.php index 44e75b3..5ee7b81 100644 --- a/modules/events.php +++ b/modules/events.php @@ -106,10 +106,11 @@ class EventsModule extends PLModule $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 diff --git a/modules/reminder.php b/modules/reminder.php index d150f58..d35ef0c 100644 --- a/modules/reminder.php +++ b/modules/reminder.php @@ -44,8 +44,8 @@ class ReminderModule extends PLModule // 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; } diff --git a/templates/events/index.tpl b/templates/events/index.tpl index 97418f8..2ee8a68 100644 --- a/templates/events/index.tpl +++ b/templates/events/index.tpl @@ -42,10 +42,10 @@ Bienvenue {$smarty.session.prenom}{if $birthday} {/if} {if $reminder} -{$reminder|smarty:nodefaults} -{/if} - +{include file="reminder/base.tpl"} +{else} {include file="include/tips.tpl" full=true} +{/if} {foreach from=$events name=events key=category item=evenement} diff --git a/templates/reminder/base.tpl b/templates/reminder/base.tpl index 7250525..404a306 100644 --- a/templates/reminder/base.tpl +++ b/templates/reminder/base.tpl @@ -20,22 +20,32 @@ {* *} {**************************************************************************} -
- {icon name=information} Information : Titre ! - - {icon name=cross title="Cacher cette information."} - - +
+
+ + {if $reminder->warning()}{icon name=error}{else}{icon name=information}{/if} +  {$reminder->title()} + - {$text} - -
+ {if $reminder->template()} + {include file=$reminder->template()} + {else} +
+ {$reminder->text()} +
+ + {/if} +
+ {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/reminder/email_warning.tpl b/templates/reminder/email_warning.tpl index 28aa0d1..cd04b2a 100644 --- a/templates/reminder/email_warning.tpl +++ b/templates/reminder/email_warning.tpl @@ -20,22 +20,15 @@ {* *} {**************************************************************************} -
- - - {icon name=cross title="Cacher cet avertissement."} - - - {icon name=error} Des problèmes sont actuellement recontrés sur tes redirections suivantes : -
    - {foreach from=$smarty.session.mx_failures item=mail} -
  • - {$mail.mail} : - {$mail.text} -
  • - {/foreach} -
-
Gérer mes adresses de redirection
-
+Des problèmes sont actuellement recontrés sur tes redirections suivantes : + +
Gérer mes adresses de redirection
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/reminder/ml.tpl b/templates/reminder/ml.tpl index a431fe7..8a26ada 100644 --- a/templates/reminder/ml.tpl +++ b/templates/reminder/ml.tpl @@ -20,35 +20,34 @@ {* *} {**************************************************************************} - + {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/reminder/no_redirection.tpl b/templates/reminder/no_redirection.tpl index b27e0fa..a07f2ea 100644 --- a/templates/reminder/no_redirection.tpl +++ b/templates/reminder/no_redirection.tpl @@ -20,15 +20,8 @@ {* *} {**************************************************************************} -
- - - {icon name=cross title="Cacher cet avertissement."} - - - {icon name=error} Tu n'as plus de redirection valide ce qui rend ton adresse Polytechnique.org - inutilisable. Rends-toi au plus vite sur la page de - gestion des emails pour corriger ce problème. -
+Tu n'as plus de redirection valide ce qui rend ton adresse Polytechnique.org +inutilisable. Rends-toi au plus vite sur la page de +gestion des emails pour corriger ce problème. {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/reminder/profile_update.tpl b/templates/reminder/profile_update.tpl index 3cbb91e..065d949 100644 --- a/templates/reminder/profile_update.tpl +++ b/templates/reminder/profile_update.tpl @@ -20,49 +20,26 @@ {* *} {**************************************************************************} -
- - - {icon name=cross title="Cacher cet avertissement."} - - -
    - {if $profile_date} -
  • - La dernière mise à jour de ta fiche - date du {$fiche_incitation|date_format}. Il est possible qu'elle ne soit pas à jour. - Si tu souhaites la modifier, - {if $incitations_count > 1} - - {else} - - {/if} - clique ici ! -
  • - {/if} - {if $photo_incitation} -
  • - Tu n'as pas mis de photo de toi sur ta fiche, c'est dommage. Clique - {if $incitations_count > 1} - - {else} - - {/if} - ici si tu souhaites en ajouter une. -
  • - {/if} - {if $geoloc_incitation > 0} -
  • - Parmi tes adresses, il y en a {$geoloc_incitation} que nous n'avons pas pu localiser. Clique - {if $incitations_count > 1} - - {else} - - {/if} - ici pour rectifier. -
  • - {/if} -
+{if $profile_incitation} + La dernière mise à jour de ta fiche + date du {$profile_last_update|date_format}. Il est possible qu'elle ne soit pas à jour. + Si tu souhaites la modifier, + + clique ici ! +{elseif $photo_incitation} + Tu n'as pas mis de photo de toi sur ta fiche, c'est dommage. Clique + + ici 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 + + ici pour rectifier. +{/if} + + {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} -- 2.1.4