X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fnewsletter.php;h=1c8ab381e9308633b328fa1c787e2bcde201e1ab;hb=5660032ac785d410f90e3f5b0d6948dc90b0cfea;hp=62dd6849a6ab8c777d396745f628b272423e5db3;hpb=e85e121558a37e06cbf2099843588a6e5e5c267a;p=platal.git diff --git a/modules/newsletter.php b/modules/newsletter.php index 62dd684..1c8ab38 100644 --- a/modules/newsletter.php +++ b/modules/newsletter.php @@ -24,11 +24,11 @@ class NewsletterModule extends PLModule function handlers() { return array( - 'nl' => $this->make_hook('nl', AUTH_COOKIE), - 'nl/show' => $this->make_hook('nl_show', AUTH_COOKIE), - 'nl/submit' => $this->make_hook('nl_submit', AUTH_MDP), - 'admin/newsletter' => $this->make_hook('admin_nl', AUTH_MDP, 'admin'), - 'admin/newsletter/categories' => $this->make_hook('admin_nl_cat', AUTH_MDP, 'admin'), + 'nl' => $this->make_hook('nl', AUTH_COOKIE), + 'nl/show' => $this->make_hook('nl_show', AUTH_COOKIE), + 'nl/submit' => $this->make_hook('nl_submit', AUTH_MDP), + 'admin/newsletter' => $this->make_hook('admin_nl', AUTH_MDP, 'admin'), + 'admin/newsletter/categories' => $this->make_hook('admin_nl_cat', AUTH_MDP, 'admin'), 'admin/newsletter/edit' => $this->make_hook('admin_nl_edit', AUTH_MDP, 'admin'), ); } @@ -58,20 +58,14 @@ class NewsletterModule extends PLModule try { $nl = new NewsLetter($nid); + $user =& S::user(); if (Get::has('text')) { - $nl->toText($page, S::v('prenom'), S::v('nom'), S::v('femme')); + $nl->toText($page, $user); } else { - $nl->toHtml($page, S::v('prenom'), S::v('nom'), S::v('femme')); + $nl->toHtml($page, $user); } if (Post::has('send')) { - $res = XDB::query("SELECT hash - FROM newsletter_ins - WHERE user_id = {?}", - S::i('uid')); - $nl->sendTo(S::user()->login(), S::user()->bestEmail(), - S::v('prenom'), S::v('nom'), - S::v('femme'), S::v('mail_fmt') != 'texte', - $res->fetchOneCell()); + $nl->sendTo($user); } } catch (MailNotFound $e) { return PL_NOT_FOUND; @@ -118,10 +112,10 @@ class NewsletterModule extends PLModule function handler_admin_nl_edit(&$page, $nid = 'last', $aid = null, $action = 'edit') { $page->changeTpl('newsletter/edit.tpl'); $page->addCssLink('nl.css'); - $page->setTitle('Administration - Newsletter : Edition'); - require_once("newsletter.inc.php"); + $page->setTitle('Administration - Newsletter : Édition'); + require_once 'newsletter.inc.php'; - $nl = new NewsLetter($nid); + $nl = new NewsLetter($nid); if($action == 'delete') { $nl->delArticle($aid); @@ -129,38 +123,64 @@ class NewsletterModule extends PLModule } if($aid == 'update') { - $nl->_title = Post::v('title'); - $nl->_title_mail= Post::v('title_mail'); - $nl->_date = Post::v('date'); - $nl->_head = Post::v('head'); - $nl->_shortname = strlen(Post::v('shortname')) ? Post::v('shortname') : null; + $nl->_title = Post::v('title'); + $nl->_title_mail = Post::v('title_mail'); + $nl->_date = Post::v('date'); + $nl->_head = Post::v('head'); + $nl->_shortname = strlen(Post::v('shortname')) ? Post::v('shortname') : null; if (preg_match('/^[-a-z0-9]*$/i', $nl->_shortname) && !is_numeric($nl->_shortname)) { $nl->save(); } else { - $page->trigError('Le nom de la NL n\'est pas valide'); + $page->trigError("Le nom de la NL n'est pas valide."); pl_redirect('admin/newsletter/edit/' . $nl->_id); } } if(Post::v('save')) { $art = new NLArticle(Post::v('title'), Post::v('body'), Post::v('append'), - $aid, Post::v('cid'), Post::v('pos')); + $aid, Post::v('cid'), Post::v('pos')); $nl->saveArticle($art); pl_redirect("admin/newsletter/edit/$nid"); } - if($action == 'edit' && $aid != 'update') { + if ($action == 'edit' && $aid != 'update') { $eaid = $aid; - if(Post::has('title')) { + if (Post::has('title')) { $art = new NLArticle(Post::v('title'), Post::v('body'), Post::v('append'), - $eaid, Post::v('cid'), Post::v('pos')); + $eaid, Post::v('cid'), Post::v('pos')); } else { - $art = ($eaid == 'new') ? new NLArticle() : $nl->getArt($eaid); + $art = ($eaid == 'new') ? new NLArticle() : $nl->getArt($eaid); + } + if ($art && !$art->check()) { + $page->trigError("Cet article est trop long."); } $page->assign('art', $art); } - $page->assign_by_ref('nl',$nl); + if ($aid == 'blacklist_check') { + global $globals; + $ips_to_check = array(); + $blacklist_host_resolution_count = 0; + + foreach ($nl->_arts as $key => $articles) { + foreach ($articles as $article) { + $article_ips = $article->getLinkIps($blacklist_host_resolution_count); + if (!empty($article_ips)) { + $ips_to_check[$article->title()] = $article_ips; + } + } + } + + $page->assign('ips_to_check', $ips_to_check); + if ($blacklist_host_resolution_count >= $globals->mail->blacklist_host_resolution_limit) { + $page->trigError("Toutes les url et adresses emails de la lettre" + . " n'ont pas été prises en compte car la" + . " limite du nombre de résolutions DNS" + . " autorisée a été atteinte."); + } + } + + $page->assign_by_ref('nl', $nl); } function handler_admin_nl_cat(&$page, $action = 'list', $id = null) {