migrate newsletter
authorx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 11 Jul 2006 19:03:38 +0000 (19:03 +0000)
committerx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 11 Jul 2006 19:03:38 +0000 (19:03 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@437 839d8a87-29fc-0310-9880-83ba4fa771e5

htdocs/newsletter/index.php [deleted file]
htdocs/newsletter/submit.php [deleted file]
include/newsletter.inc.php
modules/events.php
templates/admin/newsletter.tpl
templates/newsletter/index.tpl
templates/newsletter/submit.tpl

diff --git a/htdocs/newsletter/index.php b/htdocs/newsletter/index.php
deleted file mode 100644 (file)
index 6a3184a..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 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                *
- ***************************************************************************/
-
-require_once("xorg.inc.php");
-new_skinned_page('newsletter/index.tpl', AUTH_COOKIE);
-$page->assign('xorg_title','Polytechnique.org - Lettres mensuelles');
-require_once("newsletter.inc.php");
-
-if(Get::has('out')) { unsubscribe_nl(); }
-if(Get::has('in'))  { subscribe_nl(); }
-
-$page->assign('nls',get_nl_state());
-$page->assign_by_ref('nl_list',get_nl_list());
-$page->run();
-
-?>
diff --git a/htdocs/newsletter/submit.php b/htdocs/newsletter/submit.php
deleted file mode 100644 (file)
index b6e31ac..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 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                *
- ***************************************************************************/
-
-require_once("xorg.inc.php");
-new_skinned_page('newsletter/submit.tpl', AUTH_COOKIE);
-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')) {
-    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);
-}
-
-$page->run();
-?>
index 6528a60..9fb1ec4 100644 (file)
@@ -175,18 +175,18 @@ class NewsLetter
        if ($html) {
            return '<div class="foot">Cette lettre est envoyée à tous les Polytechniciens sur Internet par l\'intermédiaire de Polytechnique.org.</div>'
            .  '<div class="foot">'
-           .  "[<a href=\"$url/newsletter/\">archives</a>&nbsp;|&nbsp;"
-           .  "<a href=\"$url/newsletter/submit.php\">écrire dans la NL</a>&nbsp;|&nbsp;"
-           .  "<a href=\"$url/newsletter/?out=1\">ne plus recevoir</a>]"
+           .  "[<a href=\"$url/nl\">archives</a>&nbsp;|&nbsp;"
+           .  "<a href=\"$url/nl/submit\">écrire dans la NL</a>&nbsp;|&nbsp;"
+           .  "<a href=\"$url/nl/out\">ne plus recevoir</a>]"
            .  '</div>';
        } else {
            return "\n\n--------------------------------------------------------------------\n"
                 . "Cette lettre est envoyée à tous les Polytechniciens sur Internet par\n"
                 . "l'intermédiaire de Polytechnique.org.\n"
                 . "\n"
-                . "archives : [$url/newsletter/]\n"
-                . "écrire   : [$url/newsletter/submit.php]\n"
-                . "ne plus recevoir: [$url/newsletter/?out=1]\n";
+                . "archives : [$url/nl]\n"
+                . "écrire   : [$url/nl/submit]\n"
+                . "ne plus recevoir: [$url/nl/out]\n";
        }
     }
 
index 284e2ca..6169b82 100644 (file)
@@ -24,9 +24,11 @@ class EventsModule extends PLModule
     function handlers()
     {
         return array(
-            'events/submit'  => $this->make_hook('submit', AUTH_MDP),
+            'events/submit'  => $this->make_hook('submit',    AUTH_MDP),
 
-            'nl/show'        => $this->make_hook('nl',     AUTH_COOKIE),
+            'nl'             => $this->make_hook('nl',        AUTH_COOKIE),
+            'nl/show'        => $this->make_hook('nl_show',   AUTH_COOKIE),
+            'nl/submit'      => $this->make_hook('nl_submit', AUTH_COOKIE),
         );
     }
 
@@ -82,7 +84,26 @@ class EventsModule extends PLModule
         return PL_OK;
     }
 
