Add UFC_MarketingHash.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 28 Feb 2010 21:36:26 +0000 (22:36 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 28 Feb 2010 21:36:26 +0000 (22:36 +0100)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
classes/userfilter.php

index c76b93a..5d07eb0 100644 (file)
@@ -1309,6 +1309,25 @@ class UFC_WatchContact extends UFC_Contact
 }
 // }}}
 
+// {{{ class UFC_MarketingHash
+/** Filters users using the hash generated
+ * to send marketing emails to him.
+ */
+class UFC_MarketingHash implements UserFilterCondition
+{
+    private $hash;
+
+    public function __construct($hash)
+    {
+        $this->hash = $hash;
+    }
+
+    public function buildCondition(PlFilter &$uf)
+    {
+        $table = $uf->addMarketingHash();
+        return XDB::format('rm.hash = {?}', $this->hash);
+    }
+}
 
 /******************
  * ORDERS
@@ -2555,6 +2574,25 @@ class UserFilter extends PlFilter
         }
         return $joins;
     }
+
+
+    /** MARKETING
+     */
+    private $with_rm;
+    public function addMarketingHash()
+    {
+        $this->requireAccounts();
+        $this->with_rm = true;
+    }
+
+    protected function marketingJoins()
+    {
+        if ($this->with_rm) {
+            return array('rm' => new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'register_marketing', '$ME.uid = $UID'));
+        } else {
+            return array();
+        }
+    }
 }
 // }}}