Typo.
[platal.git] / modules / newsletter.php
index 75ab2e9..1c8ab38 100644 (file)
@@ -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;
@@ -151,22 +145,26 @@ class NewsletterModule extends PLModule
 
         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'));
             } else {
                 $art = ($eaid == 'new') ? new NLArticle() : $nl->getArt($eaid);
             }
+            if ($art && !$art->check()) {
+                $page->trigError("Cet article est trop long.");
+            }
             $page->assign('art', $art);
         }
 
         if ($aid == 'blacklist_check') {
+            global $globals;
             $ips_to_check = array();
-            $gethostbyname_count = 0;
+            $blacklist_host_resolution_count = 0;
 
             foreach ($nl->_arts as $key => $articles) {
                 foreach ($articles as $article) {
-                    $article_ips = $article->getLinkIps($gethostbyname_count);
+                    $article_ips = $article->getLinkIps($blacklist_host_resolution_count);
                     if (!empty($article_ips)) {
                         $ips_to_check[$article->title()] = $article_ips;
                     }
@@ -174,8 +172,8 @@ class NewsletterModule extends PLModule
             }
 
             $page->assign('ips_to_check', $ips_to_check);
-            if ($gethostbyname_count >= $globals->mail->blacklist_host_resolution_limit) {
-                $page-trigError("Toutes les url et adresses emails de la lettre"
+            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.");