From: x2004lefloch Date: Mon, 6 Aug 2007 14:24:35 +0000 (+0000) Subject: Fix Delay between marketing attempts on same adress : the delay is now 30 days. X-Git-Tag: xorg/0.9.15~215 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=8ded5b5ec36ef278cf18a4f8dd1f588011cd39a2;p=platal.git 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 --- 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(); + } } } }