--- /dev/null
+<?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 *
+ ***************************************************************************
+ $Id: submit.php,v 1.1 2004-10-16 17:49:37 x2000habouzit Exp $
+ ***************************************************************************/
+
+require("auto.prepend.inc.php");
+new_skinned_page('newsletter/submit.tpl', AUTH_COOKIE);
+require("newsletter.inc.php");
+
+if(isset($_POST['see'])) {
+ $art = new NLArticle($_POST['title'], $_POST['body'], $_POST['append']);
+ $page->assign('art', $art);
+} elseif($_POST['valid']) {
+ $nl = new Newsletter();
+ $art = new NLArticle($_POST['title'], $_POST['body'], $_POST['append']);
+ $nl->saveArticle($art);
+
+ require("diogenes.mailer.inc.php");
+ $to = 'Equipe Newsletter Polytechnique.org <info+nlp@polytechnique.org>';
+ $from = "{$_SESSION['prenom']} {$_SESSION['nom']} ({$_SESSION['promo']}) <{$_SESSION['forlife']}@polytechnique.org>";
+ $mailer = new DiogenesMailer($from,$to,"proposition d'article dans la NL",false,$from);
+ $text = "l'article suivant a été proposé par:\n\n $from\n\n\n".$art->toText();
+ $mailer->setBody($text);
+ $mailer->send();
+
+ $page->assign('submited', true);
+}
+
+$page->run();
+?>
* Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************
- $Id: newsletter.inc.php,v 1.5 2004-10-15 22:31:13 x2000habouzit Exp $
+ $Id: newsletter.inc.php,v 1.6 2004-10-16 17:49:38 x2000habouzit Exp $
***************************************************************************/
define('FEMME', 1);
define('HOMME', 0);
+function enriched_to_text($input,$html=false) {
+ $text = stripslashes(trim($input));
+ if($html) {
+ $text = htmlspecialchars($text);
+ $text = str_replace('[b]','<strong>', $text);
+ $text = str_replace('[/b]','</strong>', $text);
+ $text = str_replace('[i]','<em>', $text);
+ $text = str_replace('[/i]','</em>', $text);
+ $text = str_replace('[u]','<span style="text-decoration: underline">', $text);
+ $text = str_replace('[/u]','</span>', $text);
+ $text = preg_replace('!((https?|ftp)://[^\r\n\t ]*)!','<a href="\1">\1</a>', $text);
+ $text = preg_replace('!([a-zA-Z0-9\-_+.]*@[a-zA-Z0-9\-_+.]*)!','<a href="mailto:\1">\1</a>', $text);
+ return nl2br($text);
+ } else {
+ $text = preg_replace('!\[\/?b\]!','*',$text);
+ $text = preg_replace('!\[\/?u\]!','_',$text);
+ $text = preg_replace('!\[\/?i\]!','/',$text);
+ $text = preg_replace('!((https?|ftp)://[^\r\n\t ]*)!','[\1]', $text);
+ $text = preg_replace('!([a-zA-Z0-9\-_+.]*@[a-zA-Z0-9\-_+.]*)!','[mailto:\1]', $text);
+ return wordwrap($text, 68);
+ }
+}
+
+
class NewsLetter {
+ var $_id;
var $_cats;
- function NewsLetter() {
+ function NewsLetter($id=null) {
global $globals;
- $res = $globals->db->query("SELECT cid,title FROM newsletter_cat ORDER BY pos");
+ if(isset($id)) {
+ $res = $globals->db->query("SELECT * FROM newsletter WHERE id='$id'");
+ } else {
+ $res = $globals->db->query("SELECT * FROM newsletter WHERE bits='new'");
+ }
+ $nl = mysql_fetch_assoc($res);
+ $this->_id = $nl['id'];
+ mysql_free_result($res);
+
+ $res = $globals->db->query("SELECT cid,titre FROM newsletter_cat ORDER BY pos");
$this->_cats = Array();
while(list($cid,$title) = mysql_fetch_row($res)) {
$this->_cats[$cid] = $title;
mysql_free_result($res);
}
+
+
+ function saveArticle(&$a) {
+ global $globals;
+ if($a->_aid) {
+ $globals->db->query("REPLACE INTO newsletter_art (id,aid,cid,pos,title,body.append)
+ VALUES({$this->_id},{$a->_aid},{$a->_cid},{$a->_pos},
+ '{$a->_title}','{$a->_body}','{$a->_append}')");
+ } else {
+ $globals->db->query(
+ "INSERT INTO newsletter_art
+ SELECT {$this->_id},MAX(aid)+1,0,100,'{$a->_title}','{$a->_body}','{$a->_append}'
+ FROM newsletter_art AS a
+ WHERE a.id={$this->_id}");
+ }
+ }
}
class NLArticle {
- function NLArticle() { }
+ var $_aid;
+ var $_cid;
+ var $_pos;
+ var $_title;
+ var $_body;
+ var $_append;
+
+ function NLArticle($title,$body,$append,$aid=null,$cid=0,$pos=100) {
+ $this->_body = $body;
+ $this->_title = $title;
+ $this->_append = $append;
+ $this->_aid = $aid;
+ $this->_cid = $aid;
+ $this->_pos = $aid;
+ }
+
+ function body() { return stripslashes(trim($this->_body)); }
+ function append() { return stripslashes(trim($this->_append)); }
+
+ function toText() {
+ $title = '*'.stripslashes($this->_title).'*';
+ $body = enriched_to_text($this->_body);
+ $app = enriched_to_text($this->_append);
+ return trim("$title\n\n$body\n\n$app")."\n";
+ }
+
+ function toHtml() {
+ $title = '<strong>'.stripslashes($this->_title).'</strong>';
+ $body = enriched_to_text($this->_body,true);
+ $app = enriched_to_text($this->_append,true);
+
+ $art = "$title<br /><br />$body<br />";
+ if ($app) $art .= "<br />$app<br />";
+
+ return $art;
+ }
+
+ function check() {
+ $text = enriched_to_text($this->_body);
+ $arr = explode("\n",wordwrap($text,68));
+ $c = 0;
+ foreach($arr as $line) if(trim($line)) $c++;
+ return $c<9;
+ }
}
class NLConstraint {
-- -----------------------------------------------------------------------------
-- update old table
--
-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;
update newsletter set bits='old';
aid smallint unsigned not null,
cid smallint unsigned not null,
pos tinyint unsigned not null,
- texte mediumtext not null,
+ title mediumtext not null,
+ body mediumtext not null,
+ append mediumtext not null,
PRIMARY KEY (id,aid)
);
--
-- -----------------------------------------------------------------------------
--- newsletter appends
---
-create table newsletter_contact (
- id int unsigned not null,
- aid smallint unsigned not null,
- titre varchar(128) not null,
- content varchar(128) not null,
- type enum('url','mail','text','none'),
- PRIMARY KEY (id,aid)
-);
--- -----------------------------------------------------------------------------
* Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************
- $Id: contacts.tpl,v 1.9 2004-08-31 20:19:30 x2000habouzit Exp $
+ $Id: contacts.tpl,v 1.10 2004-10-16 17:49:39 x2000habouzit Exp $
***************************************************************************}
sus).
</p>
<p>
-Une fois que ton article est prêt et qu'il ne dépasse pas la taille indiquée, il te suffit
-de nous le soumettre par email (éviter les pièces jointes) à cette adresse :
+Un formulaire en ligne te permet de nous soumettre un article, et se chargera de vérifier
+ces contraintes pour toi : <a href='{"newsletter/submit.php"|url}'>soumission d'article</a>.
+</p>
+<p>
+Sinon, une fois que ton article est prêt et qu'il ne dépasse pas la taille indiquée,
+tu peux aussi nous le soumettre par email (éviter les pièces jointes) à cette adresse :
<strong>{mailto address='info_nlp@polytechnique.org' encode='hex'}</strong>.
</p>
<p>
Les anciennes newsletters de <strong>Polytechnique.org</strong> sont
-<strong><a href="../newsletter.php">archivées</a></strong> si tu veux t'en inspirer.
+<strong><a href="{"newsletter/"|url}">archivées</a></strong> si tu veux t'en inspirer.
</p>
{elseif $smarty.request.topic eq 6}
* Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************
- $Id: index.tpl,v 1.1 2004-10-15 12:57:11 x2000habouzit Exp $
+ $Id: index.tpl,v 1.2 2004-10-16 17:49:39 x2000habouzit Exp $
***************************************************************************}
</p>
<p>
<strong>Pour demander l'ajout d'une annonce dans la prochaine lettre mensuelle</strong>,
-<a href="mailto:info_newsletter@polytechnique.org">écris-nous !</a>
+utilise <a href='submit.php'>le formulaire dédié !</a>.
</p>
{dynamic}
--- /dev/null
+{***************************************************************************
+ * 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: submit.tpl,v 1.1 2004-10-16 17:49:39 x2000habouzit Exp $
+ ***************************************************************************}
+
+
+<div class="rubrique">
+ Proposer un article à sur la prochaine Lettre mensuelle
+</div>
+
+{dynamic}
+
+{if $submited}
+
+<p>
+ton article a bien été pris en compte.
+</p>
+
+<p>
+Nous te recontacterons éventuellement (certainement vers la fin du mois) si nous avons des
+renseignements à te demander à son sujet !
+</p>
+
+{else}
+
+
+{if $art}
+
+{if !$art->check()}
+<p class='erreur'>
+article trop long !<br />
+il faut te limiter à 8 lignes de 68 caractères.
+</p>
+{/if}
+
+<form action="{$smarty.server.PHP_SELF}" method='post'>
+<table class='tinybicol'>
+ <tr><th>Version texte</th></tr>
+ <tr id='text'>
+ <td><pre>{$art->toText()}</pre></td>
+ </tr>
+ {if $art->check()}
+ <tr><th>Version html</th></tr>
+ <tr id='html'>
+ <td>
+ <div style="margin: auto; font-familly:georgia; width:56ex; text-align: justify">
+ {$art->toHtml()|smarty:nodefaults}
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <th>Soumettre</th>
+ </tr>
+ <tr>
+ <td>
+ Si tu es content de ton article, tu peux le soummetre.
+ Sinon, tu peux continuer à l'éditer en dessous
+ </td>
+ </tr>
+ <tr>
+ <td class='center'>
+ <input type='hidden' value="{$smarty.request.title}" name='title' />
+ <input type='hidden' value="{$art->body()}" name="body" />
+ <input type='hidden' value="{$art->append()}" name='append' />
+ <input type='submit' name='valid' value='soumettre' />
+ </td>
+ </tr>
+ {/if}
+</table>
+</form>
+
+<br />
+
+{/if}
+
+<form action="{$smarty.server.PHP_SELF}" method='post'>
+ <table class="bicol" cellpadding="3" cellspacing="0" summary="liste des NL">
+ <tr>
+ <th colspan='2'>proposer un article</th>
+ </tr>
+ <tr class="impair">
+ <td class='titre'>Sujet</td>
+ <td>
+ <input type='text' value='{$smarty.request.title}' name='title' />
+ </td>
+ </tr>
+ <tr class="pair">
+ <td class='titre'>Contenu</td>
+ <td>
+ <textarea cols="68" rows="10" name='body'>{if $art}{$art->body()}{/if}</textarea>
+ </td>
+ </tr>
+ <tr class="pair">
+ <td class='titre'>Ajouts (emails,contacts,tarifs,site web, ...)</td>
+ <td>
+ <textarea cols="68" rows="6" name='append'>{if $art}{$art->append()}{/if}</textarea>
+ </td>
+ </tr>
+ <tr class='impair'>
+ <td colspan='2' class='center'>
+ <input type='submit' name='see' value='visualiser' />
+ </td>
+ </tr>
+ </table>
+</form>
+
+{/if}
+
+{/dynamic}
+
+{* vim:set et sw=2 sts=2 sws=2: *}