Adds UFC_HasValidEmail (Closes #1402)
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Sat, 5 Mar 2011 23:52:11 +0000 (00:52 +0100)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Sat, 5 Mar 2011 23:52:11 +0000 (00:52 +0100)
* Use it for Newsletters
* Make it exportable, as well as UFC_HasEmailRedirect.

Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
classes/userfilter/conditions.inc.php
include/newsletter.inc.php

index ed9c898..b8cc437 100644 (file)
@@ -173,6 +173,8 @@ abstract class UserFilterCondition implements PlFilterCondition
             break;
 
           case 'has_profile':
+          case 'has_email_redirect':
+          case 'has_valid_email':
             $class = 'ufc_' . str_replace('_', '', $type);
             $cond = new $class();
             break;
@@ -331,7 +333,7 @@ class UFC_Hrpid extends UserFilterCondition
 }
 // }}}
 // {{{ class UFC_HasEmailRedirect
-/** Filters users, keeping only those with a valid email redirection.
+/** Filters users, keeping only those with a valid email redirection (only X.org accounts).
  */
 class UFC_HasEmailRedirect extends UserFilterCondition
 {
@@ -340,6 +342,31 @@ class UFC_HasEmailRedirect extends UserFilterCondition
         $sub_redirect = $uf->addEmailRedirectFilter();
         return 'ra' . $sub_redirect . '.flags = \'active\'';
     }
+
+    public function export()
+    {
+        $export = $this->buildExport('has_email_redirect');
+        return $export;
+    }
+}
+// }}}
+// {{{ class UFC_HasValidEmail
+/** Filters users, keeping only those with a valid email address (all accounts).
+ */
+class UFC_HasValidEmail extends UserFilterCondition
+{
+    public function buildCondition(PlFilter $uf)
+    {
+        $sub_redirect = $uf->addEmailRedirectFilter();
+        $uf->requireAccounts();
+        return 'ra' . $sub_redirect . '.flags = \'active\' OR a.email IS NOT NULL';
+    }
+
+    public function export()
+    {
+        $export = $this->buildExport('has_valid_email');
+        return $export;
+    }
 }
 // }}}
 // {{{ class UFC_Ip
index b8c248e..667099c 100644 (file)
@@ -1090,7 +1090,7 @@ class NLIssue
                        WHERE  id = {?}',
                        $this->id);
 
-        $ufc = new PFC_And($this->getRecipientsUFC(), new UFC_NLSubscribed($this->nl->id, $this->id), new UFC_HasEmailRedirect());
+        $ufc = new PFC_And($this->getRecipientsUFC(), new UFC_NLSubscribed($this->nl->id, $this->id), new UFC_HasValidEmail());
         $emailsCount = 0;
         $uf = new UserFilter($ufc, array(new UFO_IsAdmin(), new UFO_Uid()));
         $limit = new PlLimit(self::BATCH_SIZE);