Adds XSRF protection to the Carnet module.
[platal.git] / include / massmailer.inc.php
index 1ac9aea..0279948 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2007 Polytechnique.org                              *
+ *  Copyright (C) 2003-2008 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -58,7 +58,7 @@ abstract class MassMailer
         $res = XDB::query("SELECT  IF (n.short_name IS NULL, n.id, n.short_name)
                              FROM  {$this->_table} AS n
                             WHERE  n.bits != 'new' AND {$where}
-                            LIMIT  1"); 
+                            LIMIT  1");
         if ($res->numRows() != 1) {
             return null;
         }
@@ -108,7 +108,7 @@ abstract class MassMailer
     public function head($prenom = null, $nom = null, $sexe = null, $type = 'text')
     {
         if (is_null($prenom)) {
-            return $this->_head; 
+            return $this->_head;
         } else {
             $head = $this->_head;
             $head = str_replace('<cher>',   $sexe ? 'Chère' : 'Cher', $head);
@@ -133,7 +133,7 @@ abstract class MassMailer
     {
         $this->css($page);
         $page->assign('is_mail', false);
-        $page->assign('html_version', false);
+        $page->assign('mail_part', 'text');
         $page->assign('prenom', $prenom);
         $page->assign('nom', $nom);
         $page->assign('sexe', $sexe);
@@ -145,7 +145,7 @@ abstract class MassMailer
         $this->css($page);
         $page->assign('prefix', $this->_prefix . '/' . $this->id());
         $page->assign('is_mail', false);
-        $page->assign('html_version', true);
+        $page->assign('mail_part', 'html');
         $page->assign('prenom', $prenom);
         $page->assign('nom', $nom);
         $page->assign('sexe', $sexe);
@@ -183,7 +183,8 @@ abstract class MassMailer
              INNER JOIN  auth_user_quick AS q  ON(q.user_id = u.user_id)
              INNER JOIN  aliases         AS a  ON(u.user_id=a.id AND FIND_IN_SET('bestalias',a.flags))
               LEFT JOIN  emails          AS e  ON(e.uid=u.user_id AND e.flags='active')
-                  WHERE  ni.last < {?} AND ({$this->subscriptionWhere()}) AND e.email IS NOT NULL
+                  WHERE  ni.last < {?} AND ({$this->subscriptionWhere()}) AND
+                         (e.email IS NOT NULL OR FIND_IN_SET('googleapps', u.mail_storage))
                GROUP BY  u.user_id";
     }
 
@@ -204,7 +205,7 @@ abstract class MassMailer
             XDB::execute("UPDATE  {$this->_subscriptionTable}
                              SET  last = {?}
                            WHERE " . implode(' OR ', $sent), $this->_id);
-            
+
             sleep(60);
         }
     }