X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Faxletter.php;h=0392173567a4e756928d5805add1306fff2db3c2;hb=5660032ac785d410f90e3f5b0d6948dc90b0cfea;hp=d3f1aa422b71ba7804a1b1e62c7b1b37f8346c3d;hpb=bd84f1ae4a78e4130422169e55a590ecbe76a0b5;p=platal.git diff --git a/modules/axletter.php b/modules/axletter.php index d3f1aa4..0392173 100644 --- a/modules/axletter.php +++ b/modules/axletter.php @@ -24,13 +24,13 @@ class AXLetterModule extends PLModule function handlers() { return array( - 'ax' => $this->make_hook('index', AUTH_COOKIE), + 'ax' => $this->make_hook('index', AUTH_COOKIE), 'ax/out' => $this->make_hook('out', AUTH_PUBLIC), 'ax/show' => $this->make_hook('show', AUTH_COOKIE), 'ax/edit' => $this->make_hook('submit', AUTH_MDP), 'ax/edit/cancel' => $this->make_hook('cancel', AUTH_MDP), 'ax/edit/valid' => $this->make_hook('valid', AUTH_MDP), - 'admin/axletter' => $this->make_hook('admin', AUTH_MDP, 'admin'), + 'admin/axletter' => $this->make_hook('admin', AUTH_MDP, 'admin'), ); } @@ -90,6 +90,9 @@ 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); + $subset_rm = Post::b('subset_rm'); $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 +103,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 +156,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, $subset_rm, $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 = {?}, 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(); @@ -197,12 +202,15 @@ 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('subset_rm', $subset_rm); $page->assign('echeance', $echeance); $page->assign('echeance_date', $echeance_date); $page->assign('echeance_time', $echeance_time); $page->assign('saved', $saved); $page->assign('new', $new); - $page->assign('is_xorg', S::has_perms()); + $page->assign('is_xorg', S::admin()); if (!$saved) { $select = ''; @@ -316,7 +324,7 @@ class AXLetterModule extends PLModule $importer->apply($page, "admin/axletter", array('user_id', 'email', 'prenom', 'nom', 'promo', 'flag', 'hash')); } - function idFromMail($line, $key) + function idFromMail($line, $key, $relation = null) { static $field; global $globals; @@ -334,7 +342,7 @@ class AXLetterModule extends PLModule return count($id) == 1 ? $id[0] : 0; } - function createHash($line, $key) + function createHash($line, $key, $relation) { $hash = implode(time(), $line) . rand(); $hash = md5($hash);