migrate events submission
authorx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 11 Jul 2006 18:33:46 +0000 (18:33 +0000)
committerx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 11 Jul 2006 18:33:46 +0000 (18:33 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@435 839d8a87-29fc-0310-9880-83ba4fa771e5

htdocs/evenements.php [deleted file]
modules/events.php [new file with mode: 0644]
templates/evenements.tpl
templates/include/form.evenement.tpl
templates/login.tpl

diff --git a/htdocs/evenements.php b/htdocs/evenements.php
deleted file mode 100644 (file)
index f85daca..0000000
+++ /dev/null
@@ -1,63 +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('evenements.tpl', AUTH_MDP);
-
-$titre              = Post::get('titre');
-$texte              = Post::get('texte');
-$promo_min          = Post::getInt('promo_min');
-$promo_max          = Post::getInt('promo_max');
-$peremption         = Post::getInt('peremption');
-$validation_message = Post::get('validation_message');
-$action             = Post::get('action');
-
-$page->assign('titre', $titre);
-$page->assign('texte', $texte);
-$page->assign('promo_min', $promo_min);
-$page->assign('promo_max', $promo_max);
-$page->assign('peremption', $peremption);
-$page->assign('validation_message', $validation_message);
-$page->assign('action', strtolower($action));
-
-if ($action=="Confirmer") {
-    $texte = preg_replace( "/((http|ftp)+(s)?:\/\/[^<>\s]+)/i", "<a href=\"\\0\">\\0</a>", $texte );
-    $texte = preg_replace( "/([^,\s]+@[^,\s]+)/i", "<a href=\"mailto:\\0\">\\0</a>", $texte );
-    require_once("validations.inc.php");
-    $evtreq = new evtreq($titre, $texte, $promo_min, $promo_max,
-            $peremption, $validation_message, Session::getInt('uid'));
-    $evtreq->submit();
-    $page->assign('ok', true);
-}
-
-$select = "";
-for ($i = 1 ; $i < 30 ; $i++) {
-    $p_stamp=date("Ymd",time()+3600*24*$i);
-    $year=substr($p_stamp,0,4);
-    $month=substr($p_stamp,4,2);
-    $day=substr($p_stamp,6,2);
-
-    $select .= "<option value=\"$p_stamp\"" . (($p_stamp == strtr($peremption, array("-" => ""))) ? " selected" : "")."> $day / $month / $year</option>\n";
-}
-$page->assign('select',$select);
-$page->run();
-
-?>
diff --git a/modules/events.php b/modules/events.php
new file mode 100644 (file)
index 0000000..76ff087
--- /dev/null
@@ -0,0 +1,84 @@
+<?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                *
+ ***************************************************************************/
+
+class EventsModule extends PLModule
+{
+    function handlers()
+    {
+        return array(
+            'events/submit'  => $this->make_hook('submit', AUTH_MDP),
+        );
+    }
+
+    function handler_submit(&$page)
+    {
+        global $globals;
+        $page->changeTpl('evenements.tpl');
+
+        $titre      = Post::get('titre');
+        $texte      = Post::get('texte');
+        $promo_min  = Post::getInt('promo_min');
+        $promo_max  = Post::getInt('promo_max');
+        $peremption = Post::getInt('peremption');
+        $valid_mesg = Post::get('valid_mesg');
+        $action     = Post::get('action');
+
+        $page->assign('titre', $titre);
+        $page->assign('texte', $texte);
+        $page->assign('promo_min', $promo_min);
+        $page->assign('promo_max', $promo_max);
+        $page->assign('peremption', $peremption);
+        $page->assign('valid_mesg', $valid_mesg);
+        $page->assign('action', strtolower($action));
+
+        if ($action == 'Confirmer') {
+            $texte = preg_replace('/((http|ftp)+(s)?:\/\/[^<>\s]+)/i',
+                                  '<a href=\"\\0\">\\0</a>', $texte);
+            $texte = preg_replace('/([^,\s]+@[^,\s]+)/i',
+                                  '<a href=\"mailto:\\0\">\\0</a>', $texte);
+            require_once 'validations.inc.php';
+            $evtreq = new EvtReq($titre, $texte, $promo_min, $promo_max,
+                                 $peremption, $valid_mesg, Session::getInt('uid'));
+            $evtreq->submit();
+            $page->assign('ok', true);
+        }
+
+        $select = '';
+        for ($i = 1 ; $i < 30 ; $i++) {
+            $time    = time() + 3600 * 24 * $i;
+            $p_stamp = date('Ymd', $time);
+            $year    = date('Y',   $time);
+            $month   = date('m',   $time);
+            $day     = date('d',   $time);
+
+            $select .= "<option value=\"$p_stamp\"";
+            if ($p_stamp == strtr($peremption, array("-" => ""))) {
+                $select .= " selected='selected'";
+            }
+            $select .= "> $day / $month / $year</option>\n";
+        }
+        $page->assign('select',$select);
+
+        return PL_OK;
+    }
+}
+
+?>
index c7f3c83..6287875 100644 (file)
 {*                                                                        *}
 {**************************************************************************}
 
-
-<h1>
-  Proposition d'information événementielle
-</h1>
-
+<h1>Proposition d'information événementielle</h1>
 
 {if $action eq "proposer"}
 
@@ -33,12 +29,8 @@ Voici ton annonce :
 </p>
 
 <table class="bicol">
-  <tr>
-    <th>{$titre|nl2br}</th>
-  </tr>
-  <tr>
-    <td>{$texte|nl2br}</td>
-  </tr>
+  <tr><th>{$titre|nl2br}</th></tr>
+  <tr><td>{$texte|nl2br}</td></tr>
 </table>
 
 <p>
@@ -51,22 +43,22 @@ de toutes les promotions
 et sera affiché sur la page d'accueil jusqu'au {$peremption|date_format}
 </p>
 
-{if $validation_message}
+{if $valid_mesg}
 <p>
-Tu as ajouté le message suivant à l'intention du validateur : {$validation_message|nl2br}
+Tu as ajouté le message suivant à l'intention du validateur : {$valid_mesg|nl2br}
 </p>
 {/if}
 
-<form action="{$smarty.request.PHP_SELF}" method="post">
+<form action="{rel}/events/submit" method="post">
   <div>
-    <input type="hidden" name="titre" value="{$titre}" />
-    <input type="hidden" name="texte" value="{$texte}" />
-    <input type="hidden" name="promo_min" value="{$promo_min}" />
-    <input type="hidden" name="promo_max" value="{$promo_max}" />
+    <input type="hidden" name="titre"      value="{$titre}" />
+    <input type="hidden" name="texte"      value="{$texte}" />
+    <input type="hidden" name="promo_min"  value="{$promo_min}" />
+    <input type="hidden" name="promo_max"  value="{$promo_max}" />
     <input type="hidden" name="peremption" value="{$peremption}" />
-    <input type="hidden" name="validation_message" value="{$validation_message}" />
-    <input type="submit" name="action" value="Confirmer" />
-    <input type="submit" name="action" value="Modifier" />
+    <input type="hidden" name="valid_mesg" value="{$valid_mesg}" />
+    <input type="submit" name="action"     value="Confirmer" />
+    <input type="submit" name="action"     value="Modifier" />
   </div>
 </form>
 
@@ -81,11 +73,12 @@ Ta proposition a bien 
 Merci pour ta contribution à la vie du site!
 </p>
 <p>
-<a href="login.php">Retour à la page d'accueil</a>
+<a href="{rel}/login.php">Retour à la page d'accueil</a>
 </p>
 {else}
 <p class="erreur">
-Une erreur s'est produite pendant l'enregistrement de ta proposition.  Merci de nous <a href="contacts.php">contacter</a>!
+Une erreur s'est produite pendant l'enregistrement de ta proposition.
+Merci de nous <a href="{rel}/Docs/NousContacter">contacter</a>!
 </p>
 {/if}
 
index 5e47da6..5f81353 100644 (file)
@@ -20,8 +20,7 @@
 {*                                                                        *}
 {**************************************************************************}
 
-
-<form action="{$smarty.server.PHP_SELF}" method="post">
+<form action="{rel}/{$platal->path}" method="post">
   <table class="bicol">
     <tr>
       <th colspan="2">Contenu du message</th>
index e121e63..c6f552d 100644 (file)
@@ -140,7 +140,7 @@ Bienvenue {$smarty.session.prenom}
   </p>
 
   <p>
-  <a href="evenements.php">Proposer une information événementielle</a>
+  <a href="{rel}/events/submit">Proposer une information événementielle</a>
   </p>
   {if $smarty.session.core_rss_hash}
   <div class="right">