$res = XDB::query("SELECT * FROM axletter WHERE FIND_IN_SET('new', bits)");
if ($res->numRows()) {
extract($res->fetchOneAssoc(), EXTR_OVERWRITE);
- $subset_to = ($subset ? explode("\n", $subset) : null);
+ $subset_to = ($subset ? explode("\n", $subset) : array());
$subset = (count($subset_to) > 0);
$saved = true;
} else {
}
switch (@Post::v('valid')) {
+ case 'Vérifier les emails':
+ // Same as 'preview', but performs a test of all provided emails
+ if ($subset) {
+ require_once 'emails.inc.php';
+ $ids = ids_from_mails($subset_to);
+ $nb_error = 0;
+ foreach ($subset_to as $e) {
+ if (!array_key_exists($e, $ids)) {
+ if ($nb_error == 0) {
+ $page->trigError("Emails inconnus :");
+ }
+ $nb_error++;
+ $page->trigError($e);
+ }
+ }
+ if ($nb_error == 0) {
+ if (count($subset_to) == 1) {
+ $page->trigSuccess("L'email soumis a été reconnu avec succès.");
+ } else {
+ $page->trigSuccess("Les " . count($subset_to) . " emails soumis ont été reconnus avec succès.");
+ }
+ } else {
+ $page->trigError("Total : $nb_error erreur" . ($nb_error > 1 ? "s" : "") . " sur " . count($subset_to) . " adresses mail soumises.");
+ }
+ $page->trigSuccess("Les adresses soumises correspondent à un total de " . count(array_unique($ids)) . " camarades.");
+ }
+ // No break here, since Vérifier is a subcase of Aperçu.
case 'Aperçu':
$this->load('axletter.inc.php');
$al = new AXLetter(array($id, $short_name, $subject, $title, $body, $signature,
$promo_min, $promo_max, $subset, $subset_rm, $echeance, 0, 'new'));
- $al->toHtml($page, S::v('prenom'), S::v('nom'), S::v('femme'));
+ $al->toHtml($page, S::user());
break;
case 'Confirmer':
- XDB::execute("REPLACE INTO axletter
- SET id = {?}, short_name = {?}, subject = {?}, title = {?}, body = {?},
- signature = {?}, promo_min = {?}, promo_max = {?}, echeance = {?}, subset = {?}, subset_rm = {?}",
- $id, $short_name, $subject, $title, $body, $signature, $promo_min, $promo_max, $echeance, $subset ? implode("\n", $subset_to) : null, $subset_rm);
+ XDB::execute('INSERT INTO axletter (id, short_name, subject, title, body, signature,
+ promo_min, promo_max, echeance, subset, subset_rm)
+ VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})
+ ON DUPLICATE KEY UPDATE short_name = VALUES(short_name), subject = VALUES(subject), title = VALUES(title),
+ body = VALUES(body), signature = VALUES(signature), promo_min = VALUES(promo_min),
+ promo_max = VALUES(promo_max), echeance = VALUES(echeance), subset = VALUES(subset),
+ subset_rm = VALUES(subset_rm)',
+ $id, $short_name, $subject, $title, $body, $signature, $promo_min, $promo_max, $echeance,
+ $subset ? implode("\n", $subset_to) : null, $subset_rm);
if (!$saved) {
global $globals;
$mailer = new PlMailer();