X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=inline;f=modules%2Faxletter.php;h=270e2ca5134718b65b536c0c4c42fac5fe255723;hb=d7610c358d074c78e1e8dc25fe0cf0e5e7e1c55e;hp=d093bd3bf8f1fc9200a4aa0abd4ee8f663b193d9;hpb=fde3e90eec52076baad7ee2a202388ff95931c45;p=platal.git diff --git a/modules/axletter.php b/modules/axletter.php index d093bd3..270e2ca 100644 --- a/modules/axletter.php +++ b/modules/axletter.php @@ -109,7 +109,9 @@ class AXLetterModule extends PLModule $saved = false; $new = true; } - } elseif (Post::has('valid') && S::has_xsrf_token()) { + } elseif (Post::has('valid')) { + S::assert_xsrf_token(); + if (!$subject && $title) { $subject = $title; } @@ -117,27 +119,27 @@ class AXLetterModule extends PLModule $title = $subject; } if (!$subject || !$title || !$body) { - $page->trig("L'article doit avoir un sujet et un contenu"); + $page->trigError("L'article doit avoir un sujet et un contenu"); Post::kill('valid'); } if (($promo_min > $promo_max && $promo_max != 0)|| ($promo_min != 0 && ($promo_min <= 1900 || $promo_min >= 2020)) || ($promo_max != 0 && ($promo_max <= 1900 || $promo_max >= 2020))) { - $page->trig("L'intervalle de promotions n'est pas valide"); + $page->trigError("L'intervalle de promotions n'est pas valide"); Post::kill('valid'); } if (empty($short_name)) { - $page->trig("L'annonce doit avoir un nom raccourci pour simplifier la navigation dans les archives"); + $page->trigError("L'annonce doit avoir un nom raccourci pour simplifier la navigation dans les archives"); Post::kill('valid'); } elseif (!preg_match('/^[a-z][-a-z0-9]*[a-z0-9]$/', $short_name)) { - $page->trig("Le nom raccourci n'est pas valide, il doit comporter au moins 2 caractères et n'être composé " + $page->trigError("Le nom raccourci n'est pas valide, il doit comporter au moins 2 caractères et n'être composé " . "que de chiffres, lettres et tirets"); Post::kill('valid'); } elseif ($short_name != Post::v('old_short_name')) { $res = XDB::query("SELECT id FROM axletter WHERE short_name = {?}", $short_name); if ($res->numRows() && $res->fetchOneCell() != $id) { - $page->trig("Le nom $short_name est déjà utilisé, merci d'en choisir un autre"); + $page->trigError("Le nom $short_name est déjà utilisé, merci d'en choisir un autre"); $short_name = Post::v('old_short_name'); if (empty($short_name)) { Post::kill('valid'); @@ -190,8 +192,6 @@ class AXLetterModule extends PLModule pl_redirect('ax'); break; } - } elseif (Post::has('valid')) { - $page->trig("L'opération a échouée, merci de réessayer."); } $page->assign('id', $id); $page->assign('short_name', $short_name); @@ -288,7 +288,9 @@ class AXLetterModule extends PLModule $action = Post::v('action'); $uid = Post::v('uid'); } - if ($uid && S::has_xsrf_token()) { + if ($uid) { + S::assert_xsrf_token(); + $uids = preg_split('/ *[,;\: ] */', $uid); foreach ($uids as $uid) { switch ($action) { @@ -300,11 +302,9 @@ class AXLetterModule extends PLModule break; } if (!$res) { - $page->trig("Personne ne correspond à l'identifiant '$uid'"); + $page->trigError("Personne ne correspond à l'identifiant '$uid'"); } } - } elseif ($uid) { - $page->trig("L'opération sur la liste des administrateurs AX a échouée, merci de réessayer."); } $page->changeTpl('axletter/admin.tpl');