public $send_before; // Date at which issue should be sent
public $head; // Foreword of the issue (or body for letters with no articles)
public $signature; // Signature of the letter
+ public $reply_to; // Adress to reply to the message (can be empty)
public $arts = array(); // Articles of the issue
const BATCH_SIZE = 60; // Number of emails to send every minute.
{
// Load this issue
$res = XDB::query('SELECT nlid, short_name, date, send_before, state, sufb_json,
- title, mail_title, head, signature
+ title, mail_title, head, signature, reply_to
FROM newsletter_issues
WHERE id = {?}',
$id);
$this->title_mail = $issue['mail_title'];
$this->head = $issue['head'];
$this->signature = $issue['signature'];
+ $this->reply_to = $issue['reply_to'];
$this->sufb = $this->importJSonStoredUFB($issue['sufb_json']);
if ($fetch_articles) {
// }}}
// {{{ Edition, articles
+ const ERROR_INVALID_REPLY_TO = 'invalid_reply_to';
const ERROR_INVALID_SHORTNAME = 'invalid_shortname';
const ERROR_INVALID_UFC = 'invalid_ufc';
const ERROR_TOO_LONG_UFC = 'too_long_ufc';
'signature' => $this->signature,
);
+ if (!empty($this->reply_to) && !isvalid_email($this->reply_to)) {
+ $errors[] = self::ERROR_INVALID_REPLY_TO ;
+ } else {
+ $fields['reply_to'] = $this->reply_to;
+ }
+
if ($this->isEditable()) {
$fields['date'] = $this->date;
if (!preg_match('/^[-a-z0-9]+$/i', $this->shortname) || is_numeric($this->shortname)) {
$mailer->assign('user', $user);
$mailer->assign('prefix', null);
$mailer->assign('hash', $hash);
+ if (!empty($this->reply_to)) {
+ $mailer->addHeader('Reply-To', $this->reply_to);
+ }
$mailer->sendTo($user);
}
// Convert NLIssue error messages to human-readable errors
$error_msgs = array(
+ NLIssue::ERROR_INVALID_REPLY_TO => "L'adresse de réponse est invalide.",
NLIssue::ERROR_INVALID_SHORTNAME => "Le nom court est invalide ou vide.",
NLIssue::ERROR_INVALID_UFC => "Le filtre des destinataires est invalide.",
NLIssue::ERROR_TOO_LONG_UFC => "Le nombre de matricules AX renseigné est trop élevé.",
$issue->title_mail = Post::s('title_mail');
$issue->head = Post::s('head');
$issue->signature = Post::s('signature');
+ $issue->reply_to = Post::s('reply_to');
if ($issue->isEditable()) {
// Date and shortname may only be modified for pending NLs, otherwise all links get broken.