From 8ded5b5ec36ef278cf18a4f8dd1f588011cd39a2 Mon Sep 17 00:00:00 2001 From: x2004lefloch Date: Mon, 6 Aug 2007 14:24:35 +0000 Subject: [PATCH] Fix Delay between marketing attempts on same adress : the delay is now 30 days. git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1909 839d8a87-29fc-0310-9880-83ba4fa771e5 --- include/marketing.inc.php | 7 +++++-- modules/marketing.php | 19 ++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/include/marketing.inc.php b/include/marketing.inc.php index a49b4aa..cbbd43a 100644 --- a/include/marketing.inc.php +++ b/include/marketing.inc.php @@ -168,11 +168,14 @@ class Marketing return $array; } - static public function get($uid, $email) + static public function get($uid, $email, $recentOnly = false) { $res = XDB::query("SELECT uid, email, message, message_data, type, sender FROM register_marketing - WHERE uid = {?} AND email = {?}", $uid, $email); + WHERE uid = {?} + AND email = {?}".( + $recentOnly ? ' AND DATEDIFF(NOW(), last) < 30' : ''), $uid, $email); + if ($res->numRows() == 0) { return null; } diff --git a/modules/marketing.php b/modules/marketing.php index 70d0c12..1b62a06 100644 --- a/modules/marketing.php +++ b/modules/marketing.php @@ -261,16 +261,21 @@ class MarketingModule extends PLModule if (Post::has('valide')) { require_once('xorg.misc.inc.php'); $email = trim(Post::v('mail')); - $market = Marketing::get($uid, $email); + if (!isvalid_email_redirection($email)) { $page->trig("Email invalide !"); - } elseif ($market) { - $page->assign('already', true); } else { - $page->assign('ok', true); - check_email($email, "Une adresse surveillée est proposée au marketing par " . S::v('forlife')); - $market = new Marketing($uid, $email, 'default', null, Post::v('origine'), S::v('uid')); - $market->add(); + // On cherche les marketings précédents sur cette adresse + // email, en se restreignant au dernier mois + + if (Marketing::get($uid, $email, true)) { + $page->assign('already', true); + } else { + $page->assign('ok', true); + check_email($email, "Une adresse surveillée est proposée au marketing par " . S::v('forlife')); + $market = new Marketing($uid, $email, 'default', null, Post::v('origine'), S::v('uid')); + $market->add(); + } } } } -- 2.1.4