-    function handler_nl(&$page, $nid = 'last')
+    function handler_nl(&$page, $action = null)
+    {
+        require_once 'newsletter.inc.php';
+
+        $page->changeTpl('newsletter/index.tpl');
+        $page->assign('xorg_title','Polytechnique.org - Lettres mensuelles');
+
+        switch ($action) {
+          case 'out': unsubscribe_nl(); break;
+          case 'in':  subscribe_nl(); break;
+          default: ;
+        }
+
+        $page->assign('nls', get_nl_state());
+        $page->assign_by_ref('nl_list', get_nl_list());
+
+        return PL_OK;
+    }
+
+    function handler_nl_show(&$page, $nid = 'last')
     {
         $page->changeTpl('newsletter/show.tpl');
 
@@ -99,6 +120,26 @@ class EventsModule extends PLModule
 
         return PL_OK;
     }
+
+    function handler_nl_submit(&$page)
+    {
+        $page->changeTpl('newsletter/submit.tpl');
+
+        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')) {
+            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);
+        }
+
+        return PL_OK;
+    }
 }
 
 ?>
index a073ca0..3a3ece1 100644 (file)
@@ -37,7 +37,7 @@
   <tr class="{cycle values="pair,impair"}">
     <td>{$nl.date|date_format}</td>
     <td>
-      <a href="{"admin/newsletter_edit.php"|url}?nid={$nl.id}">{$nl.titre|default:"[no title]"}</a>
+      <a href="{rel}/admin/newsletter_edit.php?nid={$nl.id}">{$nl.titre|default:"[no title]"}</a>
     </td>
   </tr>
   {/foreach}
index 7876b9f..08d52f1 100644 (file)
@@ -27,7 +27,7 @@
 
 <p>
 <strong>Pour demander l'ajout d'une annonce dans la prochaine lettre mensuelle</strong>,
-utilise <a href='submit.php'>le formulaire dédié !</a>
+utilise <a href='{rel}/nl/submit'>le formulaire dédié !</a>
 </p>
 
 <h2>Ton statut</h2>
@@ -37,14 +37,14 @@ utilise <a href='submit.php'>le formulaire d
 Tu es actuellement inscrit à la lettre mensuelle de Polytechnique.org (pour choisir le format HTML ou texte, rends toi sur la page <a href='{rel}/preferences'>des préférences</a>)
 </p>
 <div class='center'>
-  [<a href='?out=1'>me désinscrire de la lettre mensuelle</a>]
+  [<a href='{rel}/nl/out'>me désinscrire de la lettre mensuelle</a>]
 </div>
 {else}
 <p>
 Tu n'es actuellement pas inscrit à la lettre mensuelle de Polytechnique.org.
 </p>
 <div class='center'>
-  [<a href='?in=1'>m'inscrire à la lettre mensuelle</a>]
+  [<a href='{rel}/nl/in'>m'inscrire à la lettre mensuelle</a>]
 </div>
 {/if}
 
index a5977fd..13a7829 100644 (file)
 {*                                                                        *}
 {**************************************************************************}
 
-
-<h1>
-  Proposer un article pour la prochaine Lettre mensuelle
-</h1>
-
+<h1>Proposer un article pour la prochaine Lettre mensuelle</h1>
 
 {if $submited}
 
@@ -49,7 +45,7 @@ Il te faut te limiter 
 </p>
 {/if}
 
-<form action="{$smarty.server.PHP_SELF}" method='post'>
+<form action="{rel}/nl/submit" method='post'>
   <table class='tinybicol'>
     <tr><th>Version texte</th></tr>
     <tr id='text'>
@@ -97,7 +93,7 @@ Il faut absolument que ton article fasse moins de 8 lignes (non vides) de 68 car
 Les contacts, prix, adresses mail utiles, liens web, ...  sont en sus, et sont à placer dans la case "Ajouts"
 </p>
 
-<form action="{$smarty.server.PHP_SELF}" method='post'>
+<form action="{rel}/nl/submit" method='post'>
   <table class="bicol" cellpadding="3" cellspacing="0" summary="liste des NL">
     <tr>
       <th colspan='2'>proposer un article</th>