From d5524e7bd1216a4e0b8ea084f41e7e7df801deef Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Sun, 20 Feb 2011 02:07:24 +0100 Subject: [PATCH] Improve safeguards for NLs : send to admins first, and notify br@ when a new NL is scheduled MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Barrois --- configs/mails.conf | 3 +++ include/newsletter.inc.php | 20 ++++++++++++-- templates/newsletter/notify_scheduled.mail.tpl | 37 ++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 templates/newsletter/notify_scheduled.mail.tpl diff --git a/configs/mails.conf b/configs/mails.conf index 059b0d9..7d32aac 100644 --- a/configs/mails.conf +++ b/configs/mails.conf @@ -71,3 +71,6 @@ replyto=registration+watch@staff.m4x.org from="Polytechnique.org" cc="Polytechnique.org" +[newsletter_schedule_mailing] +from="Gestion des NLs" +to=br@staff.polytechnique.org diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index 6e03646..3df810f 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -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 index 0000000..67f65c8 --- /dev/null +++ b/templates/newsletter/notify_scheduled.mail.tpl @@ -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: *} -- 2.1.4