<?php
/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
+ * Copyright (C) 2003-2009 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
return $this->handler_index($page, 'out');
}
}
- require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+ $this->load('axletter.inc.php');
$page->changeTpl('axletter/unsubscribe.tpl');
$page->assign('success', AXLetter::unsubscribe($hash, true));
}
function handler_index(&$page, $action = null)
{
- require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+ $this->load('axletter.inc.php');
$page->changeTpl('axletter/index.tpl');
- $page->assign('pl_title','Polytechnique.org - Envois de l\'AX');
+ $page->setTitle('Envois de l\'AX');
switch ($action) {
case 'in': AXLetter::subscribe(); break;
function handler_submit(&$page, $action = null)
{
- require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+ $this->load('axletter.inc.php');
if (!AXLetter::hasPerms()) {
return PL_FORBIDDEN;
}
switch (@Post::v('valid')) {
case 'Aperçu':
- require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+ $this->load('axletter.inc.php');
$al = new AXLetter(array($id, $short_name, $subject, $title, $body, $signature,
$promo_min, $promo_max, $echeance, 0, 'new'));
$al->toHtml($page, S::v('prenom'), S::v('nom'), S::v('femme'));
global $globals;
$mailer = new PlMailer();
$mailer->setFrom("support@" . $globals->mail->domain);
- $mailer->setSubject("Un nouveau projet de mail de l'AX vient d'être proposé");
- $mailer->setTxtBody("Un nouveau mail vient d'être rédigé en prévision d'un envoi prochain. Vous pouvez "
+ $mailer->setSubject("Un nouveau projet d'email de l'AX vient d'être proposé");
+ $mailer->setTxtBody("Un nouvel email vient d'être rédigé en prévision d'un envoi prochain. Vous pouvez "
. "le modifier jusqu'à ce qu'il soit verrouillé pour l'envoi\n\n"
- . "Le sujet du mail : $subject\n"
+ . "Le sujet de l'email : $subject\n"
. "L'échéance d'envoi est fixée à $echeance.\n"
- . "Le mail pourra néanmoins partir avant cette échéance si un administrateur de "
+ . "L'email pourra néanmoins partir avant cette échéance si un administrateur de "
. "Polytechnique.org le valide.\n\n"
- . "Pour modifier, valider ou annuler le mail :\n"
+ . "Pour modifier, valider ou annuler l'email :\n"
. "https://www.polytechnique.org/ax/edit\n"
. "-- \n"
. "Association Polytechnique.org\n");
function handler_cancel(&$page, $force = null)
{
- require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+ $this->load('axletter.inc.php');
if (!AXLetter::hasPerms() || !S::has_xsrf_token()) {
return PL_FORBIDDEN;
}
return;
}
- $page->kill("L'envoi de l'annonce {$al->title()} est annulé");
+ $page->killSuccess("L'envoi de l'annonce {$al->title()} est annulé.");
}
function handler_valid(&$page, $force = null)
{
- require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+ $this->load('axletter.inc.php');
if (!AXLetter::hasPerms() || !S::has_xsrf_token()) {
return PL_FORBIDDEN;
}
return;
}
- $page->kill("L'envoi de l'annonce aura lieu dans l'heure qui vient.");
+ $page->killSuccess("L'envoi de l'annonce aura lieu dans l'heure qui vient.");
}
function handler_show(&$page, $nid = 'last')
{
- require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+ $this->load('axletter.inc.php');
$page->changeTpl('axletter/show.tpl');
- $nl = new AXLetter($nid);
- if (Get::has('text')) {
- $nl->toText($page, S::v('prenom'), S::v('nom'), S::v('femme'));
- } else {
- $nl->toHtml($page, S::v('prenom'), S::v('nom'), S::v('femme'));
- }
- if (Post::has('send')) {
- $nl->sendTo(S::v('prenom'), S::v('nom'),
- S::v('bestalias'), S::v('femme'),
- S::v('mail_fmt') != 'texte');
+ try {
+ $nl = new AXLetter($nid);
+ if (Get::has('text')) {
+ $nl->toText($page, S::v('prenom'), S::v('nom'), S::v('femme'));
+ } else {
+ $nl->toHtml($page, S::v('prenom'), S::v('nom'), S::v('femme'));
+ }
+ if (Post::has('send')) {
+ $nl->sendTo(S::user()->login(), S::user()->bestEmail(),
+ S::v('prenom'), S::v('nom'),
+ S::v('femme'), S::v('mail_fmt') != 'texte');
+ }
+ } catch (MailNotFound $e) {
+ return PL_NOT_FOUND;
}
}
function handler_admin(&$page, $action = null, $uid = null)
{
- require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+ $this->load('axletter.inc.php');
if (Post::has('action')) {
$action = Post::v('action');
$uid = Post::v('uid');
$page->changeTpl('axletter/admin.tpl');
$res = XDB::iterator("SELECT IF(u.nom_usage != '', u.nom_usage, u.nom) AS nom,
- u.prenom, u.promo, a.alias AS forlife
+ u.prenom, u.promo, u.hruid
FROM axletter_rights AS ar
- INNER JOIN auth_user_md5 AS u USING(user_id)
- INNER JOIN aliases AS a ON (u.user_id = a.id AND a.type = 'a_vie')");
+ INNER JOIN auth_user_md5 AS u USING(user_id)");
$page->assign('admins', $res);
$importer = new CSVImporter('axletter_ins');