From: Pierre Habouzit (MadCoder Date: Tue, 18 Jan 2005 17:26:14 +0000 (+0000) Subject: closes FS#267 X-Git-Tag: xorg/old~377 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=6d86cc63cbb5d32d371a965fbb3a0ebc3d8c9beb;p=platal.git closes FS#267 git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-380 --- diff --git a/ChangeLog b/ChangeLog index 7a56af9..08ca7fd 100644 --- 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 diff --git a/htdocs/admin/newsletter_edit.php b/htdocs/admin/newsletter_edit.php index 3e5cc7e..210b718 100644 --- a/htdocs/admin/newsletter_edit.php +++ b/htdocs/admin/newsletter_edit.php @@ -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'); diff --git a/htdocs/admin/valider.php b/htdocs/admin/valider.php index 9d5612b..cc60b7c 100644 --- a/htdocs/admin/valider.php +++ b/htdocs/admin/valider.php @@ -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')); diff --git a/htdocs/newsletter/show.php b/htdocs/newsletter/show.php index 47850be..fc25f18 100644 --- a/htdocs/newsletter/show.php +++ b/htdocs/newsletter/show.php @@ -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'); diff --git a/htdocs/newsletter/submit.php b/htdocs/newsletter/submit.php index a311482..0d676f8 100644 --- a/htdocs/newsletter/submit.php +++ b/htdocs/newsletter/submit.php @@ -21,28 +21,15 @@ 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" '); - $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); } diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index 5055341..57f9a00 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -24,6 +24,10 @@ 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 diff --git a/include/validations/evts.inc.php b/include/validations/evts.inc.php index 4d67aa7..6714ab7 100644 --- a/include/validations/evts.inc.php +++ b/include/validations/evts.inc.php @@ -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 index 0000000..e7b17ed --- /dev/null +++ b/include/validations/nl.inc.php @@ -0,0 +1,84 @@ +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 index 0000000..07f2dba --- /dev/null +++ b/templates/include/form.valid.nl.tpl @@ -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 * + ***************************************************************************} + + + Version texte +
{$valid->art->toText()}
+ + + Version html + +
+ {$valid->art->toHtml()|smarty:nodefaults} +
+ + + +{* vim:set et sw=2 sts=2 sws=2: *}