Port to PlWikiPage structure.
[platal.git] / modules / newsletter.php
index 3abc1ee..31face1 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2007 Polytechnique.org                              *
+ *  Copyright (C) 2003-2008 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -38,7 +38,7 @@ class NewsletterModule extends PLModule
         require_once 'newsletter.inc.php';
 
         $page->changeTpl('newsletter/index.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Lettres mensuelles');
+        $page->setTitle('Polytechnique.org - Lettres mensuelles');
 
         switch ($action) {
           case 'out': Newsletter::unsubscribe(); break;
@@ -63,9 +63,11 @@ class NewsletterModule extends PLModule
             $nl->toHtml($page, S::v('prenom'), S::v('nom'), S::v('femme'));
         }
         if (Post::has('send')) {
+            $res = XDB::query("SELECT hash FROM newsletter_ins WHERE user_id = {?}", S::i('uid'));
             $nl->sendTo(S::v('prenom'), S::v('nom'),
                         S::v('bestalias'), S::v('femme'),
-                        S::v('mail_fmt') != 'texte');
+                        S::v('mail_fmt') != 'texte',
+                        $res->fetchOneCell());
         }
     }
 
@@ -74,12 +76,12 @@ class NewsletterModule extends PLModule
         $page->changeTpl('newsletter/submit.tpl');
 
         require_once 'newsletter.inc.php';
-        require_once 'wiki.inc.php';
-        wiki_require_page('Xorg.LettreMensuelle');
+        $wp = new PlWikiPage('Xorg.LettreMensuelle');
+        $wp->buildCache();
 
         if (Post::has('see') || (Post::has('valid') && (!trim(Post::v('title')) || !trim(Post::v('body'))))) {
             if (!Post::has('see')) {
-                $page->trig("L'article doit avoir un titre et un contenu");
+                $page->trigError("L'article doit avoir un titre et un contenu");
             }
             $art = new NLArticle(Post::v('title'), Post::v('body'), Post::v('append'));
             $page->assign('art', $art);
@@ -95,7 +97,7 @@ class NewsletterModule extends PLModule
 
     function handler_admin_nl(&$page, $new = false) {
         $page->changeTpl('newsletter/admin.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Newsletter : liste');
+        $page->setTitle('Polytechnique.org - Administration - Newsletter : liste');
         require_once("newsletter.inc.php");
 
         if($new) {
@@ -109,7 +111,7 @@ 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->assign('xorg_title','Polytechnique.org - Administration - Newsletter : Edition');
+        $page->setTitle('Polytechnique.org - Administration - Newsletter : Edition');
         require_once("newsletter.inc.php");
 
         $nl  = new NewsLetter($nid);
@@ -128,7 +130,7 @@ class NewsletterModule extends PLModule
             if (preg_match('/^[-a-z0-9]*$/i', $nl->_shortname) && !is_numeric($nl->_shortname)) {
                 $nl->save();
             } else {
-                $page->trig('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);
             }
         }
@@ -155,7 +157,7 @@ class NewsletterModule extends PLModule
     }
 
     function handler_admin_nl_cat(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Newsletter : Catégories');
+        $page->setTitle('Polytechnique.org - Administration - Newsletter : Catégories');
         $page->assign('title', 'Gestion des catégories de la newsletter');
         $table_editor = new PLTableEditor('admin/newsletter/categories','newsletter_cat','cid');
         $table_editor->describe('titre','intitulé',true);