closes FS#267
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Tue, 18 Jan 2005 17:26:14 +0000 (17:26 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:27:48 +0000 (23:27 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-380

ChangeLog
htdocs/admin/newsletter_edit.php
htdocs/admin/valider.php
htdocs/newsletter/show.php
htdocs/newsletter/submit.php
include/newsletter.inc.php
include/validations/evts.inc.php
include/validations/nl.inc.php [new file with mode: 0644]
templates/include/form.valid.nl.tpl [new file with mode: 0644]

index 7a56af9..08ca7fd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -86,6 +86,7 @@ Bug/Wish :
        * Validations :
                - #137: Now possible to add comments without any action.                        -MC
                - #191, #256: Marketing now uses the validation process.                        -MC
+               - #267: Newsletter uses the validation process too.                                     -MC
 
 ================================================================================
 VERSION 0.9.3                                                                                                           27 Dec 2004
index 3e5cc7e..210b718 100644 (file)
@@ -21,7 +21,6 @@
 
 require_once("xorg.inc.php");
 new_admin_page('admin/newsletter_edit.tpl');
-$page->addCssLink('css/nl.css');
 require_once("newsletter.inc.php");
 
 $nid = Get::get('nid', 'last');
index 9d5612b..cc60b7c 100644 (file)
@@ -20,8 +20,8 @@
  ***************************************************************************/
 
 require_once("xorg.inc.php");
-require_once("validations.inc.php");
 new_admin_page('admin/valider.tpl');
+require_once("validations.inc.php");
 
 if(Env::has('uid') && Env::has('type') && Env::has('stamp')) {
     $req = Validate::get_request(Env::get('uid'), Env::get('type'), Env::get('stamp'));
index 47850be..fc25f18 100644 (file)
@@ -21,7 +21,6 @@
 
 require_once("xorg.inc.php");
 new_skinned_page('newsletter/show.tpl', AUTH_COOKIE);
-$page->addCssLink('css/nl.css');
 require_once("newsletter.inc.php");
 
 $nid = Get::get('nid', 'last');
index a311482..0d676f8 100644 (file)
 
 require_once("xorg.inc.php");
 new_skinned_page('newsletter/submit.tpl', AUTH_COOKIE);
-$page->addCssLink('css/nl.css');
 require_once("newsletter.inc.php");
 
 if (Post::has('see')) {
     $art = new NLArticle(Post::get('title'), Post::get('body'), Post::get('append'));
     $page->assign('art', $art);
 } elseif (Post::has('valid')) {
-    $nl  = new Newsletter();
-    $art = new NLArticle(Post::get('title'), Post::get('body'), Post::get('append'));
-    $nl->saveArticle($art);
-
-    require_once("diogenes/diogenes.hermes.inc.php");
-    $from = sprintf('"%s %s (%s)" <%s@%s>', Session::get('prenom'), Session::get('nom'),
-            Session::get('promo'), Session::get('bestalias'), $globals->mail->domain);
-    $mailer = new HermesMailer();
-    $mailer->setSubject("proposition d'article dans la NL");
-    $mailer->addTo('"Equipe Newsletter Polytechnique.org" <info+nlp@polytechnique.org>');
-    $mailer->setFrom($from);
-    $mailer->addCc($from);
-    $text = "l'article suivant a été proposé par:\n\n    $from\n\n\n".$art->toText();
-    $mailer->setTxtBody($text);
-    $mailer->send();
+    require_once('validations.inc.php');
+    $art = new NLReq(Session::getInt('uid'), Post::get('title'), Post::get('body'), Post::get('append'));
+    $art->submit();
     
     $page->assign('submited', true);
 }
index 5055341..57f9a00 100644 (file)
 require_once("xorg.misc.inc.php");
 require_once("diogenes/diogenes.misc.inc.php");
 
+if (isset($page)) {
+    $page->addCssLink('css/nl.css');
+}
+
 define('FEMME', 1);
 define('HOMME', 0);
 
@@ -138,7 +142,7 @@ class NewsLetter
                                           $a->_title, $a->_body, $a->_append);
            $this->_arts['a'.$a->_aid] = $a;
        } else {
-           $globals->xdb->executey(
+           $globals->xdb->execute(
                'INSERT INTO  newsletter_art
                      SELECT  {?},MAX(aid)+1,{?},'.($a->_pos ? intval($a->_pos) : 'MAX(pos)+1').',{?},{?},{?}
                        FROM  newsletter_art AS a
index 4d67aa7..6714ab7 100644 (file)
@@ -38,7 +38,7 @@ class EvtReq extends Validate
 
     function EvtReq($_titre, $_texte, $_pmin, $_pmax, $_peremption, $_comment, $_uid) {
         global $globals;
-        $this->Validate($_uid, false, 'evts', $_stamp);
+        $this->Validate($_uid, false, 'evts');
         $this->titre      = $_titre;
         $this->texte      = $_texte;
         $this->pmin       = $_pmin;
diff --git a/include/validations/nl.inc.php b/include/validations/nl.inc.php
new file mode 100644 (file)
index 0000000..e7b17ed
--- /dev/null
@@ -0,0 +1,84 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+// {{{ class NLReq
+
+require_once("newsletter.inc.php");
+
+class NLReq extends Validate
+{
+    // {{{ properties
+
+    var $art;
+    
+    // }}}
+    // {{{ constructor
+
+    function NlReq($uid, $title, $body, $append) {
+        $this->Validate($uid, false, 'nl');
+        $this->art = new NLArticle($title, $body, $append);
+    }
+
+    // }}}
+    // {{{ function formu()
+
+    function formu()
+    {
+        return 'include/form.valid.nl.tpl';
+    }
+
+    // }}}
+    // {{{ function _mail_subj
+    
+    function _mail_subj()
+    {
+        return "[Polytechnique.org/NL] Proposition d'article dans la NL";
+    }
+
+    // }}}
+    // {{{ function _mail_body
+
+    function _mail_body($isok)
+    {
+        if ($isok) {
+            return "  L'annonce que tu avais proposée ({$this->title}) vient d'être validée.";
+        } else {
+            return "  L'annonce que tu avais proposée ({$this->title}) a été refusée.";
+        }
+    }
+
+    // }}}
+    // {{{ function commit()
+
+    function commit()
+    {
+        $nl  = new Newsletter();
+        $nl->saveArticle($this->art);
+        return true;
+    }
+
+    // }}}
+}
+
+// }}}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+?>
diff --git a/templates/include/form.valid.nl.tpl b/templates/include/form.valid.nl.tpl
new file mode 100644 (file)
index 0000000..07f2dba
--- /dev/null
@@ -0,0 +1,34 @@
+{***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************}
+
+<tr class="pair">
+  <td class="titre">Version texte</td>
+  <td style='border: 1px dotted #888'><pre>{$valid->art->toText()}</pre></td>
+</tr>
+<tr class="pair">
+  <td class="titre">Version html</td>
+  <td style='border: 1px dotted #888'>
+    <div class='nl'>
+      {$valid->art->toHtml()|smarty:nodefaults}
+    </div>
+  </td>
+</tr>
+
+{* vim:set et sw=2 sts=2 sws=2: *}