Backports
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Thu, 1 Feb 2007 10:34:44 +0000 (10:34 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Thu, 1 Feb 2007 10:34:44 +0000 (10:34 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1456 839d8a87-29fc-0310-9880-83ba4fa771e5

classes/plmailer.php
include/massmailer.inc.php
modules/lists.php

index 9468fa3..5d38bb2 100644 (file)
@@ -28,11 +28,10 @@ class PlMail extends Smarty
     private $tpl;
     private $mailer = null;
 
-    function __construct(&$mailer, $tpl)
+    function __construct($tpl)
     {
         global $globals;
         $this->tpl           = $tpl;
-        $this->mailer       =& $mailer;
         $this->caching       = false;
         $this->compile_check = true;
 
@@ -50,6 +49,16 @@ class PlMail extends Smarty
         $this->register_function('add_header', Array($this, 'addHeader'));
     }
 
+    public static function &get(&$mailer, $tpl)
+    {
+        static $plmail;
+        if (!isset($plmail) || $plmail->tpl != $tpl) {
+            $plmail = new PlMail($tpl);
+        }
+        $plmail->mailer =& $mailer;
+        return $plmail;
+    }
+
     public function run($html)
     {
         $this->assign('html_version', $html);
@@ -146,7 +155,7 @@ class PlMailer extends Mail_Mime {
         $this->Mail_Mime("\n");
         $this->mail = @Mail::factory('sendmail', Array('sendmail_args' => '-oi'));
         if (!is_null($tpl)) {
-            $this->page = new PlMail($this, $tpl);
+            $this->page =& PlMail::get($this, $tpl);
         }
     }
 
index 79b0fa0..77a38b2 100644 (file)
@@ -121,7 +121,8 @@ abstract class MassMailer
 
     protected function getAllRecipients()
     {
-        return  "SELECT  u.user_id, a.alias,
+        global $globals;
+        return  "SELECT  u.user_id, CONCAT(a.alias, '@{$globals->mail->domain}'),
                          u.prenom, IF(u.nom_usage='', u.nom, u.nom_usage),
                          FIND_IN_SET('femme', u.flags),
                          q.core_mail_fmt AS pref, 0 AS hash
@@ -151,6 +152,7 @@ abstract class MassMailer
             XDB::execute("UPDATE  {$this->subscriptionTable()}
                              SET  last = {?}
                            WHERE " . implode(' OR ', $sent), $this->_id);
+            
             sleep(60);
         }
     }
index 246ccd7..72e3a1f 100644 (file)
@@ -224,6 +224,16 @@ class ListsModule extends PLModule
         }
     }
 
+    function changeTpl($tpl)
+    {
+        if (!empty($GLOBALS['IS_XNET_SITE'])) {
+            new_group_open_page($tpl);
+        } else {
+            global $page;
+            $page->changeTpl($tpl);
+        }
+    }
+
     function handler_members(&$page, $liste = null)
     {
         if (is_null($liste)) {
@@ -232,7 +242,7 @@ class ListsModule extends PLModule
 
         $this->prepare_client($page);
 
-        $page->changeTpl('lists/members.tpl');
+        $this->changeTpl('lists/members.tpl');
 
         if (Get::has('del')) {
             $this->client->unsubscribe($liste);
@@ -291,7 +301,7 @@ class ListsModule extends PLModule
 
         $this->prepare_client($page);
 
-        $page->changeTpl('lists/trombi.tpl');
+        $this->changeTpl('lists/trombi.tpl');
 
         if (Get::has('del')) {
             $this->client->unsubscribe($liste);
@@ -327,7 +337,7 @@ class ListsModule extends PLModule
 
         $domain = $this->prepare_client($page);
 
-        $page->changeTpl('lists/archives.tpl');
+        $this->changeTpl('lists/archives.tpl');
 
         if (list($det) = $this->client->get_members($liste)) {
             if (substr($liste,0,5) != 'promo' && ($det['ins'] || $det['priv'])
@@ -427,7 +437,7 @@ class ListsModule extends PLModule
 
         $domain = $this->prepare_client($page);
 
-        $page->changeTpl('lists/moderate.tpl');
+        $this->changeTpl('lists/moderate.tpl');
 
         $page->register_modifier('hdc', 'list_header_decode');
 
@@ -461,7 +471,7 @@ class ListsModule extends PLModule
                 $page->assign('msg', $msg);
 
                 $page->addCssLink('banana.css');
-                $page->changeTpl('lists/moderate_mail.tpl');
+                $this->changeTpl('lists/moderate_mail.tpl');
                 $page->assign_by_ref('mail', $res);
                 return;
             }
@@ -471,7 +481,7 @@ class ListsModule extends PLModule
             if (list($subs,$mails) = $this->client->get_pending_ops($liste)) {
                 foreach($subs as $user) {
                     if ($user['id'] == Env::v('sid')) {
-                        $page->changeTpl('lists/moderate_sub.tpl');
+                        $this->changeTpl('lists/moderate_sub.tpl');
                         $page->assign('del_user', $user);
                         return;
                     }
@@ -501,7 +511,7 @@ class ListsModule extends PLModule
 
         $this->prepare_client($page);
 
-        $page->changeTpl('lists/admin.tpl');
+        $this->changeTpl('lists/admin.tpl');
 
         if (Env::has('add_member')) {
             require_once('user.func.inc.php');
@@ -569,7 +579,7 @@ class ListsModule extends PLModule
 
         $this->prepare_client($page);
 
-        $page->changeTpl('lists/options.tpl');
+        $this->changeTpl('lists/options.tpl');
 
         if (Post::has('submit')) {
             $values = $_POST;
@@ -630,7 +640,7 @@ class ListsModule extends PLModule
             $type   = 'list';
         }
 
-        $page->changeTpl('lists/delete.tpl');
+        $this->changeTpl('lists/delete.tpl');
         if (Post::v('valid') == 'OUI') {
             if ($this->client->delete_list($liste, Post::b('del_archive'))) {
                 foreach (array('', '-owner', '-admin', '-bounces') as $app) {
@@ -661,7 +671,7 @@ class ListsModule extends PLModule
 
         $this->prepare_client($page);
 
-        $page->changeTpl('lists/soptions.tpl');
+        $this->changeTpl('lists/soptions.tpl');
 
         if (Post::has('submit')) {
             $values = $_POST;
@@ -687,7 +697,7 @@ class ListsModule extends PLModule
 
         $this->prepare_client($page);
 
-        $page->changeTpl('lists/check.tpl');
+        $this->changeTpl('lists/check.tpl');
 
         if (Post::has('correct')) {
             $this->client->check_options($liste, true);
@@ -702,7 +712,7 @@ class ListsModule extends PLModule
     }
 
     function handler_admin_all(&$page) {
-        $page->changeTpl('lists/admin_all.tpl');
+        $this->changeTpl('lists/admin_all.tpl');
         $page->assign('xorg_title','Polytechnique.org - Administration - Mailing lists');
 
         $client = new MMList(S::v('uid'), S::v('password'));