Improve safeguards for NLs : send to admins first, and notify br@ when a new NL is...
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Sun, 20 Feb 2011 01:07:24 +0000 (02:07 +0100)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Sun, 20 Feb 2011 01:33:58 +0000 (02:33 +0100)
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
configs/mails.conf
include/newsletter.inc.php
templates/newsletter/notify_scheduled.mail.tpl [new file with mode: 0644]

index 059b0d9..7d32aac 100644 (file)
@@ -71,3 +71,6 @@ replyto=registration+watch@staff.m4x.org
 from="Polytechnique.org" <validation_modification@polytechnique.org>
 cc="Polytechnique.org" <validation_modification@polytechnique.org>
 
+[newsletter_schedule_mailing]
+from="Gestion des NLs" <support@polytechnique.org>
+to=br@staff.polytechnique.org
index 6e03646..3df810f 100644 (file)
@@ -666,6 +666,14 @@ class NLIssue
                                       WHERE  id = {?}',
                                       $this->id);
             if ($success) {
+                global $globals;
+                $mailer = new PlMailer('newsletter/notify_scheduled.mail.tpl');
+                $mailer->assign('group', $this->nl->group);
+                $mailer->assign('nl_title', $this->title_mail);
+                $mailer->assign('nl_id', $this->id());
+                $mailer->assign('base', $globals->baseurl);
+                $mailer->assign('send_before', $this->send_before);
+                $mailer->send();
                 $this->refresh();
             }
             return $success;
@@ -985,7 +993,15 @@ class NLIssue
 
     // }}}
     // {{{ Mailing
-    
+
+    /** Check whether this issue is empty
+     * An issue is empty if the email has no title (or the default one), or no articles and an empty head.
+     */
+    public function isEmpty()
+    {
+        return $this->mail_title == '' || $this->mail_title == 'to be continued' || (count($this->arts == 0 && strlen($this->head) == 0));
+    }
+
     /** Retrieve the 'Send before' date, in a clean format.
      */
     public function getSendBeforeDate()
@@ -1079,7 +1095,7 @@ class NLIssue
 
         $ufc = new PFC_And($this->getRecipientsUFC(), new UFC_NLSubscribed($this->nl->id, $this->id), new UFC_HasEmailRedirect());
         $emailsCount = 0;
-        $uf = new UserFilter($ufc);
+        $uf = new UserFilter($ufc, array(new UFO_IsAdmin(), new UFO_Uid()));
         $limit = new PlLimit(self::BATCH_SIZE);
 
         while (true) {
diff --git a/templates/newsletter/notify_scheduled.mail.tpl b/templates/newsletter/notify_scheduled.mail.tpl
new file mode 100644 (file)
index 0000000..67f65c8
--- /dev/null
@@ -0,0 +1,37 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
+{*  http://opensource.polytechnique.org/                                  *}
+{*                                                                        *}
+{*  This program is free software; you can redistribute it and/or modify  *}
+{*  it under the terms of the GNU General Public License as published by  *}
+{*  the Free Software Foundation; either version 2 of the License, or     *}
+{*  (at your option) any later version.                                   *}
+{*                                                                        *}
+{*  This program is distributed in the hope that it will be useful,       *}
+{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
+{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
+{*  GNU General Public License for more details.                          *}
+{*                                                                        *}
+{*  You should have received a copy of the GNU General Public License     *}
+{*  along with this program; if not, write to the Free Software           *}
+{*  Foundation, Inc.,                                                     *}
+{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
+{*                                                                        *}
+{**************************************************************************}
+
+{config_load file="mails.conf" section="newsletter_schedule_mailing"}
+{if $mail_part eq 'head'}
+{from full=#from#}
+{to addr=#to#}
+{subject text="Validation de l'envoi d'une NL du groupe $group"}
+{elseif $mail_part eq 'text'}
+
+L'envoi d'une NL pour le groupe {$group}, "{$nl_title}", a été planifié pour le {$send_before}.
+
+Aperçu / édition :
+{$base}/newsletter/admin/edit/{$nl_id}
+
+{/if}
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}