From: Florent Bruneau Date: Sun, 25 May 2008 10:37:28 +0000 (+0200) Subject: Add a 'one-click' imap registration page. X-Git-Tag: xorg/0.9.16~8 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=2ee43273acd74ef5a3041945f82cb2aadefae685;p=platal.git Add a 'one-click' imap registration page. Signed-off-by: Florent Bruneau --- diff --git a/modules/email.php b/modules/email.php index 63cd1ab..1961dc5 100644 --- a/modules/email.php +++ b/modules/email.php @@ -33,6 +33,8 @@ class EmailModule extends PLModule 'emails/antispam/submit' => $this->make_hook('submit', AUTH_COOKIE), 'emails/test' => $this->make_hook('test', AUTH_COOKIE, 'user', NO_AUTH), + 'emails/imap/in' => $this->make_hook('imap_in', AUTH_PUBLIC), + 'admin/emails/duplicated' => $this->make_hook('duplicated', AUTH_MDP, 'admin'), 'admin/emails/watch' => $this->make_hook('duplicated', AUTH_MDP, 'admin'), 'admin/emails/lost' => $this->make_hook('lost', AUTH_MDP, 'admin'), @@ -443,6 +445,34 @@ class EmailModule extends PLModule exit; } + function handler_imap_in(&$page, $hash = null, $login = null) + { + $page->changeTpl('emails/imap_register.tpl'); + $id = null; + if (!empty($hash) || !empty($login)) { + $req = XDB::query("SELECT u.prenom, id + FROM aliases AS a + INNER JOIN newsletter_ins AS ni ON (a.id = ni.user_id) + INNER JOIN auth_user_md5 AS u ON (u.user_id = a.id) + WHERE a.alias = {?} AND ni.hash = {?}", $login, $hash); + list($prenom, $id) = $req->fetchOneRow(); + } + + require_once('emails.inc.php'); + $page->assign('ok', false); + if (S::logged() && (is_null($id) || $id == S::i('uid'))) { + $storage = new EmailStorage(S::i('uid'), 'imap'); + $storage->activate(); + $page->assign('ok', true); + $page->assign('prenom', S::v('prenom')); + } else if (!S::logged() && $id) { + $storage = new EmailStorage($id, 'imap'); + $storage->activate(); + $page->assign('ok', true); + $page->assign('prenom', $prenom); + } + } + function handler_broken(&$page, $warn = null, $email = null) { require_once 'emails.inc.php'; diff --git a/templates/emails/imap_register.tpl b/templates/emails/imap_register.tpl new file mode 100644 index 0000000..62581f3 --- /dev/null +++ b/templates/emails/imap_register.tpl @@ -0,0 +1,44 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2008 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 *} +{* *} +{**************************************************************************} + +{if $ok} +

+ Cher {$prenom}, +

+ +

+le stockage de secours de tes emails a été activé avec succès. Tu trouveras d'avantages d'informations à ce +sujet sur la page de documentation. +

+ +

+Tu peux également modifier à tout moment ton abonnement à ce service en te rendant sur la page de +gestion de tes redirections. +

+{else} +

+Une erreur s'est produite lors de ton inscription au service de stockage de secours. N'hésite pas à nous signaler le +problème en écrivant à support@polytechnique.org. +

+{/if} + +{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}