From 4e25428d4d53f5e53332a5969ad002b4ebd397ad Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Fri, 19 Jan 2007 21:57:29 +0000 Subject: [PATCH] Implements promo limits git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1364 839d8a87-29fc-0310-9880-83ba4fa771e5 --- include/massmailer.inc.php | 2 +- modules/axletter/axletter.inc.php | 15 ++++++++++++-- templates/axletter/letter.tpl | 4 ++-- templates/axletter/unsubscribe.tpl | 41 ++++++++++++++++++++++++++++++++++++++ upgrade/0.9.13/04_axletter.sql | 1 + 5 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 templates/axletter/unsubscribe.tpl diff --git a/include/massmailer.inc.php b/include/massmailer.inc.php index 02a93a8..79b0fa0 100644 --- a/include/massmailer.inc.php +++ b/include/massmailer.inc.php @@ -141,7 +141,7 @@ abstract class MassMailer while (true) { $res = XDB::iterRow($query, $this->_id, 60); if (!$res->total()) { - exit; + return; } $sent = array(); while (list($uid, $bestalias, $prenom, $nom, $sexe, $fmt, $hash) = $res->next()) { diff --git a/modules/axletter/axletter.inc.php b/modules/axletter/axletter.inc.php index 9aa8cb6..0f16c36 100644 --- a/modules/axletter/axletter.inc.php +++ b/modules/axletter/axletter.inc.php @@ -107,7 +107,8 @@ class AXLetter extends MassMailer LEFT JOIN auth_user_quick AS q ON(q.user_id = u.user_id) LEFT JOIN aliases AS a ON(u.user_id=a.id AND FIND_IN_SET('bestalias',a.flags)) LEFT JOIN emails AS e ON(e.uid=u.user_id AND e.flags='active') - WHERE ni.last < {?} AND (e.email IS NOT NULL OR ni.user_id = 0) + WHERE ni.last < {?} AND {$this->subscriptionWhere()} + AND (e.email IS NOT NULL OR ni.user_id = 0) GROUP BY u.user_id"; } @@ -163,7 +164,17 @@ class AXLetter extends MassMailer protected function subscriptionWhere() { - return 'ni.last'; + if (!$this->_promo_min && !$this->_promo_max) { + return '1'; + } + $where = array(); + if ($this->_promo_min) { + $where[] = "((ni.user_id = 0 AND ni.promo >= {$this->_promo_min}) OR (ni.user_id != 0 AND u.promo >= {$this->_promo_min}))"; + } + if ($this->_promo_max) { + $where[] = "((ni.user_id = 0 AND ni.promo <= {$this->_promo_max}) OR (ni.user_id != 0 AND u.promo <= {$this->_promo_max}))"; + } + return implode(' AND ', $where); } static public function awaiting() diff --git a/templates/axletter/letter.tpl b/templates/axletter/letter.tpl index 7e19cc8..c9f25d0 100644 --- a/templates/axletter/letter.tpl +++ b/templates/axletter/letter.tpl @@ -44,7 +44,7 @@ Cette lettre est envoyée par l'AX grâce aux outils de Polytechnique.org. archives : [https://www.polytechnique.org/ax] -ne plus recevoir : [https://www.polytechnique.org/ax/out] +ne plus recevoir : [https://www.polytechnique.org/ax/out{if $hash}/{$hash}{/if}] {if !$is_mail} @@ -77,7 +77,7 @@ ne plus recevoir : [https://www.polytechnique.org/ax/out]
[archives | - ne plus recevoir] + ne plus recevoir]
{if $is_mail} diff --git a/templates/axletter/unsubscribe.tpl b/templates/axletter/unsubscribe.tpl new file mode 100644 index 0000000..3407308 --- /dev/null +++ b/templates/axletter/unsubscribe.tpl @@ -0,0 +1,41 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2006 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 *} +{* *} +{**************************************************************************} + +

Désinscription des envois de l'AX

+ +{if $success} +

+ Votre inscription aux envois exceptionnels de l'AX a été réalisée avec + succès. Si vous désirez vous réinscrire, merci de contacter + l'AX. Vous pouvez également + le faire en vous inscrivant à Polytechnique.org (pour + les X uniquement). +

+{else} +

+ Votre inscription aux envois de l'AX n'a pu être résiliée. Merci de contacter + au plus vite l'AX pour faire + part de ce problème. +

+{/if} + +{* vim:set et sw=2 sts=2 sws=2: *} diff --git a/upgrade/0.9.13/04_axletter.sql b/upgrade/0.9.13/04_axletter.sql index 4c14495..492e64e 100644 --- a/upgrade/0.9.13/04_axletter.sql +++ b/upgrade/0.9.13/04_axletter.sql @@ -20,6 +20,7 @@ CREATE TABLE axletter_ins ( flag set('femme') default '', prenom varchar(32) default NULL, nom varchar(255) default NULL, + promo smallint(4) default 0, last int(11) NOT NULL default 0, hash varchar(32) default NULL, -- 2.1.4