X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Faxletter.php;h=b27dc7d5468950424487181f8ee00701276fca5a;hb=4279d3bc87776ede0e3f3a9789c3836b28f54db6;hp=ea4d2f4d868a19c911edcbd9f629a0d2bb355c5d;hpb=c3c43c0ebe734e2b43b5d5fdb6010d08358bc34b;p=platal.git diff --git a/modules/axletter.php b/modules/axletter.php index ea4d2f4..b27dc7d 100644 --- a/modules/axletter.php +++ b/modules/axletter.php @@ -90,6 +90,8 @@ class AXLetterModule extends PLModule $signature = trim(Post::v('signature')); $promo_min = Post::i('promo_min'); $promo_max = Post::i('promo_max'); + $subset_to = preg_split("/[ ,;\:\n\r]+/", Post::v('subset_to'), -1, PREG_SPLIT_NO_EMPTY); + $subset = (count($subset_to) > 0); $echeance = Post::has('echeance_date') ? preg_replace('/^(\d\d\d\d)(\d\d)(\d\d)$/', '\1-\2-\3', Post::v('echeance_date')) . ' ' . Post::v('echeance_time') : Post::v('echeance'); @@ -100,6 +102,8 @@ class AXLetterModule extends PLModule $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 = (count($subset_to) > 0); $saved = true; } else { XDB::execute("INSERT INTO axletter SET id = NULL"); @@ -151,15 +155,15 @@ class AXLetterModule extends PLModule case 'Aperçu': $this->load('axletter.inc.php'); $al = new AXLetter(array($id, $short_name, $subject, $title, $body, $signature, - $promo_min, $promo_max, $echeance, 0, 'new')); + $promo_min, $promo_max, $subset, $echeance, 0, 'new')); $al->toHtml($page, S::v('prenom'), S::v('nom'), S::v('femme')); break; case 'Confirmer': XDB::execute("REPLACE INTO axletter SET id = {?}, short_name = {?}, subject = {?}, title = {?}, body = {?}, - signature = {?}, promo_min = {?}, promo_max = {?}, echeance = {?}", - $id, $short_name, $subject, $title, $body, $signature, $promo_min, $promo_max, $echeance); + signature = {?}, promo_min = {?}, promo_max = {?}, echeance = {?}, subset = {?}", + $id, $short_name, $subject, $title, $body, $signature, $promo_min, $promo_max, $echeance, $subset ? implode("\n", $subset_to) : null); if (!$saved) { global $globals; $mailer = new PlMailer(); @@ -201,6 +205,8 @@ class AXLetterModule extends PLModule $page->assign('signature', $signature); $page->assign('promo_min', $promo_min); $page->assign('promo_max', $promo_max); + $page->assign('subset_to', implode("\n", $subset_to)); + $page->assign('subset', $subset); $page->assign('echeance', $echeance); $page->assign('echeance_date', $echeance_date); $page->assign('echeance_time', $echeance_time);