move preferences.php into new core module.
authorx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sat, 8 Jul 2006 21:54:41 +0000 (21:54 +0000)
committerx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sat, 8 Jul 2006 21:54:41 +0000 (21:54 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@394 839d8a87-29fc-0310-9880-83ba4fa771e5

ChangeLog
hooks/tmp.inc.php
htdocs/preferences.php [deleted file]
modules/platal.php [new file with mode: 0644]
templates/carnet/mescontacts.tpl
templates/newsletter/index.tpl

index 841a5a1..3beb0e8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,9 @@ New:
     * Marketing:
         - Switch to the new URI scheme.                                     -MC
 
+    * Platal:
+        - Create module.                                                    -MC
+
     * Search:
         - Switch to the new URI scheme.                                     -MC
 
index 7763a86..e83fd3f 100644 (file)
@@ -27,7 +27,7 @@ function tmp_menu()
     $globals->menu->addPrivateEntry(XOM_CUSTOM,   20, 'Mes contacts',       'carnet/mescontacts.php');
     $globals->menu->addPrivateEntry(XOM_CUSTOM,   30, 'Mon carnet',         'carnet/');
     $globals->menu->addPrivateEntry(XOM_CUSTOM,   40, 'Mon mot de passe',   'motdepasse.php');
-    $globals->menu->addPrivateEntry(XOM_CUSTOM,   50, 'Mes préférences',    'preferences.php');
+    $globals->menu->addPrivateEntry(XOM_CUSTOM,   50, 'Mes préférences',    'preferences');
 
     $globals->menu->addPrivateEntry(XOM_GROUPS,   10, 'Trombi/Site promo',  'trombipromo.php');
     $globals->menu->addPrivateEntry(XOM_GROUPS,   20, 'Conseil Pro.',       'referent.php');
@@ -76,14 +76,14 @@ function tmp_prefs()
     $fmt2 = Session::get('mail_fmt', 'html') == 'html' ? 'texte' : 'HTML';
     return Array(
             Array(
-                'url'    => 'preferences.php?mail_fmt='.$fmt,
+                'url'    => 'preferences?mail_fmt='.$fmt,
                 'title'  => 'Recevoir les mails en format '.$fmt2,
                 'text'   => 'Tu recois les mails envoyés par le site (lettre mensuelle, carnet, ...) de préférence <strong>sous forme de '
                             .Session::get('mail_fmt', 'html').'</strong>',
                 'weight' => 80
             ),
             Array(
-                'url'    => 'preferences.php?rss='.(intval(Session::get('core_rss_hash')=='')),
+                'url'    => 'preferences?rss='.(intval(Session::get('core_rss_hash')=='')),
                 'title'  => (Session::get('core_rss_hash') ? 'Désactiver' : 'Activer').' les fils rss',
                 'text'   => 'Ceci te permet d\'utiliser les fils rss du site. Attention, désactiver puis réactiver les fils en change les URL !',
                 'weight' => 90
diff --git a/htdocs/preferences.php b/htdocs/preferences.php
deleted file mode 100644 (file)
index b2cb4bb..0000000
+++ /dev/null
@@ -1,52 +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('preferences.tpl', AUTH_COOKIE);
-$page->assign('xorg_title','Polytechnique.org - Mes préférences');
-
-if (Env::has('mail_fmt')) {
-    $fmt=Env::get('mail_fmt');
-    if ($fmt != 'texte') $fmt = 'html';
-    $globals->xdb->execute("      UPDATE auth_user_quick
-                                     SET core_mail_fmt = '$fmt'
-                                   WHERE user_id = {?}", Session::getInt('uid'));
-    $_SESSION['mail_fmt'] = $fmt;
-    redirect('preferences.php');
-}
-
-if (Env::has('rss')) {
-    if (Env::getBool('rss')) {
-        $_SESSION['core_rss_hash'] = rand_url_id(16);
-        $globals->xdb->execute('UPDATE auth_user_quick SET core_rss_hash={?} WHERE user_id={?}',
-                Session::get('core_rss_hash'), Session::getInt('uid'));
-    } else {
-        $globals->xdb->execute('UPDATE auth_user_quick SET core_rss_hash="" WHERE user_id={?}', Session::getInt('uid'));
-        Session::kill('core_rss_hash');
-    }
-    redirect('preferences.php');
-}
-
-$page->assign('prefs', $globals->hook->prefs());
-$page->run();
-
-// vim:set et sw=4 sts=4 sws=4:
-?>
diff --git a/modules/platal.php b/modules/platal.php
new file mode 100644 (file)
index 0000000..46cbb49
--- /dev/null
@@ -0,0 +1,69 @@
+<?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 PlatalModule extends PLModule
+{
+    function handlers()
+    {
+        return array(
+            'preferences' => $this->make_hook('prefs', AUTH_COOKIE),
+        );
+    }
+
+    function handler_prefs(&$page)
+    {
+        global $globals;
+
+        $page->changeTpl('preferences.tpl');
+        $page->assign('xorg_title','Polytechnique.org - Mes préférences');
+
+        if (Env::has('mail_fmt')) {
+            $fmt = Env::get('mail_fmt');
+            if ($fmt != 'texte') $fmt = 'html';
+            $globals->xdb->execute("UPDATE auth_user_quick
+                                       SET core_mail_fmt = '$fmt'
+                                     WHERE user_id = {?}",
+                                     Session::getInt('uid'));
+            $_SESSION['mail_fmt'] = $fmt;
+            redirect('preferences');
+        }
+
+        if (Env::has('rss')) {
+            if (Env::getBool('rss')) {
+                $_SESSION['core_rss_hash'] = rand_url_id(16);
+                $globals->xdb->execute('UPDATE  auth_user_quick
+                                           SET  core_rss_hash={?} WHERE user_id={?}',
+                                       Session::get('core_rss_hash'),
+                                       Session::getInt('uid'));
+            } else {
+                $globals->xdb->execute('UPDATE  auth_user_quick
+                                           SET  core_rss_hash="" WHERE user_id={?}',
+                                       Session::getInt('uid'));
+                Session::kill('core_rss_hash');
+            }
+            redirect('preferences');
+        }
+
+        $page->assign('prefs', $globals->hook->prefs());
+    }
+}
+
+?>
index 6a0c793..d2212ff 100644 (file)
@@ -63,7 +63,7 @@ Pour r
   </div>
 {else}
 <p>
-  Pour récupérer un calendrier iCal avec l'anniversaire de tes contacts, active les flux RSS dans <a href="{rel}/preferences.php">Mes préférences</a>.
+  Pour récupérer un calendrier iCal avec l'anniversaire de tes contacts, active les flux RSS dans <a href="{rel}/preferences">Mes préférences</a>.
 </p>
 {/if}
 
index a7253ad..cb96b6e 100644 (file)
@@ -34,7 +34,7 @@ utilise <a href='submit.php'>le formulaire d
 
 {if $nls}
 <p>
-Tu es actuellement inscrit à la lettre mensuelle de Polytechnique.org (pour choisir le format HTML ou texte, rends toi sur la page <a href='../preferences.php'>des préférences</a>)
+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>]