From 4c25d2d8295edfbbc6b713061af1d3793d55abbc Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Fri, 15 Oct 2004 12:57:09 +0000 Subject: [PATCH] basis for new ML --- configs/menu.conf.php | 2 +- htdocs/{newsletter.php => newsletter/index.php} | 33 +---- htdocs/newsletter_req.php | 70 --------- include/newsletter.inc.php | 11 +- scripts/migration/0.9.1/newsleter.sql | 6 + templates/newsletter.tpl | 66 --------- .../newsletter.list.tpl => newsletter/index.tpl} | 36 +++-- templates/newsletter_req.tpl | 158 --------------------- 8 files changed, 38 insertions(+), 344 deletions(-) rename htdocs/{newsletter.php => newsletter/index.php} (54%) delete mode 100644 htdocs/newsletter_req.php create mode 100644 scripts/migration/0.9.1/newsleter.sql delete mode 100644 templates/newsletter.tpl rename templates/{include/newsletter.list.tpl => newsletter/index.tpl} (76%) delete mode 100644 templates/newsletter_req.tpl diff --git a/configs/menu.conf.php b/configs/menu.conf.php index 282f21c..9ac593c 100644 --- a/configs/menu.conf.php +++ b/configs/menu.conf.php @@ -24,7 +24,7 @@ if(logged()) { 'Sites Polytechniciens' => 'http://www.polytechnique.net/' ), 'Informations' => Array ( - 'Lettres mensuelles' => 'newsletter.php', + 'Lettres mensuelles' => 'newsletter/', 'Documentations' => 'docs/', 'Nous contacter ' => "docs/contacts.php", 'Emploi' => 'http://www.manageurs.com/' diff --git a/htdocs/newsletter.php b/htdocs/newsletter/index.php similarity index 54% rename from htdocs/newsletter.php rename to htdocs/newsletter/index.php index 31a7d49..c3f7691 100644 --- a/htdocs/newsletter.php +++ b/htdocs/newsletter/index.php @@ -18,38 +18,13 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: newsletter.php,v 1.7 2004-09-04 21:58:22 x2000habouzit Exp $ + $Id: index.php,v 1.1 2004-10-15 12:57:10 x2000habouzit Exp $ ***************************************************************************/ require("auto.prepend.inc.php"); -new_skinned_page('newsletter.tpl', AUTH_COOKIE); - -if (isset($_REQUEST['last'])) - $res=$globals->db->query("SELECT UNIX_TIMESTAMP(date),titre,text FROM newsletter ORDER BY id DESC LIMIT 1"); -elseif (isset($_REQUEST['nl_id'])) - $res=$globals->db->query("SELECT UNIX_TIMESTAMP(date),titre,text FROM newsletter WHERE id='{$_REQUEST['nl_id']}'"); -else - $res=""; - -if (($res)&&(list($nl_date, $nl_titre, $nl_text) = mysql_fetch_row($res))) { - $page->assign('nl_date', $nl_date); - $page->assign('nl_titre', $nl_titre); - $page->assign('nl_text', $nl_text); - - if (isset($_REQUEST['send_mail'])) { - require('diogenes.mailer.inc.php'); - $mymail = new DiogenesMailer("info_newsletter@polytechnique.org", - $_SESSION['forlife']."@polytechnique.org", - "[polytechnique.org] ".$nl_titre); - $mymail->addHeader("From: \"Equipe polytechnique.org\" "); - $mymail->setBody("Suite à ta demande sur le site web, nous te réexpédions cette lettre d'informations archivée.\r\n\r\n".strip_tags($nl_text)); - $mymail->send(); - $page->assign('erreur', 'Mail envoyé.'); - } -} - -$sql = "SELECT id,date,titre FROM newsletter ORDER BY date DESC"; -$page->mysql_assign($sql, 'nl_list'); +new_skinned_page('newsletter/index.tpl', AUTH_COOKIE); +require("newsletter.inc.php"); +$page->assign_by_ref('nl_list',get_nl_list()); $page->run(); ?> diff --git a/htdocs/newsletter_req.php b/htdocs/newsletter_req.php deleted file mode 100644 index 235992f..0000000 --- a/htdocs/newsletter_req.php +++ /dev/null @@ -1,70 +0,0 @@ -assign('article', $article); - $page->assign('titre', $titre); - $page->assign('bonus', $bonus); - - if (empty($_POST["titre"])) { - $page->assign('erreur', '

Tu n\'as pas mentionné de titre !!

'); - } elseif (empty($_POST["article"])) { - $page->assign('erreur', '

ton annonce est vide !!

'); - } else { - $exec="echo ".escapeshellarg($article)." | perl " - ."-MText::Autoformat -e 'autoformat " - ."{left=>1, right=>68, all=>1, justify=>full };'"; - exec($exec,$result); - $page->assign('preview', join("\n",$result)); - - $page->assign('nb_lines', count($result)); - - if ((count($result)<9) and ($_POST["action"]=="valider")) { - require_once("diogenes.mailer.inc.php"); - $mailer = new DiogenesMailer($_SESSION['forlife']."@polytechnique.org", - "info+nl@polytechnique.org", - "Proposition d'article pour la newsletter", - false); - $mailer->setbody( - wordwrap($titre,72)."\n\n". - join("\n",$result)."\n\n". - wordwrap($bonus,72)); - $mailer->send(); - $page->assign('sent', 1); - } - } -} - -$page->run(); -?> diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index 432e8c3..8d291ff 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -18,13 +18,22 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: newsletter.inc.php,v 1.1 2004-10-14 22:16:01 x2000habouzit Exp $ + $Id: newsletter.inc.php,v 1.2 2004-10-15 12:57:10 x2000habouzit Exp $ ***************************************************************************/ class NewsLetter { function NewsLetter() { } } +function get_nl_list() { + global $globals; + $res = $globals->db->query("SELECT id,date,titre FROM newsletter ORDER BY date DESC"); + $ans = Array(); + while($tmp = mysql_fetch_assoc($res)) $ans[] = $tmp; + mysql_free_result($res); + return $ans; +} + function get_nl_state() { global $globals; $res = $globals->db->query("SELECT COUNT(*)>0 FROM newsletter_ins WHERE user_id={$_SESSION['uid']}"); diff --git a/scripts/migration/0.9.1/newsleter.sql b/scripts/migration/0.9.1/newsleter.sql new file mode 100644 index 0000000..6acec7b --- /dev/null +++ b/scripts/migration/0.9.1/newsleter.sql @@ -0,0 +1,6 @@ +alter table newsletter change id id int not null; +alter table newsletter change `date` `date` date not null; +alter table newsletter add column bits enum('old','sent','new') default 'new' not null; + +alter table newsletter_ins add column last int; +alter table newsletter_ins add index (last); diff --git a/templates/newsletter.tpl b/templates/newsletter.tpl deleted file mode 100644 index 8c57c96..0000000 --- a/templates/newsletter.tpl +++ /dev/null @@ -1,66 +0,0 @@ -{*************************************************************************** - * 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 * - *************************************************************************** - $Id: newsletter.tpl,v 1.8 2004-09-04 21:58:22 x2000habouzit Exp $ - ***************************************************************************} - - -{dynamic} - -

{$erreur}

- -{if $nl_titre} - -

-[me l'envoyer par mail] -

- - - - - - - -
- {$nl_titre} - {$nl_date|date_format:"%d/%m/%Y"} -
- {$nl_text|smarty:nodefaults|replace:"":""|replace:"":""|nl2br} -
-

-[retour à la liste] -

- -{else} - -
- Lettre de Polytechnique.org -
-

-Tu trouveras ici les archives de la lettre d'information de Polytechnique.org. Pour t'abonner à -cette lettre, il te suffit de te rendre sur la page des listes et de cocher la -case "newsletter". Enfin, pour demander l'ajout d'une annonce dans la prochaine lettre - mensuelle, écris-nous ! -

- -{include file=include/newsletter.list.tpl nl_list=$nl_list} - -{/if} - -{/dynamic} -{* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/include/newsletter.list.tpl b/templates/newsletter/index.tpl similarity index 76% rename from templates/include/newsletter.list.tpl rename to templates/newsletter/index.tpl index 33e845a..806fdb7 100644 --- a/templates/include/newsletter.list.tpl +++ b/templates/newsletter/index.tpl @@ -17,40 +17,38 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: newsletter.list.tpl,v 1.5 2004-08-31 11:25:40 x2000habouzit Exp $ + $Id: index.tpl,v 1.1 2004-10-15 12:57:11 x2000habouzit Exp $ ***************************************************************************} +
+ Lettre de Polytechnique.org +
+

+Tu trouveras ici les archives de la lettre d'information de Polytechnique.org. Pour t'abonner à +cette lettre, il te suffit de te rendre sur la page des listes. +

+

+Pour demander l'ajout d'une annonce dans la prochaine lettre mensuelle, +écris-nous ! +

+ +{dynamic} - {foreach item=nl from=$nl_list} - {if $admin} - - {else} - - {/if} {/foreach}
date titre 
{$nl.date|date_format:"%Y-%m-%d"} - {$nl.titre} - -
-
- - - - -
-
+ {$nl.titre}
-   -
+{/dynamic} + {* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/newsletter_req.tpl b/templates/newsletter_req.tpl deleted file mode 100644 index c52e297..0000000 --- a/templates/newsletter_req.tpl +++ /dev/null @@ -1,158 +0,0 @@ -{*************************************************************************** - * 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 * - *************************************************************************** - $Id: newsletter_req.tpl,v 1.7 2004-08-31 11:25:39 x2000habouzit Exp $ - ***************************************************************************} - - -
- Proposer un article pour la newsletter -
- -

- La newsletter mensuelle est un excellent moyen de faire passer une - information. Nous devons cependant nous astreindre à certaines règles - dans la rédaction pour en conserver la qualité et l'efficacité. -

- - -{dynamic} -{if $smarty.request.action} - {if $erreur} - {$erreur} - {/if} - - {if $preview} -

- Le texte de ton annonce aura sensiblement l'allure suivante : -

-
- - - - -
- - <------------------------------------------------------------------>
-
- {$preview|replace:" ":" "|nl2br} -
-
- <------------------------------------------------------------------> -
-
- - {if $sent} -

- Ton annonce a été envoyée à l'équipe de rédaction. Merci de ta contribution ! -

-

- Félicitations, ton article respecte les règles de pagination de la - newsletter !!! Il pourra cependant être revu en fonction des - nécéssités de la newsletter. -

-

- Tu peux le soumettre à l'équipe de validation en validant ta demande. - Tu seras recontacté par mail par un rédacteur pour te confirmer la - bonne récéption de ta demande. -

-
- - - - -
-

- Si tu n'es pas satisfait de ton annonce, tu peux la retravailler : -

- {elseif $nb_lines > 9} -

- Ton annonce est trop longue, il faut que tu la modifie pour qu'elle fasse moins de huit lignes -

- {/if} - {/if} - -{/if} - -{if !$sent} -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Proposition d'article -
- Titre -
- -
- Article : -
- -
- Adresses, url, mail, contact, téléphone, etc. : -
- -
- -
-
-{/if} - -{/dynamic} -{* vim:set et sw=2 sts=2 sws=2: *} -- 2.1.4