Fix axletter promo restriction.
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Sun, 5 Sep 2010 15:16:37 +0000 (17:16 +0200)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Sun, 5 Sep 2010 15:16:37 +0000 (17:16 +0200)
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
include/massmailer.inc.php
modules/axletter/axletter.inc.php

index 269a570..c866f90 100644 (file)
@@ -195,6 +195,8 @@ abstract class MassMailer
              INNER JOIN  accounts AS a ON (ni.uid = a.uid)
               LEFT JOIN  email_options AS eo ON (eo.uid = a.uid)
               LEFT JOIN  emails   AS e ON (e.uid = a.uid AND e.flags='active')
+              LEFT JOIN  account_profiles AS ap ON (a.uid = ap.uid AND FIND_IN_SET('owner', ap.perms))
+              LEFT JOIN  profile_display AS pd ON (ap.pid = pd.pid)
                   WHERE  ni.last < {?} AND ({$this->subscriptionWhere()}) AND
                          (e.email IS NOT NULL OR FIND_IN_SET('googleapps', eo.storage))
                GROUP BY  a.uid";
index 761724c..5297ac9 100644 (file)
@@ -177,10 +177,10 @@ class AXLetter extends MassMailer
         }
         $where = array();
         if ($this->_promo_min) {
-            $where[] = "((ni.uid = 0 AND ni.promo >= {$this->_promo_min}) OR (ni.uid != 0 AND u.promo >= {$this->_promo_min}))";
+            $where[] = "((ni.uid = 0 AND ni.promo >= {$this->_promo_min}) OR (ni.uid != 0 AND pd.promo >= 'X{$this->_promo_min}'))";
         }
         if ($this->_promo_max) {
-            $where[] = "((ni.uid = 0 AND ni.promo <= {$this->_promo_max}) OR (ni.uid != 0 AND u.promo <= {$this->_promo_max}))";
+            $where[] = "((ni.uid = 0 AND ni.promo <= {$this->_promo_max}) OR (ni.uid != 0 AND pd.promo <= 'X{$this->_promo_max}'))";
         }
         if ($this->_subset) {
             require_once("emails.inc.php");