require_once 'newsletter.inc.php';
ini_set('memory_limit', '128M');
-$nls = NewsLetter::getIssuesToSend();
-foreach ($nls as $nl) {
- echo "Envoi de la lettre \"{$nl->title()}\" (Groupe {$nl->group})\n\n";
- echo ' ' . date("H:i:s") . " -> début de l'envoi\n";
- $emailsCount = $nl->sendToAll();
- echo ' ' . date("H:i:s") . " -> fin de l'envoi\n\n";
- echo $emailsCount . " emails ont été envoyés lors de cet envoi.\n\n";
+$issues = NewsLetter::getIssuesToSend();
+foreach ($issues as $issue) {
+ if ($issue->isEmpty()) {
+ echo "Lettre \"{$issue->title()}\" (Groupe {$issue->nl->group}) ignorée car vide.";
+ } else {
+ echo "Envoi de la lettre \"{$issue->title()}\" (Groupe {$issue->nl->group})\n\n";
+ echo ' ' . date("H:i:s") . " -> début de l'envoi\n";
+ $emailsCount = $issue->sendToAll();
+ echo ' ' . date("H:i:s") . " -> fin de l'envoi\n\n";
+ echo $emailsCount . " emails ont été envoyés lors de cet envoi.\n\n";
+ }
}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
$cond = new $class($values);
break;
+ case 'school_id':
+ $values = $export->v('values', array());
+ $school_type = $export->s('school_type');
+ $cond = new UFC_SchoolId($school_type, $values);
+ break;
+
case 'has_profile':
$class = 'ufc_' . str_replace('_', '', $type);
$cond = new $class();
}
return XDB::format('p.' . $type . '_id IN {?}', $ids);
}
+
+ public function export()
+ {
+ $export = $this->buildExport('school_id');
+ $export['school_type'] = $this->type;
+ $export['values'] = $this->ids;
+ return $export;
+ }
}
// }}}
// {{{ class UFC_EducationSchool
case 'hruid':
case 'pid':
case 'hrpid':
+ case 'is_admin':
$class = 'UFO_' . str_replace('_', '', $type);
return new $class($desc);
}
}
// }}}
+// {{{ class UFO_IsAdmin
+/** Sorts users, putting admins first
+ */
+class UFO_IsAdmin extends PlFilterOrder
+{
+ protected function getSortTokens(PlFilter $uf)
+ {
+ $uf->requireAccounts();
+ return 'a.is_admin';
+ }
+
+ public function export()
+ {
+ return $this->buildExport('is_admin');
+ }
+}
+// }}}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
?>
[xnet_notification]
from="Polytechnique.org" <contact@polytechnique.org>
+[newsletter_schedule_mailing]
+from="Gestion des NLs" <support@polytechnique.org>
+to=br@staff.polytechnique.org
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;
{
if ($this->state == self::STATE_PENDING) {
$success = XDB::execute('UPDATE newsletter_issues
- SET send_before = NULL, state = \'new\'
+ SET state = \'new\'
WHERE id = {?}', $this->id);
if ($success) {
$this->refresh();
// }}}
// {{{ 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->title_mail == '' || $this->title_mail == 'to be continued' || (count($this->arts) == 0 && strlen($this->head) == 0);
+ }
+
/** Retrieve the 'Send before' date, in a clean format.
*/
public function getSendBeforeDate()
$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) {
@include_once("$FarmD/cookbook/e-protect.php");
include_once($FarmD.'/scripts/xlpage-utf-8.php');
-ResolvePageName();
+$pagename = ResolvePageName($pagename);
if ($action == 'rss' || $action == 'atom' || $action == 'rdf' || $action == 'dc') {
$FmtPV['$MarkupExcerpt'] = '$page["text"]';
directory_name, short_name, sort_name, promo)
VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
$pid, $infos[1], $fullName, $fullName, $directoryName, $fullName, $directoryName, $promo);
- XDB::execute('INSERT INTO profile_education (pid, eduid, degreeid, entry_year, grad_year, flags)
- VALUES ({?}, {?}, {?}, {?}, {?}, {?})',
- $pid, $eduSchools[Profile::EDU_X], $degreeid, $entry_year, $grad_year, 'primary');
+ XDB::execute('INSERT INTO profile_education (id, pid, eduid, degreeid, entry_year, grad_year, flags)
+ VALUES (100, {?}, {?}, {?}, {?}, {?}, \'primary\')',
+ $pid, $eduSchools[Profile::EDU_X], $degreeid, $entry_year, $grad_year);
XDB::execute('INSERT INTO accounts (hruid, type, is_admin, state, full_name, directory_name, display_name, sex)
VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
$infos['hrid'], $type, 0, 'pending', $fullName, $directoryName, $infos[1], $sex);
return PL_NOT_FOUND;
}
- if($new) {
+ if ($new == 'new') {
$id = $nl->createPending();
pl_redirect($nl->adminPrefix() . '/edit/' . $id);
}
);
// Update the current issue
- if($aid == 'update') {
+ if($aid == 'update' && Post::has('submit')) {
// Save common fields
$issue->title = Post::s('title');
$this->search_names = array();
foreach ($value as &$sn) {
$sn['name'] = trim($sn['name']);
- if (S::user()->isMe($this->owner) && ($sn['type'] == 'firstname' || $sn['type'] == 'lastname')) {
+ if (S::user()->isMe($page->owner) && ($sn['type'] == 'firstname' || $sn['type'] == 'lastname')) {
$sn['name'] = $this->prepare($page, $sn['type'], $sn['name'],
$initial[$sn['type']], $success_tmp);
$success = $success && $success_tmp;
$user = S::user();
if ($owner->isActive()) {
foreach ($changedFields as $field => $values) {
- if (!is_null($field)) {
+ if (in_array($field, Profile::$descriptions)) {
XDB::execute('INSERT INTO profile_modifications (pid, uid, field, oldText, newText, type, timestamp)
VALUES ({?}, {?}, {?}, {?}, {?}, {?}, NOW())
ON DUPLICATE KEY UPDATE uid = VALUES(uid), oldText = IF(VALUES(type) != type, VALUES(oldText), oldText),
$uf = New UserFilter(New UFC_Group($globals->asso('id'), true));
$admins = $uf->iterUsers();
$admin = $admins->next();
- $to = $admin->bestalias;
+ $to = $admin->bestEmail();
while ($admin = $admins->next()) {
- $to .= ', ' . $admin->bestalias;
+ $to .= ', ' . $admin->bestEmail();
}
$append = "\n"
{if $issue->isEditable()}
Le {valid_date name="send_before_date" value=$issue->getSendBeforeDate() from=3 to=15} vers {html_select_time prefix="send_before_time_" time=$issue->getSendBeforeTime() display_hours=true display_minutes=false display_seconds=false display_meridian=false use_24_hours=true} heures
{else}
- Le {$issue->send_before|date_format:"%X vers %Hh"}
+ Le {$issue->send_before|date_format:"%d/%m/%Y vers %Hh"}
{/if}
</td>
</tr>
{/if}
<tr class='center'>
<td colspan='2'>
- <input type='submit' value='Sauver' />
+ <input type='submit' name='submit' value='Sauver' />
</td>
</tr>
</table>
--- /dev/null
+{**************************************************************************}
+{* *}
+{* 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: *}
nlid int(11) unsigned NOT NULL,
id int(11) unsigned NOT NULL auto_increment,
date date NOT NULL default '0000-00-00',
- send_before date default NULL,
+ send_before datetime default NULL,
state enum('sent','new','pending') NOT NULL default 'new',
sufb_json text default NULL,
title varchar(255) NOT NULL default '